updates from ADIS_HS2022

main
Jonas Arnold 4 years ago
parent b7bd98373f
commit 27cb9df55d
  1. 12
      ADIS_ESP32_Eclipse/config/IncludeMcuLibConfig.h
  2. 10
      ADIS_ESP32_Eclipse/main/robot.c
  3. 6
      ADIS_Sumo_Styger/Sumo/Maze.c
  4. 12
      ADIS_Sumo_Styger/source/IncludeMcuLibConfig.h
  5. 14
      ADIS_Sumo_Styger/source/Shell.c
  6. 6
      ADIS_Sumo_Styger/source/platform.c
  7. 10
      McuLib/src/McuShell.c

@ -15,12 +15,12 @@
#define configHEAP_SCHEME_IDENTIFICATION (0) /* ESP-IDF RTOS used */ #define configHEAP_SCHEME_IDENTIFICATION (0) /* ESP-IDF RTOS used */
/* -------------- McuShell settings -------------------------- */ /* -------------- McuShell settings -------------------------- */
#define McuShell_CONFIG_PROJECT_NAME_STRING "ESP32 Shell" #define McuShell_CONFIG_PROJECT_NAME_STRING "ESP32 Shell"
#define McuShell_CONFIG_ECHO_ENABLED (1) #define McuShell_CONFIG_ECHO_ENABLED (1)
#define McuShell_CONFIG_PROMPT_STRING "ESP32> " #define McuShell_CONFIG_PROMPT_STRING "ESP32> "
#define McuShell_CONFIG_MULTI_CMD_ENABLED (1) #define McuShell_CONFIG_MULTI_CMD_ENABLED (1)
#define McuShell_CONFIG_MULTI_CMD_SIZE (96) #define McuShell_CONFIG_MULTI_CMD_SIZE (96)
#define McuShell_CONFIG_DEFAULT_SHELL_BUFFER_SIZE (96)
/* -------------- McuCriticalSections settings -------------------------- */ /* -------------- McuCriticalSections settings -------------------------- */
#define McuCriticalSection_CONFIG_USE_RTOS_CRITICAL_SECTION (1) #define McuCriticalSection_CONFIG_USE_RTOS_CRITICAL_SECTION (1)

