Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve uorb subscription interval handling #648

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions platforms/common/uORB/SubscriptionCallback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ class SubscriptionPollable : public SubscriptionInterval
* Constructor
*
* @param meta The uORB metadata (usually from the ORB_ID() macro) for the topic.
* @param interval The requested maximum update interval in microseconds.
* @param instance The instance for multi sub.
*/
SubscriptionPollable(const orb_metadata *meta, uint8_t instance = 0) :
SubscriptionInterval(meta, 0, instance)
SubscriptionPollable(const orb_metadata *meta, uint32_t interval_us = 0, uint8_t instance = 0) :
SubscriptionInterval(meta, interval_us, instance)
{
}

Expand Down
4 changes: 3 additions & 1 deletion platforms/common/uORB/SubscriptionInterval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SubscriptionInterval
*/
SubscriptionInterval(ORB_ID id, uint32_t interval_us = 0, uint8_t instance = 0) :
_subscription{id, instance},
_last_update(hrt_absolute_time() - interval_us),
_interval_us(interval_us)
{}

Expand All @@ -74,6 +75,7 @@ class SubscriptionInterval
*/
SubscriptionInterval(const orb_metadata *meta, uint32_t interval_us = 0, uint8_t instance = 0) :
_subscription{meta, instance},
_last_update(hrt_absolute_time() - interval_us),
_interval_us(interval_us)
{}

Expand Down Expand Up @@ -140,7 +142,7 @@ class SubscriptionInterval
* Set the interval in microseconds
* @param interval The interval in microseconds.
*/
void set_interval_us(uint32_t interval) { _interval_us = interval; }
void set_interval_us(uint32_t interval) { _interval_us = interval; _last_update = hrt_absolute_time() - interval; }

/**
* Set the interval in milliseconds
Expand Down
2 changes: 1 addition & 1 deletion platforms/common/uORB/uORBManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ orb_sub_t uORB::Manager::orb_subscribe(const struct orb_metadata *meta)
// Should only be called from old interface
orb_sub_t uORB::Manager::orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance)
{
uORB::SubscriptionInterval *sub = new uORB::SubscriptionPollable(meta, instance);
uORB::SubscriptionInterval *sub = new uORB::SubscriptionPollable(meta, 0, instance);

if (sub && !sub->valid()) {
// subscribe and advertise the topic
Expand Down
Loading