Zephyr API Documentation 4.0.99
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. | |
Enumerations | |
enum | pipe_flags { PIPE_FLAG_OPEN = BIT(0) , PIPE_FLAG_RESET = BIT(1) } |
Functions | |
void | k_pipe_init (struct k_pipe *pipe, uint8_t *buffer, size_t buffer_size) |
initialize a pipe | |
int | k_pipe_write (struct k_pipe *pipe, const uint8_t *data, size_t len, k_timeout_t timeout) |
Write data to a pipe. | |
int | k_pipe_read (struct k_pipe *pipe, uint8_t *data, size_t len, k_timeout_t timeout) |
Read data from a pipe This routine reads up to len bytes of data from pipe. | |
void | k_pipe_reset (struct k_pipe *pipe) |
Reset a pipe This routine resets the pipe, discarding any unread data and unblocking any threads waiting to write or read, causing the waiting threads to return with -ECANCELED. | |
void | k_pipe_close (struct k_pipe *pipe) |
Close a pipe. | |
#define K_PIPE_DEFINE | ( | name, | |
pipe_buffer_size, | |||
pipe_align ) |
#include <zephyr/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). |
pipe_align | Alignment of the pipe's ring buffer (power of 2). |
enum pipe_flags |
#include <zephyr/kernel.h>
Enumerator | |
---|---|
PIPE_FLAG_OPEN | |
PIPE_FLAG_RESET |
void k_pipe_close | ( | struct k_pipe * | pipe | ) |
#include <zephyr/kernel.h>
Close a pipe.
This routine closes a pipe. Any threads that were blocked on the pipe will be unblocked and receive an error code.
pipe | Address of the pipe. |
#include <zephyr/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 buffer. |
buffer_size | Size of the pipe's buffer. |
int k_pipe_read | ( | struct k_pipe * | pipe, |
uint8_t * | data, | ||
size_t | len, | ||
k_timeout_t | timeout ) |
#include <zephyr/kernel.h>
Read data from a pipe This routine reads up to len bytes of data from pipe.
If the pipe is empty, the routine will block until the data can be read or the timeout expires.
pipe | Address of the pipe. |
data | Address to place the data read from pipe. |
len | Requested number of bytes to read. |
timeout | Waiting period to wait for the data to be read. |
number | of bytes read on success |
-EAGAIN | if no data could be read before the timeout expired |
-ECANCELED | if the read was interrupted by k_pipe_reset(..) |
-EPIPE | if the pipe was closed |
void k_pipe_reset | ( | struct k_pipe * | pipe | ) |
#include <zephyr/kernel.h>
Reset a pipe This routine resets the pipe, discarding any unread data and unblocking any threads waiting to write or read, causing the waiting threads to return with -ECANCELED.
Calling k_pipe_read(..) or k_pipe_write(..) when the pipe is resetting but not yet reset will return -ECANCELED. The pipe is left open after a reset and can be used as normal.
pipe | Address of the pipe. |
int k_pipe_write | ( | struct k_pipe * | pipe, |
const uint8_t * | data, | ||
size_t | len, | ||
k_timeout_t | timeout ) |
#include <zephyr/kernel.h>
Write data to a pipe.
This routine writes up to len bytes of data to pipe. If the pipe is full, the routine will block until the data can be written or the timeout expires.
pipe | Address of the pipe. |
data | Address of data to write. |
len | Size of data (in bytes). |
timeout | Waiting period to wait for the data to be written. |
number | of bytes written on success |
-EAGAIN | if no data could be written before the timeout expired |
-ECANCELED | if the write was interrupted by k_pipe_reset(..) |
-EPIPE | if the pipe was closed |