C API message queue definitions.
More...
|
const char * | os_mqueue_get_name (os_mqueue_t *mqueue) |
| Get the message queue name. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
size_t | os_mqueue_get_capacity (os_mqueue_t *mqueue) |
| Get queue capacity. More...
|
|
size_t | os_mqueue_get_length (os_mqueue_t *mqueue) |
| Get queue length. More...
|
|
size_t | os_mqueue_get_msg_size (os_mqueue_t *mqueue) |
| Get message size. More...
|
|
bool | os_mqueue_is_empty (os_mqueue_t *mqueue) |
| Check if the queue is empty. More...
|
|
bool | os_mqueue_is_full (os_mqueue_t *mqueue) |
| Check if the queue is full. More...
|
|
os_result_t | os_mqueue_reset (os_mqueue_t *mqueue) |
| Reset the message queue. More...
|
|
C API message queue definitions.
- For the complete definition, see
- RTOS C++ API
- Examples
typedef struct my_msg_s
{
int i;
const char* s;
} my_msg_t;
int
{
my_msg_t msg_out =
{ 1, "msg" };
my_msg_t msg_in =
{ 0, NULL };
{
msg_in.i = 0;
assert(msg_in.i = 1);
msg_in.i = 0;
assert(msg_in.i = 1);
msg_in.i = 0;
assert(msg_in.i = 1);
const char* str;
size_t n;
assert(strcmp (str, "q1") == 0);
assert(n == 3);
assert(n == 0);
assert(n == sizeof(my_msg_t));
}
{
static char queue[1000];
msg_in.i = 0;
assert(msg_in.i = 1);
}
}
◆ os_mqueue_create
◆ os_mqueue_destroy
◆ os_mqueue_attr_t
◆ os_mqueue_prio_t
◆ 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.
- See also
- os::rtos::message_queue
◆ os_mqueue_attr_init()
Initialise the message queue attributes.
- Parameters
-
[in] | attr | Pointer to message queue attributes object instance. |
- Returns
- Nothing.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::attributes
Definition at line 2763 of file os-c-wrapper.cpp.
◆ os_mqueue_construct()
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.
- Parameters
-
[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). |
- Returns
- Nothing.
- Note
- Must be paired with
os_mqueue_destruct()
.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue
Definition at line 2780 of file os-c-wrapper.cpp.
◆ os_mqueue_delete()
Destruct the message queue object instance and deallocate it.
- Parameters
-
[in] | mqueue | Pointer to dynamically allocated message queue object instance. |
- Returns
- Nothing.
Destruct the message queue and deallocate the dynamically allocated space using the RTOS system allocator.
- Note
- Equivalent of C++
delete ptr_mqueue
.
-
Must be paired with
os_mqueue_new()
.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue
Definition at line 2850 of file os-c-wrapper.cpp.
◆ os_mqueue_destruct()
Destruct the statically allocated message queue object instance.
- Parameters
-
[in] | mqueue | Pointer to message queue object instance. |
- Returns
- Nothing.
- Note
- Must be paired with
os_mqueue_construct()
.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue
Definition at line 2803 of file os-c-wrapper.cpp.
◆ os_mqueue_get_capacity()
Get queue capacity.
- Parameters
-
[in] | mqueue | Pointer to message queue object instance. |
- Returns
- The max number of messages that can be queued.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::capacity()
Definition at line 2997 of file os-c-wrapper.cpp.
◆ os_mqueue_get_length()
Get queue length.
- Parameters
-
[in] | mqueue | Pointer to message queue object instance. |
- Returns
- The number of messages in the queue.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::length()
Definition at line 2982 of file os-c-wrapper.cpp.
◆ os_mqueue_get_msg_size()
Get message size.
- Parameters
-
[in] | mqueue | Pointer to message queue object instance. |
- Returns
- The message size, in bytes.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::msg_size()
Definition at line 3012 of file os-c-wrapper.cpp.
◆ os_mqueue_get_name()
Get the message queue name.
- Parameters
-
[in] | mqueue | Pointer to message queue object instance. |
- Returns
- Null terminated string.
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::name()
Definition at line 2865 of file os-c-wrapper.cpp.
◆ os_mqueue_is_empty()
Check if the queue is empty.
- Parameters
-
[in] | mqueue | Pointer to message queue object instance. |
- Return values
-
true | The queue has no messages. |
false | The queue has some messages. |
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::empty()
Definition at line 3027 of file os-c-wrapper.cpp.
◆ os_mqueue_is_full()
Check if the queue is full.
- Parameters
-
[in] | mqueue | Pointer to message queue object instance. |
- Return values
-
true | The queue is full. |
false | The queue is not full. |
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::full()
Definition at line 3042 of file os-c-wrapper.cpp.
◆ os_mqueue_new()
Allocate a message queue object instance and construct it.
- Parameters
-
[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). |
- Returns
- Pointer to new message queue object instance.
Dynamically allocate the message queue object instance using the RTOS system allocator and construct it.
- Note
- Equivalent of C++
new message_queue(...)
.
-
Must be paired with
os_mqueue_delete()
.
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue
Definition at line 2824 of file os-c-wrapper.cpp.
◆ os_mqueue_receive()
Receive a message from the queue.
- Parameters
-
[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. |
- Return values
-
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. |
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::receive()
Definition at line 2931 of file os-c-wrapper.cpp.
◆ os_mqueue_reset()
Reset the message queue.
- Parameters
-
[in] | mqueue | Pointer to message queue object instance. |
- Return values
-
os_ok | The queue was reset. |
EPERM | Cannot be invoked from an Interrupt Service Routines. |
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::reset()
Definition at line 3057 of file os-c-wrapper.cpp.
◆ os_mqueue_send()
Send a message to the queue.
- Parameters
-
[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. |
- Return values
-
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. |
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::send()
Definition at line 2880 of file os-c-wrapper.cpp.
◆ os_mqueue_timed_receive()
Receive a message from the queue with timeout.
- Parameters
-
[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. |
- Return values
-
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. |
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::timed_receive()
Definition at line 2965 of file os-c-wrapper.cpp.
◆ os_mqueue_timed_send()
Send a message to the queue with timeout.
- Parameters
-
[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. |
- Return values
-
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. |
- Warning
- Cannot be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::timed_send()
Definition at line 2914 of file os-c-wrapper.cpp.
◆ os_mqueue_try_receive()
Try to receive a message from the queue.
- Parameters
-
[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. |
- Return values
-
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. |
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::try_receive()
Definition at line 2948 of file os-c-wrapper.cpp.
◆ os_mqueue_try_send()
Try to send a message to the queue.
- Parameters
-
[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. |
- Return values
-
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). |
- Note
- Can be invoked from Interrupt Service Routines.
- For the complete definition, see
- os::rtos::message_queue::try_send()
Definition at line 2897 of file os-c-wrapper.cpp.