summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/drivers/include/rtdevice.h2
-rw-r--r--components/drivers/src/pipe.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index 60d4dc1e8a..8ed9f34ca4 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -114,6 +114,8 @@ struct rt_pipe_device
struct rt_portal_device *read_portal;
};
+#define PIPE_CTRL_GET_SPACE 0x14 /**< get the remaining size of a pipe device */
+
#define RT_DATAQUEUE_EVENT_UNKNOWN 0x00
#define RT_DATAQUEUE_EVENT_POP 0x01
#define RT_DATAQUEUE_EVENT_PUSH 0x02
diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c
index 8a6c97aabf..f438a92898 100644
--- a/components/drivers/src/pipe.c
+++ b/components/drivers/src/pipe.c
@@ -190,6 +190,8 @@ static rt_size_t rt_pipe_write(rt_device_t dev,
static rt_err_t rt_pipe_control(rt_device_t dev, rt_uint8_t cmd, void *args)
{
+ if (cmd == PIPE_CTRL_GET_SPACE && args)
+ *(rt_size_t*)args = rt_ringbuffer_space_len(&PIPE_DEVICE(dev)->ringbuffer);
return RT_EOK;
}