C API message queue definitions. More...
Classes | |
struct | os_mqueue_attr_s |
Message queue attributes. More... | |
struct | os_mqueue_s |
Message queue object storage. More... | |
Typedefs | |
typedef struct os_mqueue_attr_s | os_mqueue_attr_t |
Message queue attributes. | |
typedef uint8_t | os_mqueue_prio_t |
Type of variables holding message queue priorities. | |
typedef struct os_mqueue_s | os_mqueue_t |
Message queue object storage. | |
Message Queue Attributes Functions | |
void | os_mqueue_attr_init (os_mqueue_attr_t *attr) |
Initialise the message queue attributes. | |
Message Queue Creation Functions | |
void | os_mqueue_construct (os_mqueue_t *mqueue, const char *name, size_t msgs, size_t msg_size_bytes, const os_mqueue_attr_t *attr) |
Construct a statically allocated message queue object instance. | |
void | os_mqueue_destruct (os_mqueue_t *mqueue) |
Destruct the statically allocated message queue object instance. | |
os_mqueue_t * | os_mqueue_new (const char *name, size_t msgs, size_t msg_size_bytes, const os_mqueue_attr_t *attr) |
Allocate a message queue object instance and construct it. | |
void | os_mqueue_delete (os_mqueue_t *mqueue) |
Destruct the message queue object instance and deallocate it. | |
Message Queue Functions | |
const char * | os_mqueue_get_name (os_mqueue_t *mqueue) |
Get the message queue name. | |
os_result_t | os_mqueue_send (os_mqueue_t *mqueue, const void *msg, size_t nbytes, os_mqueue_prio_t mprio) |
Send a message to the queue. | |
os_result_t | os_mqueue_try_send (os_mqueue_t *mqueue, const void *msg, size_t nbytes, os_mqueue_prio_t mprio) |
Try to send a message to the queue. | |
os_result_t | os_mqueue_timed_send (os_mqueue_t *mqueue, const void *msg, size_t nbytes, os_clock_duration_t timeout, os_mqueue_prio_t mprio) |
Send a message to the queue with timeout. | |
os_result_t | os_mqueue_receive (os_mqueue_t *mqueue, void *msg, size_t nbytes, os_mqueue_prio_t *mprio) |
Receive a message from the queue. | |
os_result_t | os_mqueue_try_receive (os_mqueue_t *mqueue, void *msg, size_t nbytes, os_mqueue_prio_t *mprio) |
Try to receive a message from the queue. | |
os_result_t | os_mqueue_timed_receive (os_mqueue_t *mqueue, void *msg, size_t nbytes, os_clock_duration_t timeout, os_mqueue_prio_t *mprio) |
Receive a message from the queue with timeout. | |
size_t | os_mqueue_get_capacity (os_mqueue_t *mqueue) |
Get queue capacity. | |
size_t | os_mqueue_get_length (os_mqueue_t *mqueue) |
Get queue length. | |
size_t | os_mqueue_get_msg_size (os_mqueue_t *mqueue) |
Get message size. | |
bool | os_mqueue_is_empty (os_mqueue_t *mqueue) |
Check if the queue is empty. | |
bool | os_mqueue_is_full (os_mqueue_t *mqueue) |
Check if the queue is full. | |
os_result_t | os_mqueue_reset (os_mqueue_t *mqueue) |
Reset the message queue. | |
Compatibility Macros | |
#define | os_mqueue_create os_mqueue_construct |
#define | os_mqueue_destroy os_mqueue_destruct |
C API message queue definitions.
#define os_mqueue_create os_mqueue_construct |
Definition at line 2428 of file os-c-api.h.
#define os_mqueue_destroy os_mqueue_destruct |
Definition at line 2429 of file os-c-api.h.
typedef struct os_mqueue_attr_s os_mqueue_attr_t |
Message queue attributes.
Initialise this structure with os_mqueue_attr_init()
and then set any of the individual members directly.
typedef uint8_t os_mqueue_prio_t |
Type of variables holding message queue priorities.
Definition at line 1289 of file os-c-decls.h.
typedef struct os_mqueue_s os_mqueue_t |
Message queue object storage.
This C structure has the same size as the C++ os::rtos::message_queue
object and must be initialised with os_mqueue_create()
.
Later on a pointer to it can be used both in C and C++ to refer to the message queue object instance.
The members of this structure are hidden and should not be used directly, but only through specific functions.
void os_mqueue_attr_init | ( | os_mqueue_attr_t * | attr | ) |
Initialise the message queue attributes.
[in] | attr | Pointer to message queue attributes object instance. |
Definition at line 2534 of file os-c-wrapper.cpp.
void os_mqueue_construct | ( | os_mqueue_t * | mqueue, |
const char * | name, | ||
size_t | msgs, | ||
size_t | msg_size_bytes, | ||
const os_mqueue_attr_t * | attr | ||
) |
Construct a statically allocated message queue object instance.
[in] | mqueue | Pointer to message queue object instance storage. |
[in] | name | Pointer to name (may be NULL). |
[in] | msgs | The number of messages. |
[in] | msg_size_bytes | The message size, in bytes. |
[in] | attr | Pointer to attributes (may be NULL). |
os_mqueue_destruct()
.Definition at line 2549 of file os-c-wrapper.cpp.
void os_mqueue_delete | ( | os_mqueue_t * | mqueue | ) |
Destruct the message queue object instance and deallocate it.
[in] | mqueue | Pointer to dynamically allocated message queue object instance. |
Destruct the message queue and deallocate the dynamically allocated space using the RTOS system allocator.
delete ptr_mqueue
. os_mqueue_new()
.Definition at line 2615 of file os-c-wrapper.cpp.
void os_mqueue_destruct | ( | os_mqueue_t * | mqueue | ) |
Destruct the statically allocated message queue object instance.
[in] | mqueue | Pointer to message queue object instance. |
os_mqueue_construct()
.Definition at line 2570 of file os-c-wrapper.cpp.
size_t os_mqueue_get_capacity | ( | os_mqueue_t * | mqueue | ) |
Get queue capacity.
[in] | mqueue | Pointer to message queue object instance. |
Definition at line 2744 of file os-c-wrapper.cpp.
size_t os_mqueue_get_length | ( | os_mqueue_t * | mqueue | ) |
Get queue length.
[in] | mqueue | Pointer to message queue object instance. |
Definition at line 2731 of file os-c-wrapper.cpp.
size_t os_mqueue_get_msg_size | ( | os_mqueue_t * | mqueue | ) |
Get message size.
[in] | mqueue | Pointer to message queue object instance. |
Definition at line 2757 of file os-c-wrapper.cpp.
const char * os_mqueue_get_name | ( | os_mqueue_t * | mqueue | ) |
Get the message queue name.
[in] | mqueue | Pointer to message queue object instance. |
Definition at line 2628 of file os-c-wrapper.cpp.
bool os_mqueue_is_empty | ( | os_mqueue_t * | mqueue | ) |
Check if the queue is empty.
[in] | mqueue | Pointer to message queue object instance. |
true | The queue has no messages. |
false | The queue has some messages. |
Definition at line 2770 of file os-c-wrapper.cpp.
bool os_mqueue_is_full | ( | os_mqueue_t * | mqueue | ) |
Check if the queue is full.
[in] | mqueue | Pointer to message queue object instance. |
true | The queue is full. |
false | The queue is not full. |
Definition at line 2783 of file os-c-wrapper.cpp.
os_mqueue_t * os_mqueue_new | ( | const char * | name, |
size_t | msgs, | ||
size_t | msg_size_bytes, | ||
const os_mqueue_attr_t * | attr | ||
) |
Allocate a message queue object instance and construct it.
[in] | name | Pointer to name (may be NULL). |
[in] | msgs | The number of messages. |
[in] | msg_size_bytes | The message size, in bytes. |
[in] | attr | Pointer to attributes (may be NULL). |
Dynamically allocate the message queue object instance using the RTOS system allocator and construct it.
new message_queue(...)
. os_mqueue_delete()
.Definition at line 2590 of file os-c-wrapper.cpp.
os_result_t os_mqueue_receive | ( | os_mqueue_t * | mqueue, |
void * | msg, | ||
size_t | nbytes, | ||
os_mqueue_prio_t * | mprio | ||
) |
Receive a message from the queue.
[in] | mqueue | Pointer to message queue object instance. |
[out] | msg | The address where to store the dequeued message. |
[in] | nbytes | The size of the destination buffer. Must be lower than the value used when creating the queue. |
[out] | mprio | The address where to store the message priority. Enter NULL if priorities are not used. |
os_ok | The message was received. |
EINVAL | A parameter is invalid or outside of a permitted range. |
EMSGSIZE | The specified message length, nbytes, is greater than the message size attribute of the message queue. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
ENOTRECOVERABLE | The message could not be dequeued (extension to POSIX). |
EBADMSG | The implementation has detected a data corruption problem with the message. |
EINTR | The operation was interrupted. |
Definition at line 2686 of file os-c-wrapper.cpp.
os_result_t os_mqueue_reset | ( | os_mqueue_t * | mqueue | ) |
Reset the message queue.
[in] | mqueue | Pointer to message queue object instance. |
os_ok | The queue was reset. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
Definition at line 2796 of file os-c-wrapper.cpp.
os_result_t os_mqueue_send | ( | os_mqueue_t * | mqueue, |
const void * | msg, | ||
size_t | nbytes, | ||
os_mqueue_prio_t | mprio | ||
) |
Send a message to the queue.
[in] | mqueue | Pointer to message queue object instance. |
[in] | msg | The address of the message to enqueue. |
[in] | nbytes | The length of the message. Must be not higher than the value used when creating the queue. |
[in] | mprio | The message priority. Enter 0 if priorities are not used. |
os_ok | The message was enqueued. |
EINVAL | A parameter is invalid or outside of a permitted range. |
EMSGSIZE | The specified message length, nbytes, exceeds the message size attribute of the message queue. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
ENOTRECOVERABLE | The message could not be enqueue (extension to POSIX). |
EINTR | The operation was interrupted. |
Definition at line 2641 of file os-c-wrapper.cpp.
os_result_t os_mqueue_timed_receive | ( | os_mqueue_t * | mqueue, |
void * | msg, | ||
size_t | nbytes, | ||
os_clock_duration_t | timeout, | ||
os_mqueue_prio_t * | mprio | ||
) |
Receive a message from the queue with timeout.
[in] | mqueue | Pointer to message queue object instance. |
[out] | msg | The address where to store the dequeued message. |
[in] | nbytes | The size of the destination buffer. Must be lower than the value used when creating the queue. |
[in] | timeout | The timeout duration. |
[out] | mprio | The address where to store the message priority. Enter NULL if priorities are not used. |
os_ok | The message was received. |
EINVAL | A parameter is invalid or outside of a permitted range. |
EMSGSIZE | The specified message length, nbytes, is greater than the message size attribute of the message queue. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
ENOTRECOVERABLE | The message could not be dequeued (extension to POSIX). |
EBADMSG | The implementation has detected a data corruption problem with the message. |
EINTR | The operation was interrupted. |
ETIMEDOUT | No message arrived on the queue before the specified timeout expired. |
Definition at line 2716 of file os-c-wrapper.cpp.
os_result_t os_mqueue_timed_send | ( | os_mqueue_t * | mqueue, |
const void * | msg, | ||
size_t | nbytes, | ||
os_clock_duration_t | timeout, | ||
os_mqueue_prio_t | mprio | ||
) |
Send a message to the queue with timeout.
[in] | mqueue | Pointer to message queue object instance. |
[in] | msg | The address of the message to enqueue. |
[in] | nbytes | The length of the message. Must be not higher than the value used when creating the queue. |
[in] | timeout | The timeout duration. |
[in] | mprio | The message priority. Enter 0 if priorities are not used. |
os_ok | The message was enqueued. |
EINVAL | A parameter is invalid or outside of a permitted range. |
EMSGSIZE | The specified message length, nbytes, exceeds the message size attribute of the message queue. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
ETIMEDOUT | The timeout expired before the message could be added to the queue. |
ENOTRECOVERABLE | The message could not be enqueue (extension to POSIX). |
EINTR | The operation was interrupted. |
Definition at line 2671 of file os-c-wrapper.cpp.
os_result_t os_mqueue_try_receive | ( | os_mqueue_t * | mqueue, |
void * | msg, | ||
size_t | nbytes, | ||
os_mqueue_prio_t * | mprio | ||
) |
Try to receive a message from the queue.
[in] | mqueue | Pointer to message queue object instance. |
[out] | msg | The address where to store the dequeued message. |
[in] | nbytes | The size of the destination buffer. Must be lower than the value used when creating the queue. |
[out] | mprio | The address where to store the message priority. Enter NULL if priorities are not used. |
os_ok | The message was received. |
EINVAL | A parameter is invalid or outside of a permitted range. |
EMSGSIZE | The specified message length, nbytes, is greater than the message size attribute of the message queue. |
ENOTRECOVERABLE | The message could not be dequeued (extension to POSIX). |
EBADMSG | The implementation has detected a data corruption problem with the message. |
EWOULDBLOCK | The specified message queue is empty. |
Definition at line 2701 of file os-c-wrapper.cpp.
os_result_t os_mqueue_try_send | ( | os_mqueue_t * | mqueue, |
const void * | msg, | ||
size_t | nbytes, | ||
os_mqueue_prio_t | mprio | ||
) |
Try to send a message to the queue.
[in] | mqueue | Pointer to message queue object instance. |
[in] | msg | The address of the message to enqueue. |
[in] | nbytes | The length of the message. Must be not higher than the value used when creating the queue. |
[in] | mprio | The message priority. Enter 0 if priorities are not used. |
os_ok | The message was enqueued. |
EWOULDBLOCK | The specified message queue is full. |
EINVAL | A parameter is invalid or outside of a permitted range. |
EMSGSIZE | The specified message length, nbytes, exceeds the message size attribute of the message queue. |
ENOTRECOVERABLE | The message could not be enqueue (extension to POSIX). |
Definition at line 2656 of file os-c-wrapper.cpp.