mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 17:43:34 +08:00
Subscription & SubscriptionArray: add forcedUpdate() methods
Can be used to immediately get & use the data, as needed for the flight tasks.
This commit is contained in:
@@ -125,13 +125,18 @@ public:
|
||||
*/
|
||||
virtual bool update() = 0;
|
||||
|
||||
/**
|
||||
* Like update(), but does not check first if there is data available
|
||||
*/
|
||||
virtual bool forcedUpdate() = 0;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Subscription wrapper class
|
||||
*/
|
||||
template<class T>
|
||||
class __EXPORT Subscription final : public SubscriptionNode
|
||||
class __EXPORT Subscription : public SubscriptionNode
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -150,7 +155,7 @@ public:
|
||||
_data() // initialize data structure to zero
|
||||
{}
|
||||
|
||||
~Subscription() override final = default;
|
||||
~Subscription() override = default;
|
||||
|
||||
// no copy, assignment, move, move assignment
|
||||
Subscription(const Subscription &) = delete;
|
||||
@@ -161,11 +166,16 @@ public:
|
||||
/**
|
||||
* Create an update function that uses the embedded struct.
|
||||
*/
|
||||
bool update() override final
|
||||
bool update() override
|
||||
{
|
||||
return SubscriptionBase::update((void *)(&_data));
|
||||
}
|
||||
|
||||
bool forcedUpdate() override
|
||||
{
|
||||
return orb_copy(_meta, _handle, &_data) == PX4_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function gets the T struct data
|
||||
* */
|
||||
|
||||
Reference in New Issue
Block a user