From 2fe5e7735a243ddcd4557d7d5f7b6dea9c7c895f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 16 Jul 2018 09:38:56 +0200 Subject: [PATCH] uorb: allow an orb subscription to retrieve data that was published prior to subscribe --- src/modules/uORB/uORBDevices.cpp | 9 ++------- src/modules/uORB/uORBManager.hpp | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/modules/uORB/uORBDevices.cpp b/src/modules/uORB/uORBDevices.cpp index 00ae985d5e..98aaa5f960 100644 --- a/src/modules/uORB/uORBDevices.cpp +++ b/src/modules/uORB/uORBDevices.cpp @@ -146,13 +146,8 @@ uORB::DeviceNode::open(device::file_t *filp) return -ENOMEM; } - /* If queue size >1, allow the subscriber to read the data in the queue. Otherwise, assume subscriber is up to date.*/ - if (_queue_size <= 1) { - sd->generation = _generation; - - } else { - sd->generation = _generation - (_queue_size < _generation ? _queue_size : _generation); - } + /* If there were any previous publications, allow the subscriber to read them */ + sd->generation = _generation - (_queue_size < _generation ? _queue_size : _generation); /* set priority */ sd->set_priority(_priority); diff --git a/src/modules/uORB/uORBManager.hpp b/src/modules/uORB/uORBManager.hpp index 0c730aae68..16545dc95c 100644 --- a/src/modules/uORB/uORBManager.hpp +++ b/src/modules/uORB/uORBManager.hpp @@ -186,6 +186,9 @@ public: * in order to wait for updates to a topic, as well as topic_read, * orb_check and orb_stat. * + * If there were any publications of the topic prior to the subscription, + * an orb_check right after orb_subscribe will return true. + * * Subscription will succeed even if the topic has not been advertised; * in this case the topic will have a timestamp of zero, it will never * signal a poll() event, checking will always return false and it cannot @@ -213,6 +216,9 @@ public: * in order to wait for updates to a topic, as well as topic_read, * orb_check and orb_stat. * + * If there were any publications of the topic prior to the subscription, + * an orb_check right after orb_subscribe_multi will return true. + * * Subscription will succeed even if the topic has not been advertised; * in this case the topic will have a timestamp of zero, it will never * signal a poll() event, checking will always return false and it cannot