From a918610846b946bcfbee68dd5addd02e92ce6531 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Thu, 7 Dec 2023 14:58:41 +0200 Subject: [PATCH] lib/dataman: Port dataman/datamanclient to new uORB --- src/lib/dataman_client/DatamanClient.cpp | 4 ++-- src/lib/dataman_client/DatamanClient.hpp | 4 +++- src/modules/dataman/dataman.cpp | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib/dataman_client/DatamanClient.cpp b/src/lib/dataman_client/DatamanClient.cpp index 1fa4820fef16..aeaa65c55c1a 100644 --- a/src/lib/dataman_client/DatamanClient.cpp +++ b/src/lib/dataman_client/DatamanClient.cpp @@ -42,7 +42,7 @@ DatamanClient::DatamanClient() _dataman_request_pub.advertise(); _dataman_response_sub = orb_subscribe(ORB_ID(dataman_response)); - if (_dataman_response_sub < 0) { + if (!orb_sub_valid(_dataman_response_sub)) { PX4_ERR("Failed to subscribe (%i)", errno); } else { @@ -74,7 +74,7 @@ DatamanClient::DatamanClient() DatamanClient::~DatamanClient() { - if (_dataman_response_sub >= 0) { + if (orb_sub_valid(_dataman_response_sub)) { orb_unsubscribe(_dataman_response_sub); } } diff --git a/src/lib/dataman_client/DatamanClient.hpp b/src/lib/dataman_client/DatamanClient.hpp index 3fa6d8206505..4d6dbd12cbf4 100644 --- a/src/lib/dataman_client/DatamanClient.hpp +++ b/src/lib/dataman_client/DatamanClient.hpp @@ -32,6 +32,8 @@ ****************************************************************************/ #pragma once +#include + #include #include #include @@ -178,7 +180,7 @@ class DatamanClient Request _active_request{}; uint8_t _response_status{}; - int32_t _dataman_response_sub{}; + orb_sub_t _dataman_response_sub{}; uORB::Publication _dataman_request_pub{ORB_ID(dataman_request)}; px4_pollfd_struct_t _fds; diff --git a/src/modules/dataman/dataman.cpp b/src/modules/dataman/dataman.cpp index eb25328a5bf0..63f858d807af 100644 --- a/src/modules/dataman/dataman.cpp +++ b/src/modules/dataman/dataman.cpp @@ -655,9 +655,9 @@ task_main(int argc, char *argv[]) g_task_should_exit = false; uORB::Publication dataman_response_pub{ORB_ID(dataman_response)}; - const int dataman_request_sub = orb_subscribe(ORB_ID(dataman_request)); + const orb_sub_t dataman_request_sub = orb_subscribe(ORB_ID(dataman_request)); - if (dataman_request_sub < 0) { + if (orb_sub_valid(dataman_request_sub)) { PX4_ERR("Failed to subscribe (%i)", errno); }