Skip to content

Commit 9b4907f

Browse files
committed
fix how the batch message is seralized on the firmware (#815)
1 parent 09f9871 commit 9b4907f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/can/core/messages.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -1002,9 +1002,16 @@ struct BatchReadFromSensorResponse
10021002
bit_utils::int_to_bytes(static_cast<uint8_t>(sensor), iter, limit);
10031003
iter = bit_utils::int_to_bytes(static_cast<uint8_t>(sensor_id), iter,
10041004
limit);
1005+
iter = bit_utils::int_to_bytes(static_cast<uint8_t>(data_length), iter,
1006+
limit);
10051007
for (auto i = 0; i < data_length; i++) {
10061008
iter = bit_utils::int_to_bytes(sensor_data.at(i), iter, limit);
10071009
}
1010+
// Since python expects statically sized messages to unpack, pad the end
1011+
// with 0's
1012+
for (auto i = data_length; i < BATCH_SENSOR_MAX_LEN; i++) {
1013+
iter = bit_utils::int_to_bytes(int32_t(0), iter, limit);
1014+
}
10081015
return iter - body;
10091016
}
10101017
auto operator==(const BatchReadFromSensorResponse& other) const

0 commit comments

Comments
 (0)