mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-18 17:30:36 +08:00
uORB::Subscription subscribe directly to uORB device node object
This commit is contained in:
@@ -195,6 +195,42 @@ public:
|
||||
int get_priority() const { return _priority; }
|
||||
void set_priority(uint8_t priority) { _priority = priority; }
|
||||
|
||||
/**
|
||||
* Copies the timestamp of the last update atomically.
|
||||
*
|
||||
* @return uint64_t
|
||||
* Returns the timestamp of the most recent data.
|
||||
*/
|
||||
hrt_abstime last_update();
|
||||
|
||||
/**
|
||||
* Copies data and the corresponding generation
|
||||
* from a node to the buffer provided.
|
||||
*
|
||||
* @param dst
|
||||
* The buffer into which the data is copied.
|
||||
* @param generation
|
||||
* The generation that was copied.
|
||||
* @return bool
|
||||
* Returns true if the data was copied.
|
||||
*/
|
||||
bool copy(void *dst, unsigned &generation);
|
||||
|
||||
/**
|
||||
* Copies data and the corresponding generation
|
||||
* from a node to the buffer provided.
|
||||
*
|
||||
* @param dst
|
||||
* The buffer into which the data is copied.
|
||||
* If topic was not updated since last check it will return false but
|
||||
* still copy the data.
|
||||
* @param generation
|
||||
* The generation that was copied.
|
||||
* @return uint64_t
|
||||
* Returns the timestamp of the copied data.
|
||||
*/
|
||||
uint64_t copy_and_get_timestamp(void *dst, unsigned &generation);
|
||||
|
||||
protected:
|
||||
|
||||
pollevent_t poll_state(cdev::file_t *filp) override;
|
||||
@@ -203,6 +239,19 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Copies data and the corresponding generation
|
||||
* from a node to the buffer provided. Caller handles locking.
|
||||
*
|
||||
* @param dst
|
||||
* The buffer into which the data is copied.
|
||||
* @param generation
|
||||
* The generation that was copied.
|
||||
* @return bool
|
||||
* Returns true if the data was copied.
|
||||
*/
|
||||
bool copy_locked(void *dst, unsigned &generation);
|
||||
|
||||
struct UpdateIntervalData {
|
||||
uint64_t last_update{0}; /**< time at which the last update was provided, used when update_interval is nonzero */
|
||||
unsigned interval{0}; /**< if nonzero minimum interval between updates */
|
||||
|
||||
Reference in New Issue
Block a user