mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 19:11:36 +08:00
logger: fix alignment issue in data message header
This commit is contained in:
@@ -546,10 +546,14 @@ void Logger::run()
|
|||||||
for (uint8_t instance = 0; instance < ORB_MULTI_MAX_INSTANCES; instance++) {
|
for (uint8_t instance = 0; instance < ORB_MULTI_MAX_INSTANCES; instance++) {
|
||||||
if (copy_if_updated_multi(sub, instance, buffer + sizeof(ulog_message_data_header_s))) {
|
if (copy_if_updated_multi(sub, instance, buffer + sizeof(ulog_message_data_header_s))) {
|
||||||
|
|
||||||
ulog_message_data_header_s *header = reinterpret_cast<ulog_message_data_header_s *>(buffer);
|
uint16_t write_msg_size = static_cast<uint16_t>(msg_size - ULOG_MSG_HEADER_LEN);
|
||||||
header->msg_type = static_cast<uint8_t>(ULogMessageType::DATA);
|
//write one byte after another (necessary because of alignment)
|
||||||
header->msg_size = static_cast<uint16_t>(msg_size - ULOG_MSG_HEADER_LEN);
|
buffer[0] = (uint8_t)write_msg_size;
|
||||||
header->msg_id = sub.msg_ids[instance];
|
buffer[1] = (uint8_t)(write_msg_size >> 8);
|
||||||
|
buffer[2] = static_cast<uint8_t>(ULogMessageType::DATA);
|
||||||
|
uint16_t write_msg_id = sub.msg_ids[instance];
|
||||||
|
buffer[3] = (uint8_t)write_msg_id;
|
||||||
|
buffer[4] = (uint8_t)(write_msg_id >> 8);
|
||||||
|
|
||||||
//PX4_INFO("topic: %s, size = %zu, out_size = %zu", sub.metadata->o_name, sub.metadata->o_size, msg_size);
|
//PX4_INFO("topic: %s, size = %zu, out_size = %zu", sub.metadata->o_name, sub.metadata->o_size, msg_size);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user