mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
uORB print_message cleanup
- indent field print with tabs instead of spaces - print a newline before printing a nested field - cmake add generator dependencies
This commit is contained in:
+8
-2
@@ -165,7 +165,10 @@ add_custom_command(OUTPUT ${uorb_headers}
|
|||||||
-e templates/uorb
|
-e templates/uorb
|
||||||
-t ${CMAKE_CURRENT_BINARY_DIR}/tmp/headers
|
-t ${CMAKE_CURRENT_BINARY_DIR}/tmp/headers
|
||||||
-q
|
-q
|
||||||
DEPENDS ${msg_files} templates/uorb/msg.h.template
|
DEPENDS
|
||||||
|
${msg_files}
|
||||||
|
templates/uorb/msg.h.template
|
||||||
|
tools/px_generate_uorb_topic_files.py
|
||||||
COMMENT "Generating uORB topic headers"
|
COMMENT "Generating uORB topic headers"
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
VERBATIM
|
VERBATIM
|
||||||
@@ -182,7 +185,10 @@ add_custom_command(OUTPUT ${uorb_sources}
|
|||||||
-e templates/uorb
|
-e templates/uorb
|
||||||
-t ${CMAKE_CURRENT_BINARY_DIR}/tmp/sources
|
-t ${CMAKE_CURRENT_BINARY_DIR}/tmp/sources
|
||||||
-q
|
-q
|
||||||
DEPENDS ${msg_files} templates/uorb/msg.cpp.template
|
DEPENDS
|
||||||
|
${msg_files}
|
||||||
|
templates/uorb/msg.cpp.template
|
||||||
|
tools/px_generate_uorb_topic_files.py
|
||||||
COMMENT "Generating uORB topic sources"
|
COMMENT "Generating uORB topic sources"
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
VERBATIM
|
VERBATIM
|
||||||
|
|||||||
@@ -80,9 +80,14 @@ ORB_DEFINE(@multi_topic, struct @uorb_struct, @(struct_size-padding_end_size), _
|
|||||||
|
|
||||||
void print_message(const @uorb_struct& message)
|
void print_message(const @uorb_struct& message)
|
||||||
{
|
{
|
||||||
printf(" @(uorb_struct)\n");
|
printf(" @(uorb_struct)\n");
|
||||||
printf("\ttimestamp: %" PRIu64 " (%.6f seconds ago)\n", message.timestamp, hrt_elapsed_time(&message.timestamp) / 1e6);
|
printf("\ttimestamp: %" PRIu64, message.timestamp);
|
||||||
|
if (message.timestamp != 0) {
|
||||||
|
printf(" (%.6f seconds ago)\n", hrt_elapsed_time(&message.timestamp) / 1e6);
|
||||||
|
} else {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
@[for field in sorted_fields]@
|
@[for field in sorted_fields]@
|
||||||
@( print_field(field) )
|
@( print_field(field) )@
|
||||||
@[end for]
|
@[end for]@
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ def print_field(field):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
for i in range(array_length):
|
for i in range(array_length):
|
||||||
print("printf(\" " + field.type + " " + field.name + "[" + str(i) + "]\");")
|
print("printf(\"\\t" + field.type + " " + field.name + "[" + str(i) + "]\");")
|
||||||
print(" print_message(message." + field.name + "[" + str(i) + "]);")
|
print(" print_message(message." + field.name + "[" + str(i) + "]);")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -236,11 +236,11 @@ def print_field(field):
|
|||||||
field_name = "(double)" + field_name
|
field_name = "(double)" + field_name
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("printf(\" " + field.name + "\");")
|
print("printf(\"\\n\\t" + field.name + "\");")
|
||||||
print("\tprint_message(message."+ field.name + ");")
|
print("\tprint_message(message."+ field.name + ");")
|
||||||
return
|
return
|
||||||
|
|
||||||
print("printf(\"\t" + field.name + ": " + c_type + "\\n\", " + field_name + ");" )
|
print("printf(\"\\t" + field.name + ": " + c_type + "\\n\", " + field_name + ");" )
|
||||||
|
|
||||||
|
|
||||||
def print_field_def(field):
|
def print_field_def(field):
|
||||||
|
|||||||
Reference in New Issue
Block a user