@ -44,10 +44,20 @@ uint8_t ROBOT_ParseCommand(const unsigned char* cmd, bool *handled, const McuShe
return ERR_OK; return ERR_OK;
} else if (McuUtility_strncmp((char*)cmd, (char*)"robo sendcmd ", sizeof("robo sendcmd ")-1)==0) { } else if (McuUtility_strncmp((char*)cmd, (char*)"robo sendcmd ", sizeof("robo sendcmd ")-1)==0) {
static uint8_t response[10*1024]; static uint8_t response[10*1024];
unsigned char buffer[McuShell_CONFIG_DEFAULT_SHELL_BUFFER_SIZE];
const unsigned char *p; const unsigned char *p;
*handled = TRUE; *handled = TRUE;
p = cmd+sizeof("robo sendcmd ")-1; p = cmd+sizeof("robo sendcmd ")-1;
while (*p==' ') { /* skip leading spaces */
p++;
}
if (*p=='"') { /* double-quoted command: it can contain multiple commands */
if (McuUtility_ScanDoubleQuotedString(&p, buffer, sizeof(buffer))!=ERR_OK) {
return ERR_FAILED;
}
p = buffer;
}
SHELL_SendToRobotAndGetResponse(p, response, sizeof(response)); SHELL_SendToRobotAndGetResponse(p, response, sizeof(response));
McuShell_SendStr(response, io->stdOut); /* show result on console */ McuShell_SendStr(response, io->stdOut); /* show result on console */
return ERR_OK; return ERR_OK;

@ -144,7 +144,13 @@ uint8_t MAZE_EvaluteTurn(bool *finished, bool *deadEndGoBw) {
*deadEndGoBw = FALSE; /* default */ *deadEndGoBw = FALSE; /* default */
currLineKind = REF_GetLineKind(REF_LINE_KIND_MODE_MAZE); currLineKind = REF_GetLineKind(REF_LINE_KIND_MODE_MAZE);
if (currLineKind==REF_LINE_NONE) { /* nothing, must be dead end */ if (currLineKind==REF_LINE_NONE) { /* nothing, must be dead end */
#if PL_GO_DEADEND_BW
TURN_Turn(TURN_STEP_LINE_BW, NULL); /* step back so we are again on the line for line following */
turn = TURN_STRAIGHT;
*deadEndGoBw = TRUE;
#else
turn = TURN_LEFT180; turn = TURN_LEFT180;
#endif
} else { } else {
HISTORY_Clear(); /* clear history values */ HISTORY_Clear(); /* clear history values */
HISTORY_SampleSensors(); /* store current values */ HISTORY_SampleSensors(); /* store current values */

@ -31,13 +31,6 @@
#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 */
@ -127,5 +120,10 @@
/* ---------------------------------------------------------------------------------------*/ /* ---------------------------------------------------------------------------------------*/
/* FXOS8700 accelerometer */ /* FXOS8700 accelerometer */
#define McuFXOS8700_CONFIG_I2C_DEVICE_ADDRESS (0x1D) #define McuFXOS8700_CONFIG_I2C_DEVICE_ADDRESS (0x1D)
/* ------------------- McuLog -----------------------*/
#define McuLog_CONFIG_IS_ENABLED (1)
#define McuLog_CONFIG_LOG_TIMESTAMP_DATE (0)
#define McuLog_CONFIG_LOG_TIMESTAMP_TIME (1)
#define McuLog_CONFIG_NOF_CONSOLE_LOGGER (2)
/* ---------------------------------------------------------------------------------------*/ /* ---------------------------------------------------------------------------------------*/

@ -54,6 +54,7 @@
#if PL_CONFIG_HAS_ACCEL #if PL_CONFIG_HAS_ACCEL
#include "McuFXOS8700.h" #include "McuFXOS8700.h"
#endif #endif
#include "McuLog.h"
static const McuShell_ParseCommandCallback CmdParserTable[] = static const McuShell_ParseCommandCallback CmdParserTable[] =
{ {
@ -111,6 +112,7 @@ static const McuShell_ParseCommandCallback CmdParserTable[] =
#if PL_CONFIG_HAS_ACCEL #if PL_CONFIG_HAS_ACCEL
McuFXOS8700_ParseCommand, McuFXOS8700_ParseCommand,
#endif #endif
McuLog_ParseCommand,
NULL /* Sentinel */ NULL /* Sentinel */
}; };
@ -193,7 +195,7 @@ static void ShellTask(void *pv) {
unsigned int i; unsigned int i;
(void)pv; /* not used */ (void)pv; /* not used */
McuShell_SendStr((uint8_t*)"Shell task started.\r\n", McuShell_GetStdio()->stdOut); McuLog_info("Shell task started.\r\n");
for(i=0;i<sizeof(ios)/sizeof(ios[0]);i++) { for(i=0;i<sizeof(ios)/sizeof(ios[0]);i++) {
ios[i].buf[0] = '\0'; ios[i].buf[0] = '\0';
} }
@ -222,6 +224,16 @@ void SHELL_Init(void) {
#if PL_CONFIG_USE_ESP32 #if PL_CONFIG_USE_ESP32
McuESP32_SetRxFromESPStdio(&ESP_ToShellStdio); /* copy ESP UART to shell console */ McuESP32_SetRxFromESPStdio(&ESP_ToShellStdio); /* copy ESP UART to shell console */
#endif #endif
#if McuLog_CONFIG_IS_ENABLED
#if PL_CONFIG_USE_RTT && PL_CONFIG_USE_UART_SHELL && McuLog_CONFIG_NOF_CONSOLE_LOGGER==2 /* both */
McuLog_set_console(McuRTT_GetStdio(), 0);
McuLog_set_console(&McuShellUart_stdio, 1);
#elif PL_CONFIG_USE_RTT /* only RTT */
McuLog_set_console(McuRTT_GetStdio(), 0);
#elif PL_CONFIG_USE_UART_SHELL /* only UART */
McuLog_set_console(&McuShellUart_stdio, 0);
#endif
#endif
} }
void SHELL_Deinit(void) {} void SHELL_Deinit(void) {}

@ -62,6 +62,10 @@
#if PL_CONFIG_HAS_ACCEL #if PL_CONFIG_HAS_ACCEL
#include "Accel.h" #include "Accel.h"
#endif #endif
#if PL_CONFIG_APP_LINE_MAZE
#include "maze.h"
#endif
#include "McuLog.h"
#if PL_CONFIG_HAS_NVM_CONFIG #if PL_CONFIG_HAS_NVM_CONFIG
static void InitNVMCValues(void) { static void InitNVMCValues(void) {
@ -145,7 +149,7 @@ void PL_Init(void) {
#endif #endif
TRG_Init(); TRG_Init();
TMR_Init(); TMR_Init();
McuLog_Init();
#if PL_CONFIG_USE_QUADRATURE #if PL_CONFIG_USE_QUADRATURE
QuadCounter_Init(); QuadCounter_Init();
#endif #endif

@ -630,7 +630,7 @@ bool McuShell_ReadLine(uint8_t *bufStart, uint8_t *buf, size_t bufSize, McuShell
*/ */
uint8_t McuShell_PrintStatus(McuShell_ConstStdIOType *io) uint8_t McuShell_PrintStatus(McuShell_ConstStdIOType *io)
{ {
unsigned char buf[16]; unsigned char buf[32];
McuShell_SendStatusStr((const unsigned char*)"McuShell", (const unsigned char*)"Commandline shell status\r\n", io->stdOut); McuShell_SendStatusStr((const unsigned char*)"McuShell", (const unsigned char*)"Commandline shell status\r\n", io->stdOut);
McuShell_SendStatusStr((const unsigned char*)" Build", (const unsigned char*)__DATE__, io->stdOut); McuShell_SendStatusStr((const unsigned char*)" Build", (const unsigned char*)__DATE__, io->stdOut);
@ -652,12 +652,18 @@ uint8_t McuShell_PrintStatus(McuShell_ConstStdIOType *io)
#if McuShell_CONFIG_MULTI_CMD_ENABLED #if McuShell_CONFIG_MULTI_CMD_ENABLED
McuUtility_strcpy(buf, sizeof(buf), (unsigned char*)"yes: '"); McuUtility_strcpy(buf, sizeof(buf), (unsigned char*)"yes: '");
McuUtility_chcat(buf, sizeof(buf), McuShell_CONFIG_MULTI_CMD_CHAR); McuUtility_chcat(buf, sizeof(buf), McuShell_CONFIG_MULTI_CMD_CHAR);
McuUtility_strcat(buf, sizeof(buf), (unsigned char*)"'\r\n"); McuUtility_strcat(buf, sizeof(buf), (unsigned char*)"', size: ");
McuUtility_strcatNum32u(buf, sizeof(buf), McuShell_CONFIG_MULTI_CMD_SIZE);
McuUtility_strcat(buf, sizeof(buf), (unsigned char*)"\r\n");
McuShell_SendStatusStr((const unsigned char*)" multiCmd", buf, io->stdOut); McuShell_SendStatusStr((const unsigned char*)" multiCmd", buf, io->stdOut);
#else #else
McuShell_SendStatusStr((const unsigned char*)" multiCmd", (unsigned char*)"no\r\n", io->stdOut); McuShell_SendStatusStr((const unsigned char*)" multiCmd", (unsigned char*)"no\r\n", io->stdOut);
#endif #endif
McuUtility_Num32uToStr(buf, sizeof(buf), McuShell_DEFAULT_SHELL_BUFFER_SIZE);
McuUtility_strcat(buf, sizeof(buf), (unsigned char*)" bytes default size\r\n");
McuShell_SendStatusStr((const unsigned char*)" size", buf, io->stdOut);
return ERR_OK; return ERR_OK;
} }

Loading…
Cancel
Save