@ -30,6 +30,16 @@ static uint8_t PrintHelp(const McuShell_StdIOType *io) {
McuShell_SendHelpStr ( ( unsigned char * ) " Display <string> " , ( const unsigned char * ) " displays as many chars of the string as sf are available \r \n " , io - > stdOut ) ;
McuShell_SendHelpStr ( ( unsigned char * ) " Display <string> " , ( const unsigned char * ) " displays as many chars of the string as sf are available \r \n " , io - > stdOut ) ;
return ERR_OK ;
return ERR_OK ;
}
}
static uint8_t PrintError ( const uint8_t * cmd , const uint8_t * msg , const McuShell_StdIOType * io ) {
McuShell_SendStr ( ( unsigned char * ) " *** Failed command: " , io - > stdErr ) ;
McuShell_SendStr ( cmd , io - > stdErr ) ;
McuShell_SendStr ( ( unsigned char * ) " \r \n " , io - > stdErr ) ;
McuShell_SendStr ( ( unsigned char * ) " *** Message: " , io - > stdErr ) ;
McuShell_SendStr ( msg , io - > stdErr ) ;
McuShell_SendStr ( ( unsigned char * ) " \r \n " , io - > stdErr ) ;
return ERR_FAILED ;
}
# endif
# endif
static QueueHandle_t shellCmdQueue ;
static QueueHandle_t shellCmdQueue ;
@ -41,6 +51,7 @@ 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 ) {
const uint8_t * cmdCpy = cmd ;
if ( McuUtility_strcmp ( ( char * ) cmd , McuShell_CMD_HELP ) = = 0 | | McuUtility_strcmp ( ( char * ) cmd , " SplitFlap help " ) = = 0 ) {
if ( McuUtility_strcmp ( ( char * ) cmd , McuShell_CMD_HELP ) = = 0 | | McuUtility_strcmp ( ( char * ) cmd , " SplitFlap help " ) = = 0 ) {
* handled = TRUE ;
* handled = TRUE ;
return PrintHelp ( io ) ;
return PrintHelp ( io ) ;
@ -52,12 +63,10 @@ static uint8_t ParseCommand(const uint8_t *cmd, bool *handled, McuShell_ConstStd
if ( McuUtility_xatoi ( & cmd , & setupId ) = = ERR_OK ) {
if ( McuUtility_xatoi ( & cmd , & setupId ) = = ERR_OK ) {
// validate param
// validate param
if ( setupId > NUM_MAX_AMOUNT_FLAPS ) {
if ( setupId > NUM_MAX_AMOUNT_FLAPS ) {
McuLog_error ( " setupId cannot exists " ) ;
return PrintError ( cmdCpy , ( const uint8_t * ) " setupId cannot exist " , io ) ;
return ERR_FAILED ;
}
}
} else {
} else {
McuLog_error ( " failed to parse setupId " ) ;
return PrintError ( cmdCpy , ( const uint8_t * ) " failed to parse setupId " , io ) ;
return ERR_FAILED ;
}
}
// second param
// second param
cmd + + ;
cmd + + ;
@ -65,12 +74,10 @@ static uint8_t ParseCommand(const uint8_t *cmd, bool *handled, McuShell_ConstStd
// validate param
// validate param
int32_t offset = 0 ;
int32_t offset = 0 ;
if ( MotOffset_Get ( hwId , & offset ) ! = ERR_OK ) {
if ( MotOffset_Get ( hwId , & offset ) ! = ERR_OK ) {
McuLog_error ( " Splitflap with id %i does not exists " , hwId ) ;
return PrintError ( cmdCpy , ( const uint8_t * ) " Splitflap with this id does not exist " , io ) ;
return ERR_FAILED ;
}
}
} else {
} else {
McuLog_error ( " failed to parse hwId " ) ;
return PrintError ( cmdCpy , ( const uint8_t * ) " failed to parse hwId " , io ) ;
return ERR_FAILED ;
}
}
Shell_cmd_s shellCmd = { . shellCmd = Shell_Identify_SF , . numberOfParams = 2 , . params = { hwId , setupId } } ;
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};
//Shell_cmd_s shellCmd = {.shellCmd = Shell_Identify_SF, .value1 = setupId, .value2 = hwId};