25 static
bool _init = false;
26 static
int _conTunTaskId = TASK_ID_NONE;
28 #define _STRBUF_MAX 240
29 #define _MSGBUF_MAX 512
32 static void rxVUart(
SUART_Device * suart,
char * tgtStr,
size_t tgtSize)
34 char * lastChar = tgtStr + tgtSize - 1;
35 uint32_t hostRx = suart->
HOST_RX;
36 while (hostRx & SUART_HOST_RX_READY)
38 *tgtStr = hostRx & SUART_HOST_RX_DATAMASK;
40 if (tgtStr == lastChar)
break;
49 while (*srcStr !=
'\0')
51 if (*srcStr !=
'\n') {
55 suart->
HOST_TX = SUART_HOST_TX_DATAMASK & *srcStr;
63 static void conTunTask()
65 char strBuf[_STRBUF_MAX];
66 uint8_t msgBuf[_MSGBUF_MAX];
69 rxVUart(
PTP_SUART, strBuf,
sizeof(strBuf));
71 rxVUart(
SUART1, strBuf,
sizeof(strBuf));
87 if (_conTunTaskId != TASK_ID_NONE)
schdStop(_conTunTaskId);
88 logInfo(
"Console tunnel closed");
97 if (_conTunTaskId == TASK_ID_NONE)
99 if (!
schdRegister(conTunTask,
false, &_conTunTaskId))
return false;
105 logInfo(
"Console tunnel opened");
113 if (ptp != NULL && strlen(ptp) > 0) {
116 if (secLm32 != NULL && strlen(secLm32) > 0) {
void schdRunPeriodic(int taskId, int interval)
Schedule a task to run periodically.
const volatile unsigned int STATUS
Status Register.
bool msgTxEvent(int msgType, DataBuffer *buf)
Invoked to send an event.
bool schdRegister(SchdTaskF task, bool priority, int *taskId)
Register a task with the scheduler.
Simple task scheduler for tasks.
#define SUART_STATUS_RX_RDY
Uart has rx data ready.
const volatile unsigned int HOST_RX
Host receive register.
Structure defines White Rabbit Simple Uart.
void schdStop(int taskId)
Stop a scheduled task.
#define E_INVSTATE
Generic error: Module is in a state in which.
#define SUART1
SUART base pointer.
Defines a DataBuffer structure.
#define PTP_SUART
PTP UART in WR space.
static uint32_t dbLength(DataBuffer *buf)
Returns the lenght of the current buffer.
#define EVT_SYS_CONTUN_RECV
Event when character data is available on any of the consoles.
void conTunSend(char *ptp, char *secLm32)
Send characters to PTP core and second LM32.
Combination of IP address and port.
This modules provides console tunneling, for both PTP core and 2nd LM32.
This module is responsible for distributing error codes.
#define LOG_DEF(NAME,...)
Define a logger for a module.
bool conTunInit(SockAddr *addr)
Initializes the console tunnel.
bool dbWriteString(DataBuffer *buf, const char *s, int max)
Writes a String as 'sort of' UTF-8 encoding, as defined in the Java DataOuput and DataInput writeUTF ...
This file assigns all device structures to memory mapped structures.
bool errSet(uint32_t code, const char *error, const char *name)
Sets an error.
Implements a generic logger facility.
#define DB_STR_OVERHEAD
Overhead for a String.
#define DB_BUF_INIT(PTR, LEN)
Simple buffer initialization.
volatile unsigned int HOST_TX
Host Transmit register.
#define logInfo(MSG,...)
Write a log message with formatting on info level.