From 4d3b99657f1aa6f1c351e53599f373b695544003 Mon Sep 17 00:00:00 2001 From: Ryan howard Date: Thu, 7 Nov 2024 13:46:24 -0500 Subject: [PATCH] fix how the batch message is seralized on the firmware --- include/can/core/messages.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/can/core/messages.hpp b/include/can/core/messages.hpp index 8380ee8f3..a2185c04a 100644 --- a/include/can/core/messages.hpp +++ b/include/can/core/messages.hpp @@ -1002,9 +1002,16 @@ struct BatchReadFromSensorResponse bit_utils::int_to_bytes(static_cast(sensor), iter, limit); iter = bit_utils::int_to_bytes(static_cast(sensor_id), iter, limit); + iter = bit_utils::int_to_bytes(static_cast(data_length), iter, + limit); for (auto i = 0; i < data_length; i++) { iter = bit_utils::int_to_bytes(sensor_data.at(i), iter, limit); } + // Since python expects statically sized messages to unpack, pad the end + // with 0's + for (auto i = data_length; i < BATCH_SENSOR_MAX_LEN; i++) { + iter = bit_utils::int_to_bytes(int32_t(0), iter, limit); + } return iter - body; } auto operator==(const BatchReadFromSensorResponse& other) const