mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 07:53:34 +08:00
listener: use PX4_INFO_RAW instead of printf
Ensures that clients will get the output of the listener.
This commit is contained in:
@@ -65,7 +65,7 @@ topic_fields = ["uint64_t timestamp"]+["%s %s" % (convert_type(field.type), fiel
|
||||
}@
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdio>
|
||||
#include <px4_log.h>
|
||||
#include <px4_defines.h>
|
||||
#include <uORB/topics/@(topic_name).h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
@@ -80,14 +80,14 @@ ORB_DEFINE(@multi_topic, struct @uorb_struct, @(struct_size-padding_end_size), _
|
||||
|
||||
void print_message(const @uorb_struct& message)
|
||||
{
|
||||
printf(" @(uorb_struct)\n");
|
||||
printf("\ttimestamp: %" PRIu64, message.timestamp);
|
||||
PX4_INFO_RAW(" @(uorb_struct)\n");
|
||||
PX4_INFO_RAW("\ttimestamp: %" PRIu64, message.timestamp);
|
||||
if (message.timestamp != 0) {
|
||||
printf(" (%.6f seconds ago)\n", hrt_elapsed_time(&message.timestamp) / 1e6);
|
||||
PX4_INFO_RAW(" (%.6f seconds ago)\n", hrt_elapsed_time(&message.timestamp) / 1e6);
|
||||
} else {
|
||||
printf("\n");
|
||||
PX4_INFO_RAW("\n");
|
||||
}
|
||||
@[for field in sorted_fields]@
|
||||
@( print_field(field) )@
|
||||
@[end for]@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ def print_field(field):
|
||||
|
||||
else:
|
||||
for i in range(array_length):
|
||||
print("printf(\"\\t" + field.type + " " + field.name + "[" + str(i) + "]\");")
|
||||
print("PX4_INFO_RAW(\"\\t" + field.type + " " + field.name + "[" + str(i) + "]\");")
|
||||
print(" print_message(message." + field.name + "[" + str(i) + "]);")
|
||||
return
|
||||
|
||||
@@ -242,11 +242,11 @@ def print_field(field):
|
||||
field_name = "(" + field_name + " ? \"True\" : \"False\")"
|
||||
|
||||
else:
|
||||
print("printf(\"\\n\\t" + field.name + "\");")
|
||||
print("PX4_INFO_RAW(\"\\n\\t" + field.name + "\");")
|
||||
print("\tprint_message(message."+ field.name + ");")
|
||||
return
|
||||
|
||||
print("printf(\"\\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):
|
||||
|
||||
Reference in New Issue
Block a user