fixed issues in splitflap_wrapper, added printing response

main
Jonas Arnold 4 years ago
parent eaf85084d8
commit dc1c6c0a6c
  1. 15
      ADIS_ESP32_Eclipse/main/splitflap_wrapper.c

@ -10,8 +10,9 @@
#include "splitflap_wrapper.h" #include "splitflap_wrapper.h"
#include "McuUtility.h" #include "McuUtility.h"
#include "McuShell.h" #include "McuShell.h"
#include "Shell.h"
#define RS_CMD_PREFIX "rs sendcmd SplitFlap " #define RS_CMD_PREFIX "rs sendcmd 0x01 SplitFlap "
#define BUF_SIZE 50 #define BUF_SIZE 50
@ -20,8 +21,10 @@
* If all splitflaps report to be initialized before the timeout, the return value is true */ * If all splitflaps report to be initialized before the timeout, the return value is true */
bool SplitFlap_Wrapper_MoveAllToZeroPosition(void){ bool SplitFlap_Wrapper_MoveAllToZeroPosition(void){
unsigned char cmd[BUF_SIZE] = RS_CMD_PREFIX; unsigned char cmd[BUF_SIZE] = RS_CMD_PREFIX;
unsigned char response[128];
McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)"initAll"); McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)"initAll");
McuShell_SendStr(cmd, McuShell_GetStdio()->stdOut); SHELL_SendToESPAndGetResponse(cmd, response, sizeof(response));
McuShell_SendStr(response, McuShell_GetStdio()->stdOut);
return true; return true;
} }
@ -30,9 +33,11 @@ bool SplitFlap_Wrapper_MoveAllToZeroPosition(void){
* returns true when all movements finished */ * returns true when all movements finished */
bool SplitFlap_Wrapper_Display(unsigned char *sentence){ bool SplitFlap_Wrapper_Display(unsigned char *sentence){
unsigned char cmd[BUF_SIZE] = RS_CMD_PREFIX; unsigned char cmd[BUF_SIZE] = RS_CMD_PREFIX;
unsigned char response[128];
McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)"Display "); McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)"Display ");
McuUtility_strcat(cmd, sizeof(cmd), sentence); McuUtility_strcat(cmd, sizeof(cmd), sentence);
McuShell_SendStr(cmd, McuShell_GetStdio()->stdOut); SHELL_SendToESPAndGetResponse(cmd, response, sizeof(response));
McuShell_SendStr(response, McuShell_GetStdio()->stdOut);
return true; return true;
} }
@ -40,6 +45,7 @@ bool SplitFlap_Wrapper_Display(unsigned char *sentence){
* returns true when successful, false when not (e.g. split flap with given id not available) */ * returns true when successful, false when not (e.g. split flap with given id not available) */
bool SplitFlap_Wrapper_SetHardwareIdentifier(uint8_t id, uint8_t hwId){ bool SplitFlap_Wrapper_SetHardwareIdentifier(uint8_t id, uint8_t hwId){
unsigned char cmd[BUF_SIZE] = RS_CMD_PREFIX; unsigned char cmd[BUF_SIZE] = RS_CMD_PREFIX;
unsigned char response[128];
unsigned char setupId_str[4] = {0}; unsigned char hardwareId_str[4] = {0}; unsigned char setupId_str[4] = {0}; unsigned char hardwareId_str[4] = {0};
McuUtility_Num8uToStr(setupId_str, sizeof(setupId_str), id); McuUtility_Num8uToStr(setupId_str, sizeof(setupId_str), id);
McuUtility_Num8uToStr(hardwareId_str, sizeof(hardwareId_str), hwId); McuUtility_Num8uToStr(hardwareId_str, sizeof(hardwareId_str), hwId);
@ -47,6 +53,7 @@ bool SplitFlap_Wrapper_SetHardwareIdentifier(uint8_t id, uint8_t hwId){
McuUtility_strcat(cmd, sizeof(cmd), setupId_str); McuUtility_strcat(cmd, sizeof(cmd), setupId_str);
McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)" "); McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)" ");
McuUtility_strcat(cmd, sizeof(cmd), hardwareId_str); McuUtility_strcat(cmd, sizeof(cmd), hardwareId_str);
McuShell_SendStr(cmd, McuShell_GetStdio()->stdOut); SHELL_SendToESPAndGetResponse(cmd, response, sizeof(response));
McuShell_SendStr(response, McuShell_GetStdio()->stdOut);
return true; return true;
} }

Loading…
Cancel
Save