From 1a8becca7797467e5b7ac775a7f9e890b5dddecb Mon Sep 17 00:00:00 2001 From: BlueAndi Date: Sat, 28 Feb 2026 13:57:35 +0100 Subject: [PATCH] SerialMuxProt updated to v2.4.0 --- lib/APPConvoyFollower/src/SerialMuxChannels.h | 16 +++++++++++++- lib/APPConvoyLeader/src/SerialMuxChannels.h | 16 +++++++++++++- lib/APPLineFollower/src/SerialMuxChannels.h | 22 ++++++++++++++++++- lib/APPRemoteControl/src/SerialMuxChannels.h | 22 ++++++++++++++++++- lib/APPSensorFusion/src/SerialMuxChannels.h | 4 +++- lib/APPTurtle/src/SerialMuxChannels.h | 22 ++++++++++++++++++- platformio.ini | 18 ++++++++++----- 7 files changed, 108 insertions(+), 12 deletions(-) diff --git a/lib/APPConvoyFollower/src/SerialMuxChannels.h b/lib/APPConvoyFollower/src/SerialMuxChannels.h index 68ea50f1..baecf597 100644 --- a/lib/APPConvoyFollower/src/SerialMuxChannels.h +++ b/lib/APPConvoyFollower/src/SerialMuxChannels.h @@ -40,7 +40,6 @@ /****************************************************************************** * Includes *****************************************************************************/ - #include #include @@ -159,6 +158,9 @@ typedef struct _Command } __attribute__((packed)) Command; +static_assert(sizeof(Command) <= MAX_DATA_LEN, + "Command struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Command Response" channel payload. */ typedef struct _CommandResponse { @@ -172,6 +174,9 @@ typedef struct _CommandResponse }; } __attribute__((packed)) CommandResponse; +static_assert(sizeof(CommandResponse) <= MAX_DATA_LEN, + "CommandResponse struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Speed" channel payload. */ typedef struct _SpeedData { @@ -180,6 +185,9 @@ typedef struct _SpeedData int32_t center; /**< Center motor speed [mm/s] */ } __attribute__((packed)) SpeedData; +static_assert(sizeof(SpeedData) <= MAX_DATA_LEN, + "SpeedData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Current Vehicle Data" channel payload. */ typedef struct _VehicleData { @@ -192,12 +200,18 @@ typedef struct _VehicleData SMPChannelPayload::Range proximity; /**< Range at which object is found [range]. */ } __attribute__((packed)) VehicleData; +static_assert(sizeof(VehicleData) <= MAX_DATA_LEN, + "VehicleData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Status" channel payload. */ typedef struct _Status { SMPChannelPayload::Status status; /**< Status */ } __attribute__((packed)) Status; +static_assert(sizeof(Status) <= MAX_DATA_LEN, + "Status struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /****************************************************************************** * Functions *****************************************************************************/ diff --git a/lib/APPConvoyLeader/src/SerialMuxChannels.h b/lib/APPConvoyLeader/src/SerialMuxChannels.h index 68ea50f1..baecf597 100644 --- a/lib/APPConvoyLeader/src/SerialMuxChannels.h +++ b/lib/APPConvoyLeader/src/SerialMuxChannels.h @@ -40,7 +40,6 @@ /****************************************************************************** * Includes *****************************************************************************/ - #include #include @@ -159,6 +158,9 @@ typedef struct _Command } __attribute__((packed)) Command; +static_assert(sizeof(Command) <= MAX_DATA_LEN, + "Command struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Command Response" channel payload. */ typedef struct _CommandResponse { @@ -172,6 +174,9 @@ typedef struct _CommandResponse }; } __attribute__((packed)) CommandResponse; +static_assert(sizeof(CommandResponse) <= MAX_DATA_LEN, + "CommandResponse struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Speed" channel payload. */ typedef struct _SpeedData { @@ -180,6 +185,9 @@ typedef struct _SpeedData int32_t center; /**< Center motor speed [mm/s] */ } __attribute__((packed)) SpeedData; +static_assert(sizeof(SpeedData) <= MAX_DATA_LEN, + "SpeedData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Current Vehicle Data" channel payload. */ typedef struct _VehicleData { @@ -192,12 +200,18 @@ typedef struct _VehicleData SMPChannelPayload::Range proximity; /**< Range at which object is found [range]. */ } __attribute__((packed)) VehicleData; +static_assert(sizeof(VehicleData) <= MAX_DATA_LEN, + "VehicleData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Status" channel payload. */ typedef struct _Status { SMPChannelPayload::Status status; /**< Status */ } __attribute__((packed)) Status; +static_assert(sizeof(Status) <= MAX_DATA_LEN, + "Status struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /****************************************************************************** * Functions *****************************************************************************/ diff --git a/lib/APPLineFollower/src/SerialMuxChannels.h b/lib/APPLineFollower/src/SerialMuxChannels.h index 6506430b..8d68654f 100644 --- a/lib/APPLineFollower/src/SerialMuxChannels.h +++ b/lib/APPLineFollower/src/SerialMuxChannels.h @@ -40,7 +40,6 @@ /****************************************************************************** * Includes *****************************************************************************/ - #include #include @@ -171,6 +170,9 @@ typedef struct _Command } __attribute__((packed)) Command; +static_assert(sizeof(Command) <= MAX_DATA_LEN, + "Command struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Command Response" channel payload. */ typedef struct _CommandResponse { @@ -184,6 +186,9 @@ typedef struct _CommandResponse }; } __attribute__((packed)) CommandResponse; +static_assert(sizeof(CommandResponse) <= MAX_DATA_LEN, + "CommandResponse struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Motor Speed Setpoints" channel payload. */ typedef struct _MotorSpeed { @@ -191,6 +196,9 @@ typedef struct _MotorSpeed int32_t right; /**< Right motor speed [mm/s] */ } __attribute__((packed)) MotorSpeed; +static_assert(sizeof(MotorSpeed) <= MAX_DATA_LEN, + "MotorSpeed struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Robot Speed Setpoints" channel payload. */ typedef struct _RobotSpeed { @@ -198,6 +206,9 @@ typedef struct _RobotSpeed int32_t angular; /**< Angular speed. [mrad/s] */ } __attribute__((packed)) RobotSpeed; +static_assert(sizeof(RobotSpeed) <= MAX_DATA_LEN, + "RobotSpeed struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Current Vehicle Data" channel payload. */ typedef struct _VehicleData { @@ -210,18 +221,27 @@ typedef struct _VehicleData SMPChannelPayload::Range proximity; /**< Range at which object is found [range]. */ } __attribute__((packed)) VehicleData; +static_assert(sizeof(VehicleData) <= MAX_DATA_LEN, + "VehicleData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Status" channel payload. */ typedef struct _Status { SMPChannelPayload::Status status; /**< Status */ } __attribute__((packed)) Status; +static_assert(sizeof(Status) <= MAX_DATA_LEN, + "Status struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Line Sensor" channel payload. */ typedef struct _LineSensorData { uint16_t lineSensorData[5U]; /**< Line sensor data [digits] normalized to max 1000 digits. */ } __attribute__((packed)) LineSensorData; +static_assert(sizeof(LineSensorData) <= MAX_DATA_LEN, + "LineSensorData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /****************************************************************************** * Functions *****************************************************************************/ diff --git a/lib/APPRemoteControl/src/SerialMuxChannels.h b/lib/APPRemoteControl/src/SerialMuxChannels.h index 6506430b..8d68654f 100644 --- a/lib/APPRemoteControl/src/SerialMuxChannels.h +++ b/lib/APPRemoteControl/src/SerialMuxChannels.h @@ -40,7 +40,6 @@ /****************************************************************************** * Includes *****************************************************************************/ - #include #include @@ -171,6 +170,9 @@ typedef struct _Command } __attribute__((packed)) Command; +static_assert(sizeof(Command) <= MAX_DATA_LEN, + "Command struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Command Response" channel payload. */ typedef struct _CommandResponse { @@ -184,6 +186,9 @@ typedef struct _CommandResponse }; } __attribute__((packed)) CommandResponse; +static_assert(sizeof(CommandResponse) <= MAX_DATA_LEN, + "CommandResponse struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Motor Speed Setpoints" channel payload. */ typedef struct _MotorSpeed { @@ -191,6 +196,9 @@ typedef struct _MotorSpeed int32_t right; /**< Right motor speed [mm/s] */ } __attribute__((packed)) MotorSpeed; +static_assert(sizeof(MotorSpeed) <= MAX_DATA_LEN, + "MotorSpeed struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Robot Speed Setpoints" channel payload. */ typedef struct _RobotSpeed { @@ -198,6 +206,9 @@ typedef struct _RobotSpeed int32_t angular; /**< Angular speed. [mrad/s] */ } __attribute__((packed)) RobotSpeed; +static_assert(sizeof(RobotSpeed) <= MAX_DATA_LEN, + "RobotSpeed struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Current Vehicle Data" channel payload. */ typedef struct _VehicleData { @@ -210,18 +221,27 @@ typedef struct _VehicleData SMPChannelPayload::Range proximity; /**< Range at which object is found [range]. */ } __attribute__((packed)) VehicleData; +static_assert(sizeof(VehicleData) <= MAX_DATA_LEN, + "VehicleData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Status" channel payload. */ typedef struct _Status { SMPChannelPayload::Status status; /**< Status */ } __attribute__((packed)) Status; +static_assert(sizeof(Status) <= MAX_DATA_LEN, + "Status struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Line Sensor" channel payload. */ typedef struct _LineSensorData { uint16_t lineSensorData[5U]; /**< Line sensor data [digits] normalized to max 1000 digits. */ } __attribute__((packed)) LineSensorData; +static_assert(sizeof(LineSensorData) <= MAX_DATA_LEN, + "LineSensorData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /****************************************************************************** * Functions *****************************************************************************/ diff --git a/lib/APPSensorFusion/src/SerialMuxChannels.h b/lib/APPSensorFusion/src/SerialMuxChannels.h index 414537df..091350f9 100644 --- a/lib/APPSensorFusion/src/SerialMuxChannels.h +++ b/lib/APPSensorFusion/src/SerialMuxChannels.h @@ -41,7 +41,6 @@ /****************************************************************************** * Includes *****************************************************************************/ - #include #include @@ -94,6 +93,9 @@ typedef struct _SensorData } __attribute__((packed)) SensorData; +static_assert(sizeof(SensorData) <= MAX_DATA_LEN, + "SensorData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /****************************************************************************** * Functions *****************************************************************************/ diff --git a/lib/APPTurtle/src/SerialMuxChannels.h b/lib/APPTurtle/src/SerialMuxChannels.h index 6506430b..8d68654f 100644 --- a/lib/APPTurtle/src/SerialMuxChannels.h +++ b/lib/APPTurtle/src/SerialMuxChannels.h @@ -40,7 +40,6 @@ /****************************************************************************** * Includes *****************************************************************************/ - #include #include @@ -171,6 +170,9 @@ typedef struct _Command } __attribute__((packed)) Command; +static_assert(sizeof(Command) <= MAX_DATA_LEN, + "Command struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Command Response" channel payload. */ typedef struct _CommandResponse { @@ -184,6 +186,9 @@ typedef struct _CommandResponse }; } __attribute__((packed)) CommandResponse; +static_assert(sizeof(CommandResponse) <= MAX_DATA_LEN, + "CommandResponse struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Motor Speed Setpoints" channel payload. */ typedef struct _MotorSpeed { @@ -191,6 +196,9 @@ typedef struct _MotorSpeed int32_t right; /**< Right motor speed [mm/s] */ } __attribute__((packed)) MotorSpeed; +static_assert(sizeof(MotorSpeed) <= MAX_DATA_LEN, + "MotorSpeed struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Robot Speed Setpoints" channel payload. */ typedef struct _RobotSpeed { @@ -198,6 +206,9 @@ typedef struct _RobotSpeed int32_t angular; /**< Angular speed. [mrad/s] */ } __attribute__((packed)) RobotSpeed; +static_assert(sizeof(RobotSpeed) <= MAX_DATA_LEN, + "RobotSpeed struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Current Vehicle Data" channel payload. */ typedef struct _VehicleData { @@ -210,18 +221,27 @@ typedef struct _VehicleData SMPChannelPayload::Range proximity; /**< Range at which object is found [range]. */ } __attribute__((packed)) VehicleData; +static_assert(sizeof(VehicleData) <= MAX_DATA_LEN, + "VehicleData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Status" channel payload. */ typedef struct _Status { SMPChannelPayload::Status status; /**< Status */ } __attribute__((packed)) Status; +static_assert(sizeof(Status) <= MAX_DATA_LEN, + "Status struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /** Struct of the "Line Sensor" channel payload. */ typedef struct _LineSensorData { uint16_t lineSensorData[5U]; /**< Line sensor data [digits] normalized to max 1000 digits. */ } __attribute__((packed)) LineSensorData; +static_assert(sizeof(LineSensorData) <= MAX_DATA_LEN, + "LineSensorData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame."); + /****************************************************************************** * Functions *****************************************************************************/ diff --git a/platformio.ini b/platformio.ini index a28cda4e..4340d438 100644 --- a/platformio.ini +++ b/platformio.ini @@ -139,11 +139,12 @@ extra_scripts = ; ***************************************************************************** [app:ConvoyLeader] build_flags = + -D MAX_DATA_LEN=36U ; Overwrite SerialMuxProt max. data length lib_deps = APPConvoyLeader Service Utilities - gabryelreyes/SerialMuxProt @ ^2.3.0 + gabryelreyes/SerialMuxProt @ ^2.4.0 bblanchon/ArduinoJson @ ^7.4.2 PlatoonService lib_ignore = @@ -159,11 +160,12 @@ lib_ignore = ; ***************************************************************************** [app:ConvoyFollower] build_flags = + -D MAX_DATA_LEN=36U ; Overwrite SerialMuxProt max. data length lib_deps = APPConvoyFollower Service Utilities - gabryelreyes/SerialMuxProt @ ^2.3.0 + gabryelreyes/SerialMuxProt @ ^2.4.0 bblanchon/ArduinoJson @ ^7.4.2 PlatoonService lib_ignore = @@ -179,11 +181,12 @@ lib_ignore = ; ***************************************************************************** [app:LineFollower] build_flags = + -D MAX_DATA_LEN=36U ; Overwrite SerialMuxProt max. data length lib_deps = APPLineFollower Service Utilities - gabryelreyes/SerialMuxProt @ ^2.3.0 + gabryelreyes/SerialMuxProt @ ^2.4.0 bblanchon/ArduinoJson @ ^7.4.2 lib_ignore = APPConvoyLeader @@ -198,11 +201,12 @@ lib_ignore = ; ***************************************************************************** [app:RemoteControl] build_flags = + -D MAX_DATA_LEN=36U ; Overwrite SerialMuxProt max. data length lib_deps = APPRemoteControl Service Utilities - gabryelreyes/SerialMuxProt @ ^2.3.0 + gabryelreyes/SerialMuxProt @ ^2.4.0 bblanchon/ArduinoJson @ ^7.4.2 lib_ignore = APPConvoyLeader @@ -234,10 +238,11 @@ lib_ignore = ; ***************************************************************************** [app:SensorFusion] build_flags = + -D MAX_DATA_LEN=32U ; Overwrite SerialMuxProt max. data length lib_deps = APPSensorFusion hideakitai/ArduinoEigen @ ^0.3.2 - gabryelreyes/SerialMuxProt @ ^2.3.0 + gabryelreyes/SerialMuxProt @ ^2.4.0 bblanchon/ArduinoJson @ ^7.4.2 lib_ignore = APPConvoyLeader @@ -252,12 +257,13 @@ lib_ignore = ; ***************************************************************************** [app:Turtle] build_flags = + -D MAX_DATA_LEN=32U ; Overwrite SerialMuxProt max. data length lib_deps = APPTurtle Service Utilities bblanchon/ArduinoJson @ ^7.4.2 - gabryelreyes/SerialMuxProt @ ^2.3.0 + gabryelreyes/SerialMuxProt @ ^2.4.0 lib_ignore = APPConvoyLeader APPConvoyFollower