/*! * \brief Flushes the given buffer/queue. The buffer will be sent over the radio. * \return Error code, ERR_OK for no error. */ static uint8_t FlushAndTxQueue(RSTDIO_QueueType queueType, RAPP_MSG_Type msgType) { unsigned char buf[RAPP_BUFFER_SIZE]; uint8_t i; uint8_t res = ERR_OK; uint8_t *p, ch; p = RAPP_BUF_PAYLOAD_START(buf); i = 0; while (i<RAPP_PAYLOAD_SIZE) { ch = RSTDIO_ReceiveQueueChar(queueType); if (ch=='\0') { /* queue empty */ break; } *p++ = ch; i++; } res = RAPP_PutPayload(buf, sizeof(buf), i, msgType, RSTDIO_dstAddr); if (res!=ERR_OK) { CLS1_ConstStdIOType *io = CLS1_GetStdio(); io->stdErr('*'); io->stdErr('F'); io->stdErr('A'); io->stdErr('I'); io->stdErr('L'); io->stdErr('*'); io->stdErr('\n'); return res; } return res; }
static portTASK_FUNCTION(ShellTask, pvParameters) { #if PL_HAS_USB_CDC static unsigned char cdc_buf[48]; #endif #if PL_HAS_BLUETOOTH static unsigned char bluetooth_buf[48]; #endif static unsigned char localConsole_buf[48]; #if CLS1_DEFAULT_SERIAL CLS1_ConstStdIOTypePtr ioLocal = CLS1_GetStdio(); #endif (void)pvParameters; /* not used */ #if PL_HAS_USB_CDC cdc_buf[0] = '\0'; #endif #if PL_HAS_BLUETOOTH bluetooth_buf[0] = '\0'; #endif localConsole_buf[0] = '\0'; #if CLS1_DEFAULT_SERIAL (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, ioLocal, CmdParserTable); #endif for(;;) { #if CLS1_DEFAULT_SERIAL (void)CLS1_ReadAndParseWithCommandTable(localConsole_buf, sizeof(localConsole_buf), ioLocal, CmdParserTable); #endif #if PL_HAS_USB_CDC (void)CLS1_ReadAndParseWithCommandTable(cdc_buf, sizeof(cdc_buf), &CDC_stdio, CmdParserTable); #endif #if PL_HAS_BLUETOOTH (void)CLS1_ReadAndParseWithCommandTable(bluetooth_buf, sizeof(bluetooth_buf), &BT_stdio, CmdParserTable); #endif #if PL_HAS_SHELL_QUEUE /*! \todo Handle shell queue */ unsigned char ch; while((ch=SQUEUE_ReceiveChar()) && ch!='\0') { #if CLS1_DEFAULT_SERIAL ioLocal->stdOut(ch); #endif #if PL_HAS_USB_CDC CDC_stdio.stdOut(ch); #endif #if PL_HAS_BLUETOOTH BT_stdio.stdOut(ch); /* copy on Bluetooth */ #endif } #endif FRTOS1_vTaskDelay(50/portTICK_RATE_MS); } /* for */ }
static uint8_t GetChar(uint8_t *data, void *q) { CLS1_ConstStdIOType *io; io = (CLS1_ConstStdIOType*)q; if (!io->keyPressed()) { #if USE_XON_XOFF SendXONOFF(io, XON); #endif while(!io->keyPressed()) { /* wait until there is something in the input buffer */ } #if USE_XON_XOFF SendXONOFF(io, XOFF); #endif } io->stdIn(data); /* read character */ if (*data=='\0') { /* end of input? */ return ERR_RXEMPTY; } return ERR_OK; }
static portTASK_FUNCTION(ShellTask, pvParameters) { #if PL_HAS_RSTDIO static unsigned char radio_cmd_buf[48]; CLS1_ConstStdIOType *ioRemote = RSTDIO_GetStdioRx(); #endif #if CLS1_DEFAULT_SERIAL CLS1_ConstStdIOTypePtr ioLocal = CLS1_GetStdio(); #endif (void)pvParameters; /* not used */ #if CLS1_DEFAULT_SERIAL (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, ioLocal, CmdParserTable); #endif for(;;) { #if CLS1_DEFAULT_SERIAL (void)CLS1_ReadAndParseWithCommandTable(localConsole_buf, sizeof(localConsole_buf), ioLocal, CmdParserTable); #endif #if PL_HAS_RSTDIO RSTDIO_Print(ioLocal); /* dispatch incoming messages */ (void)CLS1_ReadAndParseWithCommandTable(radio_cmd_buf, sizeof(radio_cmd_buf), ioRemote, CmdParserTable); #endif #if PL_HAS_BLUETOOTH (void)CLS1_ReadAndParseWithCommandTable(bluetooth_buf, sizeof(bluetooth_buf), &BT_stdio, CmdParserTable); #endif #if PL_HAS_SHELL_QUEUE { unsigned char ch; while((ch=SQUEUE_ReceiveChar()) && ch!='\0') { #if CLS1_DEFAULT_SERIAL ioLocal->stdOut(ch); #endif #if PL_HAS_BLUETOOTH BT_stdio.stdOut(ch); /* copy on Bluetooth */ #endif } } #endif FRTOS1_vTaskDelay(50/portTICK_RATE_MS); } /* for */ }
static void ShellTask(void *pvParameters) { static unsigned char localConsole_buf[48]; #if PL_CONFIG_HAS_USB_CDC static unsigned char cdc_buf[48]; #endif #if PL_CONFIG_HAS_BLUETOOTH static unsigned char bluetooth_buf[48]; #endif #if PL_CONFIG_HAS_SEGGER_RTT static unsigned char rtt_buf[48]; #endif #if CLS1_DEFAULT_SERIAL CLS1_ConstStdIOTypePtr ioLocal = CLS1_GetStdio(); #endif #if PL_CONFIG_HAS_RADIO && RNET_CONFIG_REMOTE_STDIO static unsigned char radio_cmd_buf[48]; CLS1_ConstStdIOType *ioRemote = RSTDIO_GetStdioRx(); #endif (void)pvParameters; /* not used */ #if PL_CONFIG_HAS_USB_CDC cdc_buf[0] = '\0'; #endif #if PL_CONFIG_HAS_BLUETOOTH bluetooth_buf[0] = '\0'; #endif #if PL_CONFIG_HAS_SEGGER_RTT rtt_buf[0] = '\0'; #endif localConsole_buf[0] = '\0'; #if CLS1_DEFAULT_SERIAL (void)CLS1_ParseWithCommandTable((unsigned char*)CLS1_CMD_HELP, ioLocal, CmdParserTable); #endif #if PL_CONFIG_HAS_RADIO && RNET_CONFIG_REMOTE_STDIO radio_cmd_buf[0] = '\0'; #endif for(;;) { #if CLS1_DEFAULT_SERIAL (void)CLS1_ReadAndParseWithCommandTable(localConsole_buf, sizeof(localConsole_buf), ioLocal, CmdParserTable); #endif #if PL_CONFIG_HAS_USB_CDC #if SHELL_COPY_CDC_TO_UART (void)CLS1_ReadAndParseWithCommandTable(cdc_buf, sizeof(cdc_buf), &CopyCDCtoUARTStdio, CmdParserTable); #else (void)CLS1_ReadAndParseWithCommandTable(cdc_buf, sizeof(cdc_buf), &CDC_stdio, CmdParserTable); #endif #endif #if PL_CONFIG_HAS_BLUETOOTH (void)CLS1_ReadAndParseWithCommandTable(bluetooth_buf, sizeof(bluetooth_buf), &BT_stdio, CmdParserTable); #endif #if PL_CONFIG_HAS_SEGGER_RTT (void)CLS1_ReadAndParseWithCommandTable(rtt_buf, sizeof(rtt_buf), &RTT_Stdio, CmdParserTable); #endif #if PL_CONFIG_HAS_RADIO && RNET_CONFIG_REMOTE_STDIO RSTDIO_Print(ioLocal); /* dispatch incoming messages */ (void)CLS1_ReadAndParseWithCommandTable(radio_cmd_buf, sizeof(radio_cmd_buf), ioRemote, CmdParserTable); #endif #if PL_CONFIG_HAS_SHELL_QUEUE #if PL_CONFIG_HAS_SQUEUE_SINGLE_CHAR { /*! \todo Handle shell queue */ unsigned char ch; while((ch=SQUEUE_ReceiveChar()) && ch!='\0') { #if CLS1_DEFAULT_SERIAL ioLocal->stdOut(ch); #endif #if PL_CONFIG_HAS_BLUETOOTH BT_stdio.stdOut(ch); /* copy on Bluetooth */ #endif #if PL_CONFIG_HAS_USB_CDC CDC_stdio.stdOut(ch); /* copy on USB CDC */ #endif } } #else /* PL_CONFIG_HAS_SQUEUE_SINGLE_CHAR */ { const unsigned char *msg; msg = SQUEUE_ReceiveMessage(); if (msg!=NULL) { CLS1_SendStr(msg, CLS1_GetStdio()->stdOut); FRTOS1_vPortFree((void*)msg); } } #endif /* PL_CONFIG_HAS_SQUEUE_SINGLE_CHAR */ #endif /* PL_CONFIG_HAS_SHELL_QUEUE */ FRTOS1_vTaskDelay(10/portTICK_RATE_MS); } /* for */ }