Xenomai
3.1
|
Two-way communication channel between Xenomai & Linux domains. More...
Macros | |
#define | P_MINOR_AUTO XNPIPE_MINOR_AUTO |
Creation flags. More... | |
#define | P_URGENT XNPIPE_URGENT |
Operation flags. More... | |
Functions | |
int | rt_pipe_delete (RT_PIPE *pipe) |
Delete a message pipe. More... | |
ssize_t | rt_pipe_read_timed (RT_PIPE *pipe, void *buf, size_t size, const struct timespec *abs_timeout) |
Read a message from a pipe. More... | |
static ssize_t | rt_pipe_read_until (RT_PIPE *pipe, void *buf, size_t size, RTIME timeout) |
Read from a pipe (with absolute scalar timeout). More... | |
static ssize_t | rt_pipe_read (RT_PIPE *pipe, void *buf, size_t size, RTIME timeout) |
Read from a pipe (with relative scalar timeout). More... | |
ssize_t | rt_pipe_write (RT_PIPE *pipe, const void *buf, size_t size, int mode) |
Write a message to a pipe. More... | |
ssize_t | rt_pipe_stream (RT_PIPE *pipe, const void *buf, size_t size) |
Stream bytes through a pipe. More... | |
int | rt_pipe_bind (RT_PIPE *pipe, const char *name, RTIME timeout) |
Bind to a message pipe. More... | |
int | rt_pipe_unbind (RT_PIPE *pipe) |
Unbind from a message pipe. More... | |
int | rt_pipe_create (RT_PIPE *pipe, const char *name, int minor, size_t poolsize) |
Create a message pipe. More... | |
Two-way communication channel between Xenomai & Linux domains.
A message pipe is a two-way communication channel between Xenomai threads and normal Linux threads using regular file I/O operations on a pseudo-device. Pipes can be operated in a message-oriented fashion so that message boundaries are preserved, and also in byte-oriented streaming mode from real-time to normal Linux threads for optimal throughput.
Xenomai threads open their side of the pipe using the rt_pipe_create() service; regular Linux threads do the same by opening one of the /dev/rtpN special devices, where N is the minor number agreed upon between both ends of each pipe.
In addition, named pipes are available through the registry support, which automatically creates a symbolic link from entries under /proc/xenomai/registry/rtipc/xddp/ to the corresponding special device file.
#define P_MINOR_AUTO XNPIPE_MINOR_AUTO |
Creation flags.
#define P_URGENT XNPIPE_URGENT |
Operation flags.
int rt_pipe_bind | ( | RT_PIPE * | pipe, |
const char * | name, | ||
RTIME | timeout | ||
) |
Bind to a message pipe.
This routine creates a new descriptor to refer to an existing message pipe identified by its symbolic name. If the object does not exist on entry, the caller may block until a pipe of the given name is created.
pipe | The address of a pipe descriptor filled in by the operation. Contents of this memory is undefined upon failure. |
name | A valid NULL-terminated name which identifies the pipe to bind to. This string should match the object name argument passed to rt_pipe_create(). |
timeout | The number of clock ticks to wait for the registration to occur (see note). Passing TM_INFINITE causes the caller to block indefinitely until the object is registered. Passing TM_NONBLOCK causes the service to return immediately without waiting if the object is not registered on entry. |
int rt_pipe_create | ( | RT_PIPE * | pipe, |
const char * | name, | ||
int | minor, | ||
size_t | poolsize | ||
) |
Create a message pipe.
This service opens a bi-directional communication channel for exchanging messages between Xenomai threads and regular Linux threads. Pipes natively preserve message boundaries, but can also be used in byte-oriented streaming mode from Xenomai to Linux.
rt_pipe_create() always returns immediately, even if no thread has opened the associated special device file yet. On the contrary, the non real-time side could block upon attempt to open the special device file until rt_pipe_create() is issued on the same pipe from a Xenomai thread, unless O_NONBLOCK was given to the open(2) system call.
pipe | The address of a pipe descriptor which can be later used to identify uniquely the created object, upon success of this call. |
name | An ASCII string standing for the symbolic name of the pipe. When non-NULL and non-empty, a copy of this string is used for indexing the created pipe into the object registry. |
Named pipes are supported through the use of the registry. Passing a valid name parameter when creating a message pipe causes a symbolic link to be created from /proc/xenomai/registry/rtipc/xddp/name to the associated special device (i.e. /dev/rtp*), so that the specific minor information does not need to be known from those processes for opening the proper device file. In such a case, both sides of the pipe only need to agree upon a symbolic name to refer to the same data path, which is especially useful whenever the minor number is picked up dynamically using an adaptive algorithm, such as passing P_MINOR_AUTO as minor value.
minor | The minor number of the device associated with the pipe. Passing P_MINOR_AUTO causes the minor number to be auto-allocated. In such a case, a symbolic link will be automatically created from /proc/xenomai/registry/rtipc/xddp/name to the allocated pipe device entry. Valid minor numbers range from 0 to CONFIG_XENO_OPT_PIPE_NRDEV-1. |
poolsize | Specifies the size of a dedicated buffer pool for the pipe. Passing 0 means that all message allocations for this pipe are performed on the Cobalt core heap. |
int rt_pipe_delete | ( | RT_PIPE * | pipe | ) |
Delete a message pipe.
This routine deletes a pipe object previously created by a call to rt_pipe_create(). All resources attached to that pipe are automatically released, all pending data is flushed.
pipe | The pipe descriptor. |
|
inlinestatic |
Read from a pipe (with relative scalar timeout).
This routine is a variant of rt_queue_read_timed() accepting a relative timeout specification expressed as a scalar value.
pipe | The pipe descriptor. |
buf | A pointer to a memory area which will be written upon success with the message received. |
size | The count of bytes from the received message to read up into buf. If size is lower than the actual message size, -ENOBUFS is returned since the incompletely received message would be lost. If size is zero, this call returns immediately with no other action. |
timeout | A delay expressed in clock ticks. Passing TM_INFINITE causes the caller to block indefinitely until a message is available. Passing TM_NONBLOCK causes the service to return immediately without blocking in case no message is available. |
ssize_t rt_pipe_read_timed | ( | RT_PIPE * | pipe, |
void * | buf, | ||
size_t | size, | ||
const struct timespec * | abs_timeout | ||
) |
Read a message from a pipe.
This service reads the next available message from a given pipe.
pipe | The pipe descriptor. |
buf | A pointer to a memory area which will be written upon success with the message received. |
size | The count of bytes from the received message to read up into buf. If size is lower than the actual message size, -ENOBUFS is returned since the incompletely received message would be lost. If size is zero, this call returns immediately with no other action. |
abs_timeout | An absolute date expressed in clock ticks, specifying a time limit to wait for a message to be available from the pipe (see note). Passing NULL causes the caller to block indefinitely until a message is available. Passing { .tv_sec = 0, .tv_nsec = 0 } causes the service to return immediately without blocking in case no message is available. |
|
inlinestatic |
Read from a pipe (with absolute scalar timeout).
This routine is a variant of rt_queue_read_timed() accepting an absolute timeout specification expressed as a scalar value.
pipe | The pipe descriptor. |
buf | A pointer to a memory area which will be written upon success with the message received. |
size | The count of bytes from the received message to read up into buf. If size is lower than the actual message size, -ENOBUFS is returned since the incompletely received message would be lost. If size is zero, this call returns immediately with no other action. |
abs_timeout | An absolute date expressed in clock ticks. Passing TM_INFINITE causes the caller to block indefinitely until a message is available. Passing TM_NONBLOCK causes the service to return immediately without blocking in case no message is available. |
ssize_t rt_pipe_stream | ( | RT_PIPE * | pipe, |
const void * | buf, | ||
size_t | size | ||
) |
Stream bytes through a pipe.
This service writes a sequence of bytes to be received from the associated special device. Unlike rt_pipe_send(), this service does not preserve message boundaries. Instead, an internal buffer is filled on the fly with the data, which will be consumed as soon as the receiver wakes up.
Data buffers sent by the rt_pipe_stream() service are always transmitted in FIFO order (i.e. P_NORMAL mode).
pipe | The pipe descriptor. |
buf | The address of the first data byte to send. The data will be copied to an internal buffer before transmission. |
size | The size in bytes of the buffer. Zero is a valid value, in which case the service returns immediately without sending any data. |
int rt_pipe_unbind | ( | RT_PIPE * | pipe | ) |
Unbind from a message pipe.
pipe | The pipe descriptor. |
This routine releases a previous binding to a message pipe. After this call has returned, the descriptor is no more valid for referencing this object.
ssize_t rt_pipe_write | ( | RT_PIPE * | pipe, |
const void * | buf, | ||
size_t | size, | ||
int | mode | ||
) |
Write a message to a pipe.
This service writes a complete message to be received from the associated special device. rt_pipe_write() always preserves message boundaries, which means that all data sent through a single call of this service will be gathered in a single read(2) operation from the special device.
This service differs from rt_pipe_send() in that it accepts a pointer to the raw data to be sent, instead of a canned message buffer.
pipe | The pipe descriptor. |
buf | The address of the first data byte to send. The data will be copied to an internal buffer before transmission. |
size | The size in bytes of the message (payload data only). Zero is a valid value, in which case the service returns immediately without sending any message. |
mode | A set of flags affecting the operation: |