msg: timestamp_sample print elapsed from timestamp

This commit is contained in:
Daniel Agar 2020-05-10 15:35:18 -04:00
parent 2bbdef205e
commit c5cbc7725d
2 changed files with 6 additions and 1 deletions

View File

@ -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]@

View File

@ -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);")