|
Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Data Structures | |
| struct | k_pipe |
Macros | |
| #define | K_PIPE_DEFINE(name, pipe_buffer_size, pipe_align) |
| Statically define and initialize a pipe. More... | |
Functions | |
| void | k_pipe_init (struct k_pipe *pipe, unsigned char *buffer, size_t size) |
| Initialize a pipe. More... | |
| int | k_pipe_cleanup (struct k_pipe *pipe) |
| Release a pipe's allocated buffer. More... | |
| int | k_pipe_alloc_init (struct k_pipe *pipe, size_t size) |
| Initialize a pipe and allocate a buffer for it. More... | |
| int | k_pipe_put (struct k_pipe *pipe, void *data, size_t bytes_to_write, size_t *bytes_written, size_t min_xfer, k_timeout_t timeout) |
| Write data to a pipe. More... | |
| int | k_pipe_get (struct k_pipe *pipe, void *data, size_t bytes_to_read, size_t *bytes_read, size_t min_xfer, k_timeout_t timeout) |
| Read data from a pipe. More... | |
| size_t | k_pipe_read_avail (struct k_pipe *pipe) |
| Query the number of bytes that may be read from pipe. More... | |
| size_t | k_pipe_write_avail (struct k_pipe *pipe) |
| Query the number of bytes that may be written to pipe. More... | |
| #define K_PIPE_DEFINE | ( | name, | |
| pipe_buffer_size, | |||
| pipe_align | |||
| ) |
#include <include/kernel.h>
Statically define and initialize a pipe.
The pipe can be accessed outside the module where it is defined using:
| name | Name of the pipe. |
| pipe_buffer_size | Size of the pipe's ring buffer (in bytes), or zero if no ring buffer is used. |
| pipe_align | Alignment of the pipe's ring buffer (power of 2). |
| int k_pipe_alloc_init | ( | struct k_pipe * | pipe, |
| size_t | size | ||
| ) |
#include <include/kernel.h>
Initialize a pipe and allocate a buffer for it.
Storage for the buffer region will be allocated from the calling thread's resource pool. This memory will be released if k_pipe_cleanup() is called, or userspace is enabled and the pipe object loses all references to it.
This function should only be called on uninitialized pipe objects.
| pipe | Address of the pipe. |
| size | Size of the pipe's ring buffer (in bytes), or zero if no ring buffer is used. |
| 0 | on success |
| -ENOMEM | if memory couldn't be allocated |
| int k_pipe_cleanup | ( | struct k_pipe * | pipe | ) |
#include <include/kernel.h>
Release a pipe's allocated buffer.
If a pipe object was given a dynamically allocated buffer via k_pipe_alloc_init(), this will free it. This function does nothing if the buffer wasn't dynamically allocated.
| pipe | Address of the pipe. |
| 0 | on success |
| -EAGAIN | nothing to cleanup |
| int k_pipe_get | ( | struct k_pipe * | pipe, |
| void * | data, | ||
| size_t | bytes_to_read, | ||
| size_t * | bytes_read, | ||
| size_t | min_xfer, | ||
| k_timeout_t | timeout | ||
| ) |
#include <include/kernel.h>
Read data from a pipe.
This routine reads up to bytes_to_read bytes of data from pipe.
| pipe | Address of the pipe. |
| data | Address to place the data read from pipe. |
| bytes_to_read | Maximum number of data bytes to read. |
| bytes_read | Address of area to hold the number of bytes read. |
| min_xfer | Minimum number of data bytes to read. |
| timeout | Waiting period to wait for the data to be read, or one of the special values K_NO_WAIT and K_FOREVER. |
| 0 | At least min_xfer bytes of data were read. |
| -EINVAL | invalid parameters supplied |
| -EIO | Returned without waiting; zero data bytes were read. |
| -EAGAIN | Waiting period timed out; between zero and min_xfer minus one data bytes were read. |
#include <include/kernel.h>
Initialize a pipe.
This routine initializes a pipe object, prior to its first use.
| pipe | Address of the pipe. |
| buffer | Address of the pipe's ring buffer, or NULL if no ring buffer is used. |
| size | Size of the pipe's ring buffer (in bytes), or zero if no ring buffer is used. |
| int k_pipe_put | ( | struct k_pipe * | pipe, |
| void * | data, | ||
| size_t | bytes_to_write, | ||
| size_t * | bytes_written, | ||
| size_t | min_xfer, | ||
| k_timeout_t | timeout | ||
| ) |
#include <include/kernel.h>
Write data to a pipe.
This routine writes up to bytes_to_write bytes of data to pipe.
| pipe | Address of the pipe. |
| data | Address of data to write. |
| bytes_to_write | Size of data (in bytes). |
| bytes_written | Address of area to hold the number of bytes written. |
| min_xfer | Minimum number of bytes to write. |
| timeout | Waiting period to wait for the data to be written, or one of the special values K_NO_WAIT and K_FOREVER. |
| 0 | At least min_xfer bytes of data were written. |
| -EIO | Returned without waiting; zero data bytes were written. |
| -EAGAIN | Waiting period timed out; between zero and min_xfer minus one data bytes were written. |
| size_t k_pipe_read_avail | ( | struct k_pipe * | pipe | ) |
#include <include/kernel.h>
Query the number of bytes that may be read from pipe.
| pipe | Address of the pipe. |
| a | number n such that 0 <= n <= k_pipe::size; the result is zero for unbuffered pipes. |
| size_t k_pipe_write_avail | ( | struct k_pipe * | pipe | ) |
#include <include/kernel.h>
Query the number of bytes that may be written to pipe.
| pipe | Address of the pipe. |
| a | number n such that 0 <= n <= k_pipe::size; the result is zero for unbuffered pipes. |