add error message when command failed due to validation from parser

main
Simon Frei 4 years ago
parent e204adf6eb
commit 618184d283
  1. 4
      ADIS_tinyK22_SplitFlap/source/shell.c
  2. 29
      ADIS_tinyK22_SplitFlap/source/splitflap.c

@ -52,9 +52,11 @@ 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 ERR_FAILED; return ERR_FAILED;
} }
}else{ }else{
McuLog_error("failed to parse setupId");
return ERR_FAILED; return ERR_FAILED;
} }
// second param // second param
@ -63,9 +65,11 @@ 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 ERR_FAILED; return ERR_FAILED;
} }
}else{ }else{
McuLog_error("failed to parse hwId");
return ERR_FAILED; 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}};

@ -151,16 +151,27 @@ bool SF_MoveMotorToZeroPosition(SF_Handle_t instance){
} }
// turn until sensor is on and not reached one full rotation already (timeout) // turn until sensor is on and not reached one full rotation already (timeout)
while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == false && numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND ){ // while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == false && numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND ){
McuULN2003_IncStep(((SF_t*)instance)->motor); // McuULN2003_IncStep(((SF_t*)instance)->motor);
#ifdef McuLib_CONFIG_SDK_USE_FREERTOS //#ifdef McuLib_CONFIG_SDK_USE_FREERTOS
vTaskDelay(pdMS_TO_TICKS(20)); // vTaskDelay(pdMS_TO_TICKS(20));
#else //#else
McuWait_Waitms(20); // McuWait_Waitms(20);
#endif //#endif
numStepsMoved++; // numStepsMoved++;
// }
McuULN2003_AccelerationStart(((SF_t*)instance)->motor);
while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == false && numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND){
if(McuULN2003_StepCallback(((SF_t*)instance)->motor, true)){
numStepsMoved++;
}
#ifdef McuLib_CONFIG_SDK_USE_FREERTOS
vTaskDelay(pdMS_TO_TICKS(20));
#else
McuWait_Waitms(20);
#endif
} }
McuULN2003_AccelerationEnd(((SF_t*)instance)->motor);
// offset after init // offset after init
if(numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND){ if(numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND){
for(int i=0; i < offsetSteps; i++){ for(int i=0; i < offsetSteps; i++){

Loading…
Cancel
Save