diff --git a/ADIS_tinyK22_SplitFlap/.cproject b/ADIS_tinyK22_SplitFlap/.cproject index c60089f..fed5235 100644 --- a/ADIS_tinyK22_SplitFlap/.cproject +++ b/ADIS_tinyK22_SplitFlap/.cproject @@ -765,7 +765,7 @@ SDK_2.x_MK22FN512xxx12 2.12.0 - platform.drivers.smc.MK22F51212;platform.drivers.port.MK22F51212;platform.drivers.dspi.MK22F51212;platform.drivers.adc16.MK22F51212;platform.drivers.uart.MK22F51212;platform.drivers.clock.MK22F51212;platform.drivers.rtc.MK22F51212;platform.drivers.common.MK22F51212;platform.drivers.i2c.MK22F51212;platform.drivers.gpio.MK22F51212;device.MK22F51212_system.MK22F51212;device.MK22F51212_CMSIS.MK22F51212;CMSIS_Include_core_cm.MK22F51212;platform.utilities.assert.MK22F51212;component.serial_manager_uart.MK22F51212;utility.debug_console.MK22F51212;component.serial_manager.MK22F51212;component.uart_adapter.MK22F51212;component.lists.MK22F51212;project_template.MK22F51212.MK22F51212;device.MK22F51212_startup.MK22F51212;platform.drivers.sim.MK22F51212;middleware.freertos-kernel.MK22F51212;platform.drivers.lpuart.MK22F51212; + middleware.baremetal.MK22F51212;platform.drivers.smc.MK22F51212;platform.drivers.port.MK22F51212;platform.drivers.dspi.MK22F51212;platform.drivers.adc16.MK22F51212;platform.drivers.uart.MK22F51212;platform.drivers.clock.MK22F51212;platform.drivers.rtc.MK22F51212;platform.drivers.common.MK22F51212;platform.drivers.i2c.MK22F51212;platform.drivers.gpio.MK22F51212;device.MK22F51212_system.MK22F51212;device.MK22F51212_CMSIS.MK22F51212;CMSIS_Include_core_cm.MK22F51212;platform.utilities.assert.MK22F51212;component.serial_manager_uart.MK22F51212;utility.debug_console.MK22F51212;component.serial_manager.MK22F51212;component.uart_adapter.MK22F51212;component.lists.MK22F51212;project_template.MK22F51212.MK22F51212;device.MK22F51212_startup.MK22F51212;platform.drivers.sim.MK22F51212; MK22FN512VLH12 cm4 core0_MK22FN512xxx12 diff --git a/ADIS_tinyK22_SplitFlap/source/shell.c b/ADIS_tinyK22_SplitFlap/source/shell.c index 03119d6..d7de06a 100644 --- a/ADIS_tinyK22_SplitFlap/source/shell.c +++ b/ADIS_tinyK22_SplitFlap/source/shell.c @@ -13,7 +13,7 @@ #include "McuLog.h" #include "McuUtility.h" #include "MotOffsetTable.h" -#include "multi-splitflap.h" + #define SHELL_CMD_ELEM_SIZE (sizeof(Shell_cmd_s)) @@ -71,11 +71,47 @@ static uint8_t ParseCommand(const uint8_t *cmd, bool *handled, McuShell_ConstStd }else if(McuUtility_strcmp((char*)cmd, SHELL_CMD_INIT_ALL_SF) == 0){ Shell_cmd_s shellCmd = {.shellCmd = Shell_Init_All_SF, .numberOfParams = 0}; vQueueShellCmd(shellCmd); + }else if(McuUtility_strncmp((char*)cmd,SHELL_CMD_DISPLAY_STRING,sizeof(SHELL_CMD_DISPLAY_STRING)-1) == 0){ + Shell_cmd_s shellCmd = {.shellCmd = Shell_Display_String_SF, .numberOfParams = NUM_FLAPS, .params = {0}}; + cmd += sizeof(SHELL_CMD_DISPLAY_STRING)-1; + if(SHELL_stringToInt32ArrayForSFCMD(&cmd, shellCmd.params, NUM_FLAPS) != ERR_OK){ + return ERR_FAILED; + } + vQueueShellCmd(shellCmd); } return ERR_OK; } +uint8_t SHELL_stringToInt32ArrayForSFCMD(const unsigned char **str, int32_t* res, int8_t sizeRes){ + uint8_t c = 0; + while(**str == ' '){ + (*str)++; // skip leading spaces + } + c = **str; + while(c != '\0' && sizeRes>0){ + sizeRes--; + if(c <= '9' && c >= '0'){ + // its a number + *res = (int32_t)c; + res++; + }else if(c >= 'A' && c <= 'Z'){ + // its a char + *res = (int32_t)c; + res++; + } else if(c == '!' || c == '?' || c == ':' || c == ' '){ + // special character allowed by SF + *res = (int32_t)c; + res++; + } else{ + return ERR_FAILED; + } + c = *(++(*str)); + } + return ERR_OK; + +} + static const McuShell_ParseCommandCallback CmdParserTable[] = { ParseCommand, diff --git a/ADIS_tinyK22_SplitFlap/source/shell.h b/ADIS_tinyK22_SplitFlap/source/shell.h index 168244b..110f540 100644 --- a/ADIS_tinyK22_SplitFlap/source/shell.h +++ b/ADIS_tinyK22_SplitFlap/source/shell.h @@ -9,10 +9,13 @@ #include "McuShell.h" #include "McuRTOS.h" +#include +#include "multi-splitflap.h" #define SHELL_CMD_IDENTIFY_SF "Splitflap Number:" #define SHELL_CMD_POWEROFF_RPI "Shutdown RPI" #define SHELL_CMD_INIT_ALL_SF "Init All SplitFlaps" +#define SHELL_CMD_DISPLAY_STRING "Display String:" #define SHELL_CMD_QUEUE_LENGTH 5 @@ -20,13 +23,14 @@ typedef enum ShellCmd { Shell_Identify_SF, Shell_Init_All_SF, + Shell_Display_String_SF, Shell_Powerof_rpi }Shell_cmd_t; typedef struct ShellCmd_s { Shell_cmd_t shellCmd; int32_t numberOfParams; - int32_t params[4]; + int32_t params[NUM_FLAPS]; }Shell_cmd_s; @@ -37,6 +41,7 @@ extern "C" { QueueHandle_t SHELL_GetShellCmdQueueHandle(); +uint8_t SHELL_stringToInt32ArrayForSFCMD(const unsigned char **str, int32_t* res, int8_t sizeRes); /*! * \brief Send a string to all supported I/Os * \param str String to send