From c5cbc7725d67ebaf9eacc3c63205807c08153183 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sun, 10 May 2020 15:35:18 -0400 Subject: [PATCH] msg: timestamp_sample print elapsed from timestamp --- msg/templates/uorb/msg.cpp.em | 3 +++ msg/tools/px_generate_uorb_topic_helper.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/msg/templates/uorb/msg.cpp.em b/msg/templates/uorb/msg.cpp.em index 15fb4a75a8..faa20dd807 100644 --- a/msg/templates/uorb/msg.cpp.em +++ b/msg/templates/uorb/msg.cpp.em @@ -89,6 +89,9 @@ void print_message(const @uorb_struct &message) PX4_INFO_RAW("Not implemented on flash constrained hardware\n"); @[else] PX4_INFO_RAW(" @(uorb_struct)\n"); + + const hrt_abstime now = hrt_absolute_time(); + @[for field in sorted_fields]@ @( print_field(field) )@ @[end for]@ diff --git a/msg/tools/px_generate_uorb_topic_helper.py b/msg/tools/px_generate_uorb_topic_helper.py index 495a8cd888..c0bd8fbe96 100644 --- a/msg/tools/px_generate_uorb_topic_helper.py +++ b/msg/tools/px_generate_uorb_topic_helper.py @@ -298,7 +298,9 @@ def print_field(field): if field.name == 'timestamp': print(("if (message.timestamp != 0) {\n\t\tPX4_INFO_RAW(\"\\t" + field.name + ": " + c_type + " (%.6f seconds ago)\\n\", " + field_name + - ", hrt_elapsed_time(&message.timestamp) / 1e6);\n\t} else {\n\t\tPX4_INFO_RAW(\"\\n\");\n\t}")) + ", (now - message.timestamp) / 1e6);\n\t} else {\n\t\tPX4_INFO_RAW(\"\\n\");\n\t}")) + elif field.name == 'timestamp_sample': + print(("\n\tPX4_INFO_RAW(\"\\t" + field.name + ": " + c_type + " (" + c_type + " us before timestamp)\\n\", " + field_name + ", message.timestamp - message.timestamp_sample);\n\t")) elif field.name == 'device_id': print("char device_id_buffer[80];") print("device::Device::device_id_print_buffer(device_id_buffer, sizeof(device_id_buffer), message.device_id);")