mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 01:51:35 +08:00
mavlink: MavlinkOrbSubscription.update() result fixed
This commit is contained in:
@@ -78,12 +78,15 @@ MavlinkOrbSubscription::get_data()
|
|||||||
bool
|
bool
|
||||||
MavlinkOrbSubscription::update(const hrt_abstime t)
|
MavlinkOrbSubscription::update(const hrt_abstime t)
|
||||||
{
|
{
|
||||||
if (_last_check != t) {
|
if (_last_check == t) {
|
||||||
_last_check = t;
|
/* already checked right now, return result of the check */
|
||||||
bool updated;
|
return _updated;
|
||||||
orb_check(_fd, &updated);
|
|
||||||
|
|
||||||
if (updated) {
|
} else {
|
||||||
|
_last_check = t;
|
||||||
|
orb_check(_fd, &_updated);
|
||||||
|
|
||||||
|
if (_updated) {
|
||||||
orb_copy(_topic, _fd, _data);
|
orb_copy(_topic, _fd, _data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
class MavlinkOrbSubscription
|
class MavlinkOrbSubscription
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MavlinkOrbSubscription *next;
|
MavlinkOrbSubscription *next; /*< pointer to next subscription in list */
|
||||||
|
|
||||||
MavlinkOrbSubscription(const orb_id_t topic);
|
MavlinkOrbSubscription(const orb_id_t topic);
|
||||||
~MavlinkOrbSubscription();
|
~MavlinkOrbSubscription();
|
||||||
@@ -66,11 +66,12 @@ public:
|
|||||||
const orb_id_t get_topic();
|
const orb_id_t get_topic();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const orb_id_t _topic;
|
const orb_id_t _topic; /*< topic metadata */
|
||||||
int _fd;
|
int _fd; /*< subscription handle */
|
||||||
bool _published;
|
bool _published; /*< topic was ever published */
|
||||||
void *_data;
|
void *_data; /*< pointer to data buffer */
|
||||||
hrt_abstime _last_check;
|
hrt_abstime _last_check; /*< time of last check */
|
||||||
|
bool _updated; /*< updated on last check */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user