From dc1c6c0a6ce0fb4970d7e56efbb42a994f208e46 Mon Sep 17 00:00:00 2001 From: Jonas Arnold Date: Fri, 9 Dec 2022 10:38:18 +0100 Subject: [PATCH] fixed issues in splitflap_wrapper, added printing response --- ADIS_ESP32_Eclipse/main/splitflap_wrapper.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ADIS_ESP32_Eclipse/main/splitflap_wrapper.c b/ADIS_ESP32_Eclipse/main/splitflap_wrapper.c index d9bd838..33fa1ed 100644 --- a/ADIS_ESP32_Eclipse/main/splitflap_wrapper.c +++ b/ADIS_ESP32_Eclipse/main/splitflap_wrapper.c @@ -10,8 +10,9 @@ #include "splitflap_wrapper.h" #include "McuUtility.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 @@ -20,8 +21,10 @@ * If all splitflaps report to be initialized before the timeout, the return value is true */ bool SplitFlap_Wrapper_MoveAllToZeroPosition(void){ unsigned char cmd[BUF_SIZE] = RS_CMD_PREFIX; + unsigned char response[128]; 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; } @@ -30,9 +33,11 @@ bool SplitFlap_Wrapper_MoveAllToZeroPosition(void){ * returns true when all movements finished */ bool SplitFlap_Wrapper_Display(unsigned char *sentence){ 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), sentence); - McuShell_SendStr(cmd, McuShell_GetStdio()->stdOut); + SHELL_SendToESPAndGetResponse(cmd, response, sizeof(response)); + McuShell_SendStr(response, McuShell_GetStdio()->stdOut); 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) */ bool SplitFlap_Wrapper_SetHardwareIdentifier(uint8_t id, uint8_t hwId){ unsigned char cmd[BUF_SIZE] = RS_CMD_PREFIX; + unsigned char response[128]; unsigned char setupId_str[4] = {0}; unsigned char hardwareId_str[4] = {0}; McuUtility_Num8uToStr(setupId_str, sizeof(setupId_str), id); 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), (unsigned char*)" "); 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; }