Skip to content
Snippets Groups Projects
Verified Commit 13386d1a authored by rahix's avatar rahix
Browse files

docs: Improve stream documentation


Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 6a5ae34e
No related branches found
No related tags found
No related merge requests found
...@@ -68,11 +68,18 @@ API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b)); ...@@ -68,11 +68,18 @@ API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b));
/** /**
* Read sensor data into a buffer. ``epic_stream_read()`` will read as many * Read sensor data into a buffer. ``epic_stream_read()`` will read as many
* sensor data packets as possible into ``buf`` and return as soon as possible. * sensor samples into the provided buffer as possible and return the number of
* It will poke the sensor driver once to check whether new data can be fetched. * samples written. If no samples are available, ``epic_stream_read()`` will
* If there is no new sensor data, ``epic_stream_read()`` will return ``0`` and * return ``0`` immediately.
* not touch ``buf``. Otherwise it will return the number of data packets which *
* were read into ``buf``. * ``epic_stream_read()`` expects the provided buffer to have a size which is a
* multiple of the sample size for the given stream. For the sample-format and
* size, please consult the sensors documentation.
*
* Before reading the internal sensor sample queue, ``epic_stream_read()`` will
* call a sensor specific *poll* function to allow the sensor driver to fetch
* new samples from its hardware. This should, however, never take a long
* amount of time.
* *
* :param int sd: Sensor Descriptor. You get sensor descriptors as return * :param int sd: Sensor Descriptor. You get sensor descriptors as return
* values when activating the respective sensors. * values when activating the respective sensors.
...@@ -84,8 +91,7 @@ API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b)); ...@@ -84,8 +91,7 @@ API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b));
* *
* - ``-ENODEV``: Sensor is not currently available. * - ``-ENODEV``: Sensor is not currently available.
* - ``-EBADF``: The given sensor descriptor is unknown. * - ``-EBADF``: The given sensor descriptor is unknown.
* - ``-EINVAL``: If ``count`` is not a multiple of the sensor data packet * - ``-EINVAL``: ``count`` is not a multiple of the sensor's sample size.
* size.
* *
* **Example**: * **Example**:
* *
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "queue.h" #include "queue.h"
#define STREAM_QUEUE_WAIT pdMS_TO_TICKS(10)
/** /**
* **Stream Descriptors**: * **Stream Descriptors**:
* *
...@@ -38,11 +36,14 @@ struct stream_info { ...@@ -38,11 +36,14 @@ struct stream_info {
/** The size of one data packet (= queue element). */ /** The size of one data packet (= queue element). */
size_t item_size; size_t item_size;
/** /**
* An optional function to call before performing the read. * An optional function to call before performing the read. Set to
* ``NULL`` if unused.
* *
* ``poll_stream()`` is intended for sensors who passively collect data. * ``poll_stream()`` is intended for sensors who passively collect data.
* A sensor driver might for example retrieve the latest samples in this * A sensor driver might for example retrieve the latest samples in this
* function instead of actively polling in a task loop. * function instead of actively polling in a task loop.
*
* The function registered here should never block for a longer time.
*/ */
int (*poll_stream)(); int (*poll_stream)();
}; };
...@@ -50,7 +51,7 @@ struct stream_info { ...@@ -50,7 +51,7 @@ struct stream_info {
/** /**
* Register a stream so it can be read from Epicardium API. * Register a stream so it can be read from Epicardium API.
* *
* :param int sd: Stream Descriptor. Must be from the above enum. * :param int sd: Stream Descriptor. Must be from the :c:type:`stream_descriptor` enum.
* :param stream_info stream: Stream info. * :param stream_info stream: Stream info.
* :returns: ``0`` on success or a negative value on error. Possible errors: * :returns: ``0`` on success or a negative value on error. Possible errors:
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment