mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 18:06:39 +08:00
orb_print_message_internal: handle 64 bit bitsets
This commit is contained in:
@@ -399,7 +399,7 @@ void orb_print_message_internal(const orb_metadata *meta, const void *data, bool
|
|||||||
} else if (strstr(field_name, "flags") != nullptr) {
|
} else if (strstr(field_name, "flags") != nullptr) {
|
||||||
// bitfield
|
// bitfield
|
||||||
unsigned field_size = 0;
|
unsigned field_size = 0;
|
||||||
unsigned long value = 0;
|
uint64_t value = 0;
|
||||||
|
|
||||||
if (strcmp(c_type, "uint8_t") == 0) {
|
if (strcmp(c_type, "uint8_t") == 0) {
|
||||||
field_size = sizeof(uint8_t);
|
field_size = sizeof(uint8_t);
|
||||||
@@ -412,13 +412,24 @@ void orb_print_message_internal(const orb_metadata *meta, const void *data, bool
|
|||||||
} else if (strcmp(c_type, "uint32_t") == 0) {
|
} else if (strcmp(c_type, "uint32_t") == 0) {
|
||||||
field_size = sizeof(uint32_t);
|
field_size = sizeof(uint32_t);
|
||||||
value = *(uint32_t *)(data_ptr + previous_data_offset);
|
value = *(uint32_t *)(data_ptr + previous_data_offset);
|
||||||
|
|
||||||
|
} else if (strcmp(c_type, "uint64_t") == 0) {
|
||||||
|
field_size = sizeof(uint64_t);
|
||||||
|
value = *(uint64_t *)(data_ptr + previous_data_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field_size > 0) {
|
if (field_size > 0 && value != 0) {
|
||||||
PX4_INFO_RAW(" (0b");
|
PX4_INFO_RAW(" (0b");
|
||||||
|
|
||||||
|
bool got_set_bit = false;
|
||||||
|
|
||||||
for (int i = (field_size * 8) - 1; i >= 0; i--) {
|
for (int i = (field_size * 8) - 1; i >= 0; i--) {
|
||||||
PX4_INFO_RAW("%lu%s", (value >> i) & 1, ((unsigned)i < (field_size * 8) - 1 && i % 4 == 0 && i > 0) ? "'" : "");
|
unsigned current_bit = (value >> i) & 1;
|
||||||
|
got_set_bit |= current_bit;
|
||||||
|
|
||||||
|
if (got_set_bit) {
|
||||||
|
PX4_INFO_RAW("%u%s", current_bit, ((unsigned)i < (field_size * 8) - 1 && i % 4 == 0 && i > 0) ? "'" : "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PX4_INFO_RAW(")");
|
PX4_INFO_RAW(")");
|
||||||
|
|||||||
Reference in New Issue
Block a user