mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 06:53:33 +08:00
orb: add orb_get_interval to API
This commit is contained in:
@@ -90,4 +90,7 @@
|
||||
/** Set the queue size of the topic */
|
||||
#define ORBIOCSETQUEUESIZE _ORBIOC(15)
|
||||
|
||||
/** Get the minimum interval at which the topic can be seen to be updated for this subscription */
|
||||
#define ORBIOCGETINTERVAL _ORBIOC(16)
|
||||
|
||||
#endif /* _DRV_UORB_H */
|
||||
|
||||
@@ -140,8 +140,12 @@ int orb_priority(int handle, int32_t *priority)
|
||||
return uORB::Manager::get_instance()->orb_priority(handle, priority);
|
||||
}
|
||||
|
||||
int orb_set_interval(int handle, unsigned interval)
|
||||
int orb_set_interval(int handle, unsigned interval)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_set_interval(handle, interval);
|
||||
}
|
||||
|
||||
int orb_get_interval(int handle, unsigned *interval)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_get_interval(handle, interval);
|
||||
}
|
||||
|
||||
@@ -232,6 +232,11 @@ extern int orb_priority(int handle, int32_t *priority) __EXPORT;
|
||||
*/
|
||||
extern int orb_set_interval(int handle, unsigned interval) __EXPORT;
|
||||
|
||||
/**
|
||||
* @see uORB::Manager::orb_get_interval()
|
||||
*/
|
||||
extern int orb_get_interval(int handle, unsigned *interval) __EXPORT;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
/* Diverse uORB header defines */ //XXX: move to better location
|
||||
|
||||
@@ -311,6 +311,10 @@ uORB::DeviceNode::ioctl(struct file *filp, int cmd, unsigned long arg)
|
||||
//and only one advertiser is allowed to open the DeviceNode at the same time.
|
||||
return update_queue_size(arg);
|
||||
|
||||
case ORBIOCGETINTERVAL:
|
||||
*(unsigned *)arg = sd->update_interval;
|
||||
return OK;
|
||||
|
||||
default:
|
||||
/* give it to the superclass */
|
||||
return CDev::ioctl(filp, cmd, arg);
|
||||
|
||||
@@ -326,6 +326,10 @@ uORB::DeviceNode::ioctl(device::file_t *filp, int cmd, unsigned long arg)
|
||||
//and only one advertiser is allowed to open the DeviceNode at the same time.
|
||||
return update_queue_size(arg);
|
||||
|
||||
case ORBIOCGETINTERVAL:
|
||||
*(unsigned *)arg = sd->update_interval;
|
||||
return OK;
|
||||
|
||||
default:
|
||||
/* give it to the superclass */
|
||||
return VDev::ioctl(filp, cmd, arg);
|
||||
|
||||
@@ -204,6 +204,14 @@ int uORB::Manager::orb_set_interval(int handle, unsigned interval)
|
||||
return px4_ioctl(handle, ORBIOCSETINTERVAL, interval * 1000);
|
||||
}
|
||||
|
||||
int uORB::Manager::orb_get_interval(int handle, unsigned *interval)
|
||||
{
|
||||
ASSERT(interval);
|
||||
int ret = px4_ioctl(handle, ORBIOCGETINTERVAL, (unsigned long)interval);
|
||||
*interval /= 1000;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int uORB::Manager::node_advertise
|
||||
(
|
||||
|
||||
@@ -327,6 +327,18 @@ public:
|
||||
*/
|
||||
int orb_set_interval(int handle, unsigned interval) ;
|
||||
|
||||
|
||||
/**
|
||||
* Get the minimum interval between which updates are seen for a subscription.
|
||||
*
|
||||
* @see orb_set_interval()
|
||||
*
|
||||
* @param handle A handle returned from orb_subscribe.
|
||||
* @param interval The returned interval period in milliseconds.
|
||||
* @return OK on success, ERROR otherwise with ERRNO set accordingly.
|
||||
*/
|
||||
int orb_get_interval(int handle, unsigned *interval);
|
||||
|
||||
/**
|
||||
* Method to set the uORBCommunicator::IChannel instance.
|
||||
* @param comm_channel
|
||||
|
||||
Reference in New Issue
Block a user