OS_MSG_QTY OSQFlush (OS_Q *p_q,
OS_ERR *p_err)
File |
Called from |
Code enabled by |
---|---|---|
|
Task only |
|
OSQFlush()
empties the contents of the message queue and eliminates all messages sent to the queue. This function takes the same amount of time to execute regardless of whether tasks are waiting on the queue (and thus no messages are present), or the queue contains one or more messages. OS_MSGs
from the queue are simply returned to the free pool of OS_MSGs
.
Arguments
p_q
is a pointer to the message queue.
p_err
is a pointer to a variable that will contain an error code returned by this function.
OS_ERR_NONE
If the message queue is flushed.
OS_ERR_FLUSH_ISR
If OS_CFG_CALLED_FROM_ISR_CHK_EN
set to 1
in os_cfg.h
: if calling this function from an ISR
OS_ERR_OBJ_PTR_NULL
If OS_CFG_ARG_CHK_EN
is set to 1
in os_cfg.h
: if p_q
is a NULL
pointer.
OS_ERR_OBJ_TYPE
If OS_CFG_OBJ_TYPE_CHK_EN
is set to 1
in os_cfg.h
: if you attempt to flush an object other than a message queue.
Returned Value
The number of OS_MSG
entries freed from the message queue. Note that the OS_MSG
entries are returned to the free pool of OS_MSGs
.
Notes/Warnings
Example
or, to flush a queue that contains entries, instead you can use OSQPend()
and specify the OS_OPT_PEND_NON_BLOCKING
option.