From 2cb698f01faa12682020ed1f68a6e846c9016efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 19 Jan 2018 11:48:12 +0100 Subject: [PATCH] uORBDevices: set the priority when advertising a node that's already subscribed This fixes the case where a topic instance is already subscribed, and advertised later. The subscriber will create the DeviceNode with default priority, and the advertiser will just use the existing DeviceNode, without updating to the requested priority. --- src/modules/uORB/uORBDevices.cpp | 1 + src/modules/uORB/uORBDevices.hpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/uORB/uORBDevices.cpp b/src/modules/uORB/uORBDevices.cpp index 1a59e0f4f3..5a88d366e2 100644 --- a/src/modules/uORB/uORBDevices.cpp +++ b/src/modules/uORB/uORBDevices.cpp @@ -927,6 +927,7 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg) if ((existing_node != nullptr) && !(existing_node->is_published())) { /* nothing has been published yet, lets claim it */ + existing_node->set_priority(adv->priority); ret = PX4_OK; } else { diff --git a/src/modules/uORB/uORBDevices.hpp b/src/modules/uORB/uORBDevices.hpp index 2625330c23..d92886898c 100644 --- a/src/modules/uORB/uORBDevices.hpp +++ b/src/modules/uORB/uORBDevices.hpp @@ -185,6 +185,8 @@ public: unsigned int published_message_count() const { return _generation; } const struct orb_metadata *get_meta() const { return _meta; } + void set_priority(uint8_t priority) { _priority = priority; } + protected: virtual pollevent_t poll_state(device::file_t *filp); virtual void poll_notify_one(px4_pollfd_struct_t *fds, pollevent_t events); @@ -215,7 +217,7 @@ private: uint8_t *_data; /**< allocated object buffer */ hrt_abstime _last_update; /**< time the object was last updated */ volatile unsigned _generation; /**< object generation count */ - const uint8_t _priority; /**< priority of the topic */ + uint8_t _priority; /**< priority of the topic */ bool _published; /**< has ever data been published */ uint8_t _queue_size; /**< maximum number of elements in the queue */ int16_t _subscriber_count;