mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
uORB::Subscription fix initialization but not yet published case
- otherwise uORB::Subscription will erroneously report published after the first successful initialization of an unpublished topic
This commit is contained in:
@@ -75,7 +75,22 @@ public:
|
|||||||
void unsubscribe();
|
void unsubscribe();
|
||||||
|
|
||||||
bool valid() const { return _node != nullptr; }
|
bool valid() const { return _node != nullptr; }
|
||||||
bool published() { return valid() ? _node->is_published() : init(); }
|
bool published()
|
||||||
|
{
|
||||||
|
if (valid()) {
|
||||||
|
return _node->is_published();
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to initialize
|
||||||
|
if (init()) {
|
||||||
|
// check again if valid
|
||||||
|
if (valid()) {
|
||||||
|
return _node->is_published();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if there is a new update.
|
* Check if there is a new update.
|
||||||
|
|||||||
Reference in New Issue
Block a user