add Command to display a string on the splitflaps

main
Simon Frei 4 years ago
parent 0b9952e40f
commit 02d75d1e9e
  1. 2
      ADIS_tinyK22_SplitFlap/.cproject
  2. 38
      ADIS_tinyK22_SplitFlap/source/shell.c
  3. 7
      ADIS_tinyK22_SplitFlap/source/shell.h

@ -765,7 +765,7 @@
<storageModule moduleId="com.nxp.mcuxpresso.core.datamodels">
<sdkName>SDK_2.x_MK22FN512xxx12</sdkName>
<sdkVersion>2.12.0</sdkVersion>
<sdkComponents>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;</sdkComponents>
<sdkComponents>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;</sdkComponents>
<package>MK22FN512VLH12</package>
<core>cm4</core>
<coreId>core0_MK22FN512xxx12</coreId>

@ -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,6 +71,42 @@ 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;

@ -9,10 +9,13 @@
#include "McuShell.h"
#include "McuRTOS.h"
#include <stdint.h>
#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

Loading…
Cancel
Save