From 70d6528a9bf0744368f36553ea0f93a5d1c08547 Mon Sep 17 00:00:00 2001 From: Beniamino Pozzan Date: Sun, 30 Nov 2025 17:56:45 +0000 Subject: [PATCH] chore(uxrce_dds_client): merge SYNCC and SYNCT into CTRL Signed-off-by: Beniamino Pozzan --- src/modules/uxrce_dds_client/module.yaml | 27 +++++++------------ .../uxrce_dds_client/uxrce_dds_client.cpp | 6 ++--- .../uxrce_dds_client/uxrce_dds_client.h | 8 ++++-- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/modules/uxrce_dds_client/module.yaml b/src/modules/uxrce_dds_client/module.yaml index 3e9d03fcc9..c302582858 100644 --- a/src/modules/uxrce_dds_client/module.yaml +++ b/src/modules/uxrce_dds_client/module.yaml @@ -85,26 +85,17 @@ parameters: max: 2 default: 0 - UXRCE_DDS_SYNCT: + UXRCE_DDS_CTRL: description: - short: Enable uXRCE-DDS timestamp synchronization - long: When enabled, uxrce_dds_client will synchronize the timestamps - of the incoming and outgoing messages measuring the offset - between the Agent OS time and the PX4 time. - type: boolean - category: System - reboot_required: true + short: UXRCE_DDS_CLIENT control flags + long: 'Set bits in the following positions to enable: 0 : timestamp sync 1 : system time sync' + type: bitmask + bit: + 0: Timestamp Synchronization + 1: System Clock Synchronization default: 1 - - UXRCE_DDS_SYNCC: - description: - short: Enable uXRCE-DDS system clock synchronization - long: When enabled along with UXRCE_DDS_SYNCT, uxrce_dds_client will - set the system clock using the agents UTC timestamp. - type: boolean - category: System - reboot_required: true - default: 0 + min: 0 + max: 3 UXRCE_DDS_TX_TO: description: diff --git a/src/modules/uxrce_dds_client/uxrce_dds_client.cpp b/src/modules/uxrce_dds_client/uxrce_dds_client.cpp index d5f2b57042..67824c504e 100644 --- a/src/modules/uxrce_dds_client/uxrce_dds_client.cpp +++ b/src/modules/uxrce_dds_client/uxrce_dds_client.cpp @@ -203,7 +203,7 @@ void UxrceddsClient::deinit() bool UxrceddsClient::setupSession(uxrSession *session) { _participant_config = static_cast(_param_uxrce_dds_ptcfg.get()); - _synchronize_timestamps = (_param_uxrce_dds_synct.get() > 0); + _synchronize_timestamps = (_param_uxrce_dds_ctrl.get() & static_cast(Ctrl::kTimestampSync)); bool got_response = false; @@ -331,7 +331,7 @@ bool UxrceddsClient::setupSession(uxrSession *session) if (_timesync.sync_converged()) { PX4_INFO("synchronized with time offset %-5" PRId64 "us", session->time_offset / 1000); - if (_param_uxrce_dds_syncc.get() > 0) { + if (_param_uxrce_dds_ctrl.get() & static_cast(Ctrl::kSystemClockSync)) { syncSystemClock(session); } @@ -686,7 +686,7 @@ void UxrceddsClient::run() if (uxr_sync_session(&session, 10) && _timesync.sync_converged()) { last_sync_session = hrt_absolute_time(); - if (_param_uxrce_dds_syncc.get() > 0) { + if (_param_uxrce_dds_ctrl.get() & static_cast(Ctrl::kSystemClockSync)) { syncSystemClock(&session); } } diff --git a/src/modules/uxrce_dds_client/uxrce_dds_client.h b/src/modules/uxrce_dds_client/uxrce_dds_client.h index 7b5208a80e..6eb85dcacc 100644 --- a/src/modules/uxrce_dds_client/uxrce_dds_client.h +++ b/src/modules/uxrce_dds_client/uxrce_dds_client.h @@ -203,12 +203,16 @@ private: perf_counter_t _loop_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")}; perf_counter_t _loop_interval_perf{perf_alloc(PC_INTERVAL, MODULE_NAME": cycle interval")}; + enum class Ctrl : uint8_t { + kTimestampSync = (1 << 0), + kSystemClockSync = (1 << 1) + }; + DEFINE_PARAMETERS( (ParamInt) _param_uxrce_dds_dom_id, (ParamInt) _param_uxrce_key, (ParamInt) _param_uxrce_dds_ptcfg, - (ParamInt) _param_uxrce_dds_syncc, - (ParamInt) _param_uxrce_dds_synct, + (ParamInt) _param_uxrce_dds_ctrl, (ParamInt) _param_uxrce_dds_tx_to, (ParamInt) _param_uxrce_dds_rx_to )