mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-07-21 23:40:54 +08:00
uorb/flush: support flush operation
After you call orb_flush(), you can determine whether the flush is completed by listening to the POLLPRI event of fd and getting the event in orb_get_events. After calling orb_get_events, the flush events will be cleared. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
b0b4ac0f39
commit
a5516121e2
@ -229,6 +229,16 @@ int orb_get_state(int fd, FAR struct orb_state *state)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int orb_get_events(int fd, FAR unsigned int *events)
|
||||||
|
{
|
||||||
|
if (!events)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ioctl(fd, SNIOC_GET_EVENTS, (unsigned long)(uintptr_t)events);
|
||||||
|
}
|
||||||
|
|
||||||
int orb_check(int fd, FAR bool *updated)
|
int orb_check(int fd, FAR bool *updated)
|
||||||
{
|
{
|
||||||
return ioctl(fd, SNIOC_UPDATED, (unsigned long)(uintptr_t)updated);
|
return ioctl(fd, SNIOC_UPDATED, (unsigned long)(uintptr_t)updated);
|
||||||
@ -239,6 +249,11 @@ int orb_ioctl(int fd, int cmd, unsigned long arg)
|
|||||||
return ioctl(fd, cmd, arg);
|
return ioctl(fd, cmd, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int orb_flush(int fd)
|
||||||
|
{
|
||||||
|
return ioctl(fd, SNIOC_FLUSH, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int orb_set_interval(int fd, unsigned interval)
|
int orb_set_interval(int fd, unsigned interval)
|
||||||
{
|
{
|
||||||
return ioctl(fd, SNIOC_SET_INTERVAL, (unsigned long)interval);
|
return ioctl(fd, SNIOC_SET_INTERVAL, (unsigned long)interval);
|
||||||
|
@ -114,6 +114,8 @@ struct orb_handle_s
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define ORB_EVENT_FLUSH_COMPLETE SENSOR_EVENT_FLUSH_COMPLETE
|
||||||
|
|
||||||
#define ORB_SENSOR_PATH "/dev/uorb/"
|
#define ORB_SENSOR_PATH "/dev/uorb/"
|
||||||
#define ORB_USENSOR_PATH "/dev/usensor"
|
#define ORB_USENSOR_PATH "/dev/usensor"
|
||||||
#define ORB_PATH_MAX (NAME_MAX + 16)
|
#define ORB_PATH_MAX (NAME_MAX + 16)
|
||||||
@ -521,6 +523,23 @@ static inline int orb_copy(FAR const struct orb_metadata *meta,
|
|||||||
|
|
||||||
int orb_get_state(int fd, FAR struct orb_state *state);
|
int orb_get_state(int fd, FAR struct orb_state *state);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: orb_get_events
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get the events about the specify subscriber of topic.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* fd The fd returned from orb_advertise / orb_subscribe.
|
||||||
|
* events Pointer to events, type is unsigned int pointer.
|
||||||
|
* eg: ORB_EVENT_FLUSH_COMPLETE
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* -1 on error.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int orb_get_events(int fd, FAR unsigned int *events);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: orb_check
|
* Name: orb_check
|
||||||
*
|
*
|
||||||
@ -563,6 +582,27 @@ int orb_check(int fd, FAR bool *updated);
|
|||||||
|
|
||||||
int orb_ioctl(int fd, int cmd, unsigned long arg);
|
int orb_ioctl(int fd, int cmd, unsigned long arg);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: orb_flush
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* When topic data accumulates in the hardware buffer but does not reach
|
||||||
|
* the watermark, you can mmediately read the fifo data through the flush
|
||||||
|
* operation. You can call the flush operation at any time.
|
||||||
|
*
|
||||||
|
* After you call flush, you can determine whether the flush is completed
|
||||||
|
* by listening to the POLLPRI event of fd and getting the event in
|
||||||
|
* orb_get_events
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* fd A fd returned from orb_advertise / orb_subscribe.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 on success.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int orb_flush(int fd);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: orb_set_batch_interval
|
* Name: orb_set_batch_interval
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user