mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08: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:
parent
6cf55ac83a
commit
d38dfcfcd3
@ -75,7 +75,22 @@ public:
|
||||
void unsubscribe();
|
||||
|
||||
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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user