4040/* *****************************************************************************
4141 * Includes
4242 *****************************************************************************/
43-
4443#include < Arduino.h>
4544#include < SerialMuxProtServer.hpp>
4645
@@ -171,6 +170,9 @@ typedef struct _Command
171170
172171} __attribute__((packed)) Command;
173172
173+ static_assert (sizeof (Command) <= MAX_DATA_LEN,
174+ " Command struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame." );
175+
174176/* * Struct of the "Command Response" channel payload. */
175177typedef struct _CommandResponse
176178{
@@ -184,20 +186,29 @@ typedef struct _CommandResponse
184186 };
185187} __attribute__((packed)) CommandResponse;
186188
189+ static_assert (sizeof (CommandResponse) <= MAX_DATA_LEN,
190+ " CommandResponse struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame." );
191+
187192/* * Struct of the "Motor Speed Setpoints" channel payload. */
188193typedef struct _MotorSpeed
189194{
190195 int32_t left; /* *< Left motor speed [mm/s] */
191196 int32_t right; /* *< Right motor speed [mm/s] */
192197} __attribute__((packed)) MotorSpeed;
193198
199+ static_assert (sizeof (MotorSpeed) <= MAX_DATA_LEN,
200+ " MotorSpeed struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame." );
201+
194202/* * Struct of the "Robot Speed Setpoints" channel payload. */
195203typedef struct _RobotSpeed
196204{
197205 int32_t linearCenter; /* *< Linear speed of the vehicle center. [mm/s] */
198206 int32_t angular; /* *< Angular speed. [mrad/s] */
199207} __attribute__((packed)) RobotSpeed;
200208
209+ static_assert (sizeof (RobotSpeed) <= MAX_DATA_LEN,
210+ " RobotSpeed struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame." );
211+
201212/* * Struct of the "Current Vehicle Data" channel payload. */
202213typedef struct _VehicleData
203214{
@@ -210,18 +221,27 @@ typedef struct _VehicleData
210221 SMPChannelPayload::Range proximity; /* *< Range at which object is found [range]. */
211222} __attribute__((packed)) VehicleData;
212223
224+ static_assert (sizeof (VehicleData) <= MAX_DATA_LEN,
225+ " VehicleData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame." );
226+
213227/* * Struct of the "Status" channel payload. */
214228typedef struct _Status
215229{
216230 SMPChannelPayload::Status status; /* *< Status */
217231} __attribute__((packed)) Status;
218232
233+ static_assert (sizeof (Status) <= MAX_DATA_LEN,
234+ " Status struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame." );
235+
219236/* * Struct of the "Line Sensor" channel payload. */
220237typedef struct _LineSensorData
221238{
222239 uint16_t lineSensorData[5U ]; /* *< Line sensor data [digits] normalized to max 1000 digits. */
223240} __attribute__((packed)) LineSensorData;
224241
242+ static_assert (sizeof (LineSensorData) <= MAX_DATA_LEN,
243+ " LineSensorData struct size must be less than or equal to MAX_DATA_LEN to fit in the SerialMuxProt frame." );
244+
225245/* *****************************************************************************
226246 * Functions
227247 *****************************************************************************/
0 commit comments