From a324e5465a1bde047dac494c4a394bb8152e2101 Mon Sep 17 00:00:00 2001 From: TSC21 Date: Mon, 12 Jul 2021 10:09:51 +0200 Subject: [PATCH] timesync: extend timesync_status message with protocol source field and enum --- msg/timesync_status.msg | 13 +++++++++---- src/modules/mavlink/mavlink_timesync.cpp | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/msg/timesync_status.msg b/msg/timesync_status.msg index 38ff31db75..df0a56ca8a 100644 --- a/msg/timesync_status.msg +++ b/msg/timesync_status.msg @@ -1,5 +1,10 @@ -uint64 timestamp # time since system start (microseconds) +uint64 timestamp # time since system start (microseconds) + +uint8 SOURCE_PROTOCOL_MAVLINK = 0 +uint8 SOURCE_PROTOCOL_RTPS = 1 +uint8 source_protocol # timesync source. Source can be MAVLink or the microRTPS bridge + uint64 remote_timestamp # remote system timestamp (microseconds) -int64 observed_offset # raw time offset directly observed from this timesync packet (microseconds) -int64 estimated_offset # smoothed time offset between companion system and PX4 (microseconds) -uint32 round_trip_time # round trip time of this timesync packet (microseconds) +int64 observed_offset # raw time offset directly observed from this timesync packet (microseconds) +int64 estimated_offset # smoothed time offset between companion system and PX4 (microseconds) +uint32 round_trip_time # round trip time of this timesync packet (microseconds) diff --git a/src/modules/mavlink/mavlink_timesync.cpp b/src/modules/mavlink/mavlink_timesync.cpp index 6cd963abc2..d930a66295 100644 --- a/src/modules/mavlink/mavlink_timesync.cpp +++ b/src/modules/mavlink/mavlink_timesync.cpp @@ -141,6 +141,7 @@ MavlinkTimesync::handle_message(const mavlink_message_t *msg) timesync_status_s tsync_status{}; tsync_status.timestamp = hrt_absolute_time(); + tsync_status.source_protocol = timesync_status_s::SOURCE_PROTOCOL_MAVLINK; tsync_status.remote_timestamp = tsync.tc1 / 1000ULL; tsync_status.observed_offset = offset_us; tsync_status.estimated_offset = (int64_t)_time_offset;