From a75b8a9269846ada243ae18d6bacd1e443a66c20 Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Mon, 23 Sep 2024 15:01:52 +0100 Subject: [PATCH] AP_DDS: add params for ping timeout and max retries Signed-off-by: Rhys Mainwaring --- libraries/AP_DDS/AP_DDS_Client.cpp | 23 ++++++++++++++++++++--- libraries/AP_DDS/AP_DDS_Client.h | 6 ++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/libraries/AP_DDS/AP_DDS_Client.cpp b/libraries/AP_DDS/AP_DDS_Client.cpp index 77f052de6204d..a17d8b5231861 100644 --- a/libraries/AP_DDS/AP_DDS_Client.cpp +++ b/libraries/AP_DDS/AP_DDS_Client.cpp @@ -84,6 +84,25 @@ const AP_Param::GroupInfo AP_DDS_Client::var_info[] { // @User: Standard AP_GROUPINFO("_DOMAIN_ID", 4, AP_DDS_Client, domain_id, 0), + // @Param: _TIMEOUT_MS + // @DisplayName: DDS ping timeout + // @Description: The time in milliseconds the DDS client will wait for a response from the XRCE agent before reattempting. + // @Units: ms + // @Range: 1 10000 + // @RebootRequired: True + // @Increment: 1 + // @User: Standard + AP_GROUPINFO("_TIMEOUT_MS", 5, AP_DDS_Client, ping_timeout_ms, 1000), + + // @Param: _MAX_RETRY + // @DisplayName: DDS ping max attempts + // @Description: The maximum number of times the DDS client will attempt to ping the XRCE agent before exiting. + // @Range: 1 100 + // @RebootRequired: True + // @Increment: 1 + // @User: Standard + AP_GROUPINFO("_MAX_RETRY", 6, AP_DDS_Client, ping_max_retry, 10), + AP_GROUPEND }; @@ -699,9 +718,7 @@ void AP_DDS_Client::main_loop(void) } // check ping - const uint64_t ping_timeout_ms{1000}; - const uint8_t ping_max_attempts{10}; - if (!uxr_ping_agent_attempts(comm, ping_timeout_ms, ping_max_attempts)) { + if (!uxr_ping_agent_attempts(comm, ping_timeout_ms, ping_max_retry)) { GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "%s No ping response, exiting", msg_prefix); return; } diff --git a/libraries/AP_DDS/AP_DDS_Client.h b/libraries/AP_DDS/AP_DDS_Client.h index daddfff96877f..c020eae17933c 100644 --- a/libraries/AP_DDS/AP_DDS_Client.h +++ b/libraries/AP_DDS/AP_DDS_Client.h @@ -225,6 +225,12 @@ class AP_DDS_Client //! @brief ROS_DOMAIN_ID AP_Int32 domain_id; + //! @brief Timeout in milliseconds when pinging the XRCE agent + AP_Int32 ping_timeout_ms; + + //! @brief Maximum number of attempts to ping the XRCE agent before exiting + AP_Int8 ping_max_retry; + //! @brief Enum used to mark a topic as a data reader or writer enum class Topic_rw : uint8_t { DataReader = 0,