diff --git a/msg/templates/uorb/msg.cpp.template b/msg/templates/uorb/msg.cpp.template index 11764637a4..d803e34f30 100644 --- a/msg/templates/uorb/msg.cpp.template +++ b/msg/templates/uorb/msg.cpp.template @@ -65,7 +65,7 @@ topic_fields = ["uint64_t timestamp"]+["%s %s" % (convert_type(field.type), fiel }@ #include -#include +#include #include #include #include @@ -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]@ -} \ No newline at end of file +} diff --git a/msg/tools/px_generate_uorb_topic_helper.py b/msg/tools/px_generate_uorb_topic_helper.py index b5d89cdba7..d876d83bb1 100644 --- a/msg/tools/px_generate_uorb_topic_helper.py +++ b/msg/tools/px_generate_uorb_topic_helper.py @@ -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): diff --git a/src/systemcmds/topic_listener/generate_listener.py b/src/systemcmds/topic_listener/generate_listener.py index 18fefacf1e..8a8b95beb7 100755 --- a/src/systemcmds/topic_listener/generate_listener.py +++ b/src/systemcmds/topic_listener/generate_listener.py @@ -92,6 +92,7 @@ print(""" #include #include #include +#include #include #include #include @@ -125,7 +126,7 @@ for index, (m, t) in enumerate(zip(messages, topics)): print("\t\tlistener<%s_s>(ORB_ID(%s), num_msgs, topic_instance, topic_interval);" % (m, t)) print("\t} else {") -print("\t\t printf(\" Topic did not match any known topics\\n\");") +print("\t\t PX4_INFO_RAW(\" Topic did not match any known topics\\n\");") print("\t}") print("}\n") diff --git a/src/systemcmds/topic_listener/topic_listener.hpp b/src/systemcmds/topic_listener/topic_listener.hpp index 239ed02e21..8760ca2b3d 100644 --- a/src/systemcmds/topic_listener/topic_listener.hpp +++ b/src/systemcmds/topic_listener/topic_listener.hpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,7 @@ template void listener(const orb_id_t &id, unsigned num_msgs, unsigned topic_instance, unsigned topic_interval) { if (orb_exists(id, topic_instance) != 0) { - printf("never published\n"); + PX4_INFO_RAW("never published\n"); return; } @@ -79,7 +80,7 @@ void listener(const orb_id_t &id, unsigned num_msgs, unsigned topic_instance, un start_time = hrt_absolute_time(); i++; - printf("\nTOPIC: %s instance %d #%d\n", id->o_name, topic_instance, i); + PX4_INFO_RAW("\nTOPIC: %s instance %d #%d\n", id->o_name, topic_instance, i); T container; @@ -92,7 +93,7 @@ void listener(const orb_id_t &id, unsigned num_msgs, unsigned topic_instance, un } else { if (hrt_elapsed_time(&start_time) > 2 * 1000 * 1000) { - printf("Waited for 2 seconds without a message. Giving up.\n"); + PX4_INFO_RAW("Waited for 2 seconds without a message. Giving up.\n"); break; } }