From 29de1192dd7b4f7d3b559b6271bd292eda0964f5 Mon Sep 17 00:00:00 2001 From: Ryan Howard Date: Thu, 7 Nov 2024 15:02:40 -0500 Subject: [PATCH] fix how the batch message is seralized on the firmware (#815) --- 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