|
|
|
@ -12,13 +12,13 @@ |
|
|
|
#include "McuShellUart.h" |
|
|
|
#include "McuShellUart.h" |
|
|
|
#include "McuLog.h" |
|
|
|
#include "McuLog.h" |
|
|
|
#include "McuUtility.h" |
|
|
|
#include "McuUtility.h" |
|
|
|
|
|
|
|
#include "MotOffsetTable.h" |
|
|
|
|
|
|
|
#include "multi-splitflap.h" |
|
|
|
|
|
|
|
|
|
|
|
#define SHELL_CMD_ELEM_SIZE (sizeof(Shell_cmd_s)) |
|
|
|
#define SHELL_CMD_ELEM_SIZE (sizeof(Shell_cmd_s)) |
|
|
|
|
|
|
|
|
|
|
|
static QueueHandle_t shellCmdQueue; |
|
|
|
static QueueHandle_t shellCmdQueue; |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t splitFlapId = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void vQueueShellCmd(Shell_cmd_s shellCmd){ |
|
|
|
static void vQueueShellCmd(Shell_cmd_s shellCmd){ |
|
|
|
if(xQueueSendToBack(shellCmdQueue, &shellCmd, pdMS_TO_TICKS(100)) != pdPASS){ |
|
|
|
if(xQueueSendToBack(shellCmdQueue, &shellCmd, pdMS_TO_TICKS(100)) != pdPASS){ |
|
|
|
McuLog_warn("Failed adding shell cmd to queue, maybe full?"); |
|
|
|
McuLog_warn("Failed adding shell cmd to queue, maybe full?"); |
|
|
|
@ -26,31 +26,49 @@ static void vQueueShellCmd(Shell_cmd_s shellCmd){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t ParseCommand(const uint8_t *cmd, bool *handled, McuShell_ConstStdIOType *io){ |
|
|
|
static uint8_t ParseCommand(const uint8_t *cmd, bool *handled, McuShell_ConstStdIOType *io){ |
|
|
|
uint8_t size = sizeof(SHELL_CMD_IDENTIFY_SF)-1; |
|
|
|
|
|
|
|
if (McuUtility_strcmp((char*)cmd, McuShell_CMD_HELP)==0) { |
|
|
|
if (McuUtility_strcmp((char*)cmd, McuShell_CMD_HELP)==0) { |
|
|
|
McuShell_SendStr((unsigned char*)"\r\n", io->stdOut); |
|
|
|
McuShell_SendStr((unsigned char*)"\r\n", io->stdOut); |
|
|
|
McuShell_SendStr((unsigned char*)McuShell_DASH_LINE, io->stdOut); |
|
|
|
McuShell_SendStr((unsigned char*)McuShell_DASH_LINE, io->stdOut); |
|
|
|
McuShell_SendStr((unsigned char*)"\r\n", io->stdOut); |
|
|
|
McuShell_SendStr((unsigned char*)"\r\n", io->stdOut); |
|
|
|
McuShell_SendHelpStr((unsigned char*)"SplitFlap Help", (const unsigned char*)"Group of SplitFlap commands\r\n", io->stdOut); |
|
|
|
McuShell_SendHelpStr((unsigned char*)"SplitFlap Help", (const unsigned char*)"Group of SplitFlap commands\r\n", io->stdOut); |
|
|
|
McuShell_SendHelpStr((unsigned char*)" help", (const unsigned char*)"Print help this message\r\n", io->stdOut); |
|
|
|
McuShell_SendHelpStr((unsigned char*)" help", (const unsigned char*)"Print help this message\r\n", io->stdOut); |
|
|
|
McuShell_SendHelpStr((unsigned char*)SHELL_CMD_IDENTIFY_SF, (const unsigned char*)"<SplitFlapId> (uint8_t)\r\n", io->stdOut); |
|
|
|
McuShell_SendHelpStr((unsigned char*)SHELL_CMD_IDENTIFY_SF, (const unsigned char*)"<SetupIdentifier> <HardwareIdentifier> (uint8_t) (uint8_t)\r\n", io->stdOut); |
|
|
|
McuShell_SendHelpStr((unsigned char*)" ", (const unsigned char*)"the number printed on the splitflap\r\n", io->stdOut); |
|
|
|
|
|
|
|
McuShell_SendHelpStr((unsigned char*)" ", (const unsigned char*)"Splitflap Number:16\r\n", io->stdOut); |
|
|
|
|
|
|
|
McuShell_SendHelpStr((unsigned char*)SHELL_CMD_POWEROFF_RPI, (const unsigned char*)"power of the raspberry pi\r\n", io->stdOut); |
|
|
|
McuShell_SendHelpStr((unsigned char*)SHELL_CMD_POWEROFF_RPI, (const unsigned char*)"power of the raspberry pi\r\n", io->stdOut); |
|
|
|
|
|
|
|
McuShell_SendHelpStr((unsigned char*)SHELL_CMD_INIT_ALL_SF, (const unsigned char*)"init all Splitflaps\r\n", io->stdOut); |
|
|
|
*handled = TRUE; |
|
|
|
*handled = TRUE; |
|
|
|
return ERR_OK; |
|
|
|
return ERR_OK; |
|
|
|
} else if(McuUtility_strncmp((char*)cmd, SHELL_CMD_IDENTIFY_SF, size) == 0){ |
|
|
|
} else if(McuUtility_strncmp((char*)cmd, SHELL_CMD_IDENTIFY_SF, sizeof(SHELL_CMD_IDENTIFY_SF)-1) == 0){ |
|
|
|
|
|
|
|
int32_t hwId = 0; |
|
|
|
|
|
|
|
int32_t setupId = 0; |
|
|
|
*handled = TRUE; |
|
|
|
*handled = TRUE; |
|
|
|
cmd += sizeof(SHELL_CMD_IDENTIFY_SF)-1; |
|
|
|
cmd += sizeof(SHELL_CMD_IDENTIFY_SF)-1; |
|
|
|
if(McuUtility_ScanDecimal8uNumber(&cmd, &splitFlapId) != ERR_OK){ |
|
|
|
if(McuUtility_xatoi(&cmd, &setupId) == ERR_OK){ |
|
|
|
// Do not save id
|
|
|
|
// validate param
|
|
|
|
|
|
|
|
if(setupId > NUM_FLAPS){ |
|
|
|
|
|
|
|
return ERR_FAILED; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return ERR_FAILED; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// second param
|
|
|
|
|
|
|
|
cmd++; |
|
|
|
|
|
|
|
if(McuUtility_xatoi(&cmd, &hwId) == ERR_OK){ |
|
|
|
|
|
|
|
// validate param
|
|
|
|
|
|
|
|
if(MotOffset_Get(hwId, NULL) != ERR_OK){ |
|
|
|
return ERR_FAILED; |
|
|
|
return ERR_FAILED; |
|
|
|
} |
|
|
|
} |
|
|
|
Shell_cmd_s shellCmd = {.shellCmd = Shell_Identify_SF, .value = (uint32_t)splitFlapId}; |
|
|
|
}else{ |
|
|
|
|
|
|
|
return ERR_FAILED; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Shell_cmd_s shellCmd = {.shellCmd = Shell_Identify_SF, .numberOfParams = 2, .params = {hwId,setupId}}; |
|
|
|
|
|
|
|
//Shell_cmd_s shellCmd = {.shellCmd = Shell_Identify_SF, .value1 = setupId, .value2 = hwId};
|
|
|
|
vQueueShellCmd(shellCmd); |
|
|
|
vQueueShellCmd(shellCmd); |
|
|
|
} else if(McuUtility_strcmp((char*)cmd,SHELL_CMD_POWEROFF_RPI) == 0){ |
|
|
|
} else if(McuUtility_strcmp((char*)cmd,SHELL_CMD_POWEROFF_RPI) == 0){ |
|
|
|
// shutown rpi
|
|
|
|
// shutown rpi
|
|
|
|
Shell_cmd_s shellCmd = {.shellCmd = Shell_Powerof_rpi, .value = 0}; |
|
|
|
Shell_cmd_s shellCmd = {.shellCmd = Shell_Powerof_rpi, .numberOfParams = 0}; |
|
|
|
|
|
|
|
vQueueShellCmd(shellCmd); |
|
|
|
|
|
|
|
}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); |
|
|
|
vQueueShellCmd(shellCmd); |
|
|
|
} |
|
|
|
} |
|
|
|
return ERR_OK; |
|
|
|
return ERR_OK; |
|
|
|
|