Skip to content
Snippets Groups Projects
Commit f1dc8f8f authored by Beat Küng's avatar Beat Küng Committed by Lorenz Meier
Browse files

listener: use PX4_INFO_RAW instead of printf

Ensures that clients will get the output of the listener.
parent e6d71680
No related branches found
No related tags found
No related merge requests found
......@@ -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]@
}
\ No newline at end of file
}
......@@ -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):
......
......@@ -92,6 +92,7 @@ print("""
#include <px4_middleware.h>
#include <px4_app.h>
#include <px4_config.h>
#include <px4_log.h>
#include <uORB/uORB.h>
#include <string.h>
#include <stdint.h>
......@@ -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")
......@@ -43,6 +43,7 @@
#include <px4_middleware.h>
#include <px4_app.h>
#include <px4_config.h>
#include <px4_log.h>
#include <uORB/uORB.h>
#include <string.h>
#include <stdint.h>
......@@ -54,7 +55,7 @@ template <typename T>
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;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment