forked from Archive/PX4-Autopilot
uORB: print individual bits of fields
- applies to messages with names containing "flags" or "bits" and unsigned fixed width integer type (uint8, uint16, uint32)
This commit is contained in:
parent
b8f3b97bad
commit
459abcd035
|
@ -235,6 +235,7 @@ add_custom_command(OUTPUT ${uorb_headers}
|
|||
templates/uorb/msg.h.em
|
||||
templates/uorb/uORBTopics.hpp.em
|
||||
tools/px_generate_uorb_topic_files.py
|
||||
tools/px_generate_uorb_topic_helper.py
|
||||
COMMENT "Generating uORB topic headers"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
VERBATIM
|
||||
|
@ -257,6 +258,7 @@ add_custom_command(OUTPUT ${uorb_sources}
|
|||
templates/uorb/msg.cpp.em
|
||||
templates/uorb/uORBTopics.cpp.em
|
||||
tools/px_generate_uorb_topic_files.py
|
||||
tools/px_generate_uorb_topic_helper.py
|
||||
COMMENT "Generating uORB topic sources"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
VERBATIM
|
||||
|
|
|
@ -317,11 +317,15 @@ def print_field(field):
|
|||
print("char baro_device_id_buffer[80];")
|
||||
print("device::Device::device_id_print_buffer(baro_device_id_buffer, sizeof(baro_device_id_buffer), message.baro_device_id);")
|
||||
print("PX4_INFO_RAW(\"\\tbaro_device_id: %d (%s) \\n\", message.baro_device_id, baro_device_id_buffer);")
|
||||
elif ("flags" in field.name or "bits" in field.name) and "uint" in field.type:
|
||||
# print bits of fixed width unsigned integers (uint8, uint16, uint32) if name contains flags or bits
|
||||
print("PX4_INFO_RAW(\"\\t" + field.name + ": " + c_type + " (0b\", " + field_name + ");")
|
||||
print("\tfor (int i = (sizeof(" + field_name + ") * 8) - 1; i >= 0; i--) { PX4_INFO_RAW(\"%u%s\", " + field_name + " >> i & 1, ((unsigned)i < (sizeof(" + field_name + ") * 8) - 1 && i % 4 == 0 && i > 0) ? \"'\" : \"\"); }")
|
||||
print("\tPX4_INFO_RAW(\")\\n\");")
|
||||
elif is_array and 'char' in field.type:
|
||||
print(("PX4_INFO_RAW(\"\\t" + field.name + ": \\\"%." + str(array_length) + "s\\\" \\n\", message." + field.name + ");"))
|
||||
else:
|
||||
print(("PX4_INFO_RAW(\"\\t" + field.name + ": " +
|
||||
c_type + "\\n\", " + field_name + ");"))
|
||||
print(("PX4_INFO_RAW(\"\\t" + field.name + ": " + c_type + "\\n\", " + field_name + ");"))
|
||||
|
||||
|
||||
def print_field_def(field):
|
||||
|
|
Loading…
Reference in New Issue