diff --git a/left/src/slave_protocol_handler.c b/left/src/slave_protocol_handler.c index f1245ee..6b0755a 100644 --- a/left/src/slave_protocol_handler.c +++ b/left/src/slave_protocol_handler.c @@ -10,10 +10,17 @@ #include "bool_array_converter.h" #include "bootloader.h" #include "module.h" +#include "versions.h" i2c_message_t RxMessage; i2c_message_t TxMessage; +static version_t moduleProtocolVersion = { + MODULE_PROTOCOL_MAJOR_VERSION, + MODULE_PROTOCOL_MINOR_VERSION, + MODULE_PROTOCOL_PATCH_VERSION, +}; + void SlaveRxHandler(void) { if (!CRC16_IsMessageValid(&RxMessage)) { @@ -57,7 +64,7 @@ void SlaveTxHandler(void) break; } case SlaveProperty_ModuleProtocolVersion: { - TxMessage.data[0] = MODULE_PROTOCOL_VERSION; + memcpy(TxMessage.data, &moduleProtocolVersion, sizeof(version_t)); TxMessage.length = 1; break; } diff --git a/right/src/slave_drivers/uhk_module_driver.c b/right/src/slave_drivers/uhk_module_driver.c index 112369e..96a873a 100644 --- a/right/src/slave_drivers/uhk_module_driver.c +++ b/right/src/slave_drivers/uhk_module_driver.c @@ -113,7 +113,7 @@ status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleDriverId) case UhkModulePhase_ProcessModuleProtocolVersion: { bool isMessageValid = CRC16_IsMessageValid(rxMessage); if (isMessageValid) { - uhkModuleState->protocolVersion = rxMessage->data[0]; + memcpy(&uhkModuleState->moduleProtocolVersion, rxMessage->data, sizeof(version_t)); } status = kStatus_Uhk_NoTransfer; *uhkModulePhase = isMessageValid ? UhkModulePhase_RequestModuleId : UhkModulePhase_RequestModuleProtocolVersion; diff --git a/right/src/slave_drivers/uhk_module_driver.h b/right/src/slave_drivers/uhk_module_driver.h index bc87861..8955f57 100644 --- a/right/src/slave_drivers/uhk_module_driver.h +++ b/right/src/slave_drivers/uhk_module_driver.h @@ -5,6 +5,7 @@ #include "fsl_common.h" #include "crc16.h" + #include "versions.h" // Macros: @@ -62,7 +63,7 @@ typedef struct { uint8_t moduleId; - uint8_t protocolVersion; + version_t moduleProtocolVersion; uhk_module_phase_t phase; uhk_module_vars_t sourceVars; uhk_module_vars_t targetVars;