From 76826f2d469e8697c2c443d863c352c4cf2e5eb9 Mon Sep 17 00:00:00 2001 From: gabryelreyes Date: Tue, 16 Jan 2024 11:52:05 +0100 Subject: [PATCH] Added response union --- lib/RemoteControl/src/App.cpp | 4 ++-- lib/RemoteControl/src/SerialMuxChannels.h | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/RemoteControl/src/App.cpp b/lib/RemoteControl/src/App.cpp index fcb2e104..0d6f07e7 100644 --- a/lib/RemoteControl/src/App.cpp +++ b/lib/RemoteControl/src/App.cpp @@ -337,11 +337,11 @@ void App_cmdRspChannelCallback(const uint8_t* payload, const uint8_t payloadSize if ((nullptr != payload) && (COMMAND_RESPONSE_CHANNEL_DLC == payloadSize)) { const CommandResponse* cmdRsp = reinterpret_cast(payload); - LOG_DEBUG("CMD_RSP: ID: 0x%02X , RSP: 0x%02X", cmdRsp->commandId, cmdRsp->response); + LOG_DEBUG("CMD_RSP: ID: 0x%02X , RSP: 0x%02X", cmdRsp->commandId, cmdRsp->responseId); if (0x04 == cmdRsp->commandId) { - LOG_DEBUG("Max Speed: %d", cmdRsp->value); + LOG_DEBUG("Max Speed: %d", cmdRsp->maxMotorSpeed); } } else diff --git a/lib/RemoteControl/src/SerialMuxChannels.h b/lib/RemoteControl/src/SerialMuxChannels.h index b5c546a1..57e2e774 100644 --- a/lib/RemoteControl/src/SerialMuxChannels.h +++ b/lib/RemoteControl/src/SerialMuxChannels.h @@ -82,9 +82,14 @@ typedef struct _Command /** Struct of the "Command Response" channel payload. */ typedef struct _CommandResponse { - uint8_t commandId; /**< Command ID */ - uint8_t response; /**< Response to the command */ - int16_t value; /**< Value of the response */ + uint8_t commandId; /**< Command ID */ + uint8_t responseId; /**< Response to the command */ + + /** Response Payload. */ + union + { + int16_t maxMotorSpeed; /**< Max speed. */ + }; } __attribute__((packed)) CommandResponse; /** Struct of the "Speed" channel payload. */