receive cmd from esp, parsing no working yet

main
Simon Frei 4 years ago
parent 51a85c441d
commit 465278bde9
  1. 33
      ADIS_Sumo_Styger/Sumo/Remote.c
  2. 7
      ADIS_Sumo_Styger/source/IncludeMcuLibConfig.h

@ -12,6 +12,7 @@
#include "Shell.h" #include "Shell.h"
#include "Buzzer.h" #include "Buzzer.h"
#include "McuESP32.h" #include "McuESP32.h"
#include "McuLog.h"
/*! \todo ADIS: This is a (mostly empty) template where the remote commands from the ESP32 could be handled. This module should be extended to send data back to the ESP32 */ /*! \todo ADIS: This is a (mostly empty) template where the remote commands from the ESP32 could be handled. This module should be extended to send data back to the ESP32 */
@ -30,7 +31,11 @@ void REMOTE_GatewayRxFromESP(unsigned char ch) {
static void RemoteTask(void *pv) { static void RemoteTask(void *pv) {
unsigned char ch; unsigned char ch;
BaseType_t res; BaseType_t res;
unsigned char espMsg[McuShell_DEFAULT_SHELL_BUFFER_SIZE] = "";
const char espMsgPrefix[] = "@robot:cmd ";
const char espMsgPostfix[] = "!\r\n";
uint8_t saveChar = 0;
uint8_t writeIndex = 0;
(void)pv; /* not used */ (void)pv; /* not used */
#if 0 /* example making a beep */ #if 0 /* example making a beep */
BUZ_Beep(200, 500); BUZ_Beep(200, 500);
@ -55,13 +60,39 @@ static void RemoteTask(void *pv) {
res = xQueueReceive(REMOTE_RxFromESP_Queue, &ch, pdMS_TO_TICKS(10)); /* wait max 10 ms */ res = xQueueReceive(REMOTE_RxFromESP_Queue, &ch, pdMS_TO_TICKS(10)); /* wait max 10 ms */
if (res==errQUEUE_EMPTY) { if (res==errQUEUE_EMPTY) {
ch = '\0'; /* nothing received */ ch = '\0'; /* nothing received */
} }
else if(res == pdPASS) { else if(res == pdPASS) {
/* something was received */ /* something was received */
/* handle remote stream from ESP */ /* handle remote stream from ESP */
// uint8_t mCh = (uint8_t)ch;
// uint8_t mCh[10] = "Char: ";
// unsigned char newLine = '\n';
// McuUtility_strcat(mCh, 10, &ch);
// McuUtility_strcat(mCh, 10, &newLine);
// McuShell_SendStr(mCh, McuShell_GetStdio()->stdOut);
if(ch == '@'){ if(ch == '@'){
saveChar = 1;
writeIndex = 0;
BUZ_Beep(200, 500); BUZ_Beep(200, 500);
} }
if(saveChar == 1){
espMsg[writeIndex++] = ch;
}
if(ch == '!' && saveChar == 1){
saveChar = 0;
McuShell_SendStr(espMsg, McuShell_GetStdio()->stdOut);
McuShell_SendStr((uint8_t*)" okok.\r\n", McuShell_GetStdio()->stdOut);
if (McuUtility_strncmp(espMsg, espMsgPrefix, sizeof(espMsgPrefix)-1)==0) { /* check prefix */
unsigned char recCmd[32] = {0};
memmove(recCmd,espMsg[11],writeIndex);
McuShell_SendStr(recCmd, McuShell_GetStdio()->stdOut);
}
}else if(writeIndex == McuShell_DEFAULT_SHELL_BUFFER_SIZE && saveChar == 1){
saveChar = 0;
McuShell_SendStr(espMsg, McuShell_GetStdio()->stdOut);
McuShell_SendStr((uint8_t*)" Error in cmd.\r\n", McuShell_GetStdio()->stdOut);
}
} }
} }
} }

@ -31,6 +31,13 @@
#define McuShell_CONFIG_MULTI_CMD_SIZE (96) /* maximum size of a single command in a multi-command string */ #define McuShell_CONFIG_MULTI_CMD_SIZE (96) /* maximum size of a single command in a multi-command string */
#define McuShell_CONFIG_PROMPT_STRING "ROBO> " #define McuShell_CONFIG_PROMPT_STRING "ROBO> "
#define McuShell_CONFIG_ECHO_ENABLED (1) #define McuShell_CONFIG_ECHO_ENABLED (1)
/* Mcu log */
#define McuLog_CONFIG_IS_ENABLED (1)
#define McuLog_CONFIG_USE_RTT_CONSOLE (1)
#define McuLog_CONFIG_LOG_TIMESTAMP_DATE (0) // disable since time is not used
#define McuLog_CONFIG_LOG_TIMESTAMP_TIME (0)
/* ---------------------------------------------------------------------------------------*/ /* ---------------------------------------------------------------------------------------*/
/* I2C and OLED */ /* I2C and OLED */
//#define CONFIG_I2C_USE_PORT_B (1) /* tinyK22: PTB0, PTB1 */ //#define CONFIG_I2C_USE_PORT_B (1) /* tinyK22: PTB0, PTB1 */

Loading…
Cancel
Save