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:
Daniel Agar 2019-08-20 10:28:09 -04:00 committed by GitHub
parent 6cf55ac83a
commit d38dfcfcd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.