diff --git a/ADIS_tinyK22_SplitFlap/source/application.c b/ADIS_tinyK22_SplitFlap/source/application.c index def81fa..9cbf1e5 100644 --- a/ADIS_tinyK22_SplitFlap/source/application.c +++ b/ADIS_tinyK22_SplitFlap/source/application.c @@ -23,6 +23,7 @@ #define LED_BLUE_PORT PORTC #define LED_BLUE_PIN 2U + /* vars */ static McuLED_Handle_t LED_blue; static SF_Handle_t splitflap0, splitflap1; @@ -70,7 +71,7 @@ static void App_Task(void* pv){ QueueHandle_t cmdQueueHandle = SHELL_GetShellCmdQueueHandle();; Shell_cmd_s cmd; - + char* sentence; while(1){ // if queue recieved something if(xQueueReceive(cmdQueueHandle, &cmd, pdMS_TO_TICKS(20)) == pdPASS){ @@ -83,7 +84,14 @@ static void App_Task(void* pv){ // params[0]=hwId, params[1]= setupId MultiSplitFlap_SetHardwareIdentifier(cmd.params[1], cmd.params[0]); break; - + case Shell_Display_String_SF: + sentence = (char*)calloc(cmd.numberOfParams,sizeof(char)); + SHELL_Int32ArrayToStringForSF(cmd.params, cmd.numberOfParams, sentence); + McuLog_info("Sentence parsed"); + MultiSplitFlap_Display(sentence); + free(sentence); + vTaskDelay(pdMS_TO_TICKS(2000)); + break; case Shell_Powerof_rpi: default: McuLog_error("Not implemented command recieved in App_Task. Command Id was <%i>", (int)cmd.shellCmd); diff --git a/ADIS_tinyK22_SplitFlap/source/shell.c b/ADIS_tinyK22_SplitFlap/source/shell.c index d7de06a..ef66323 100644 --- a/ADIS_tinyK22_SplitFlap/source/shell.c +++ b/ADIS_tinyK22_SplitFlap/source/shell.c @@ -66,12 +66,15 @@ static uint8_t ParseCommand(const uint8_t *cmd, bool *handled, McuShell_ConstStd vQueueShellCmd(shellCmd); } else if(McuUtility_strcmp((char*)cmd,SHELL_CMD_POWEROFF_RPI) == 0){ // shutown rpi + *handled = TRUE; Shell_cmd_s shellCmd = {.shellCmd = Shell_Powerof_rpi, .numberOfParams = 0}; vQueueShellCmd(shellCmd); }else if(McuUtility_strcmp((char*)cmd, SHELL_CMD_INIT_ALL_SF) == 0){ + *handled = TRUE; 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){ + *handled = TRUE; 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){ @@ -95,9 +98,13 @@ uint8_t SHELL_stringToInt32ArrayForSFCMD(const unsigned char **str, int32_t* res // its a number *res = (int32_t)c; res++; - }else if(c >= 'A' && c <= 'Z'){ + }else if((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')){ // its a char - *res = (int32_t)c; + if(c >= 'a' && c <= 'z'){ + *res = (int32_t)c-0x20; + }else{ + *res = (int32_t)c; + } res++; } else if(c == '!' || c == '?' || c == ':' || c == ' '){ // special character allowed by SF @@ -109,7 +116,14 @@ uint8_t SHELL_stringToInt32ArrayForSFCMD(const unsigned char **str, int32_t* res c = *(++(*str)); } return ERR_OK; +} +uint8_t SHELL_Int32ArrayToStringForSF(int32_t* intArray, int8_t size, char *str){ + for(uint8_t i = 0; i < size; i++){ + *str = (char)intArray[i]; + str++; + } + return ERR_OK; } static const McuShell_ParseCommandCallback CmdParserTable[] = diff --git a/ADIS_tinyK22_SplitFlap/source/shell.h b/ADIS_tinyK22_SplitFlap/source/shell.h index 110f540..6b777e4 100644 --- a/ADIS_tinyK22_SplitFlap/source/shell.h +++ b/ADIS_tinyK22_SplitFlap/source/shell.h @@ -41,7 +41,21 @@ extern "C" { QueueHandle_t SHELL_GetShellCmdQueueHandle(); +/*! + * \brief Converts a string to a integer array for sending with the cmd queue + * \param str String to convert + * \param res Array pointer to store the values + * \param size of the string / array + */ uint8_t SHELL_stringToInt32ArrayForSFCMD(const unsigned char **str, int32_t* res, int8_t sizeRes); + +/*! + * \brief Converts a int array to a string + * \param intArray array to convert + * \param size the size of the array + * \param str to store string + */ +uint8_t SHELL_Int32ArrayToStringForSF(int32_t* intArray, int8_t size, char *str); /*! * \brief Send a string to all supported I/Os * \param str String to send