Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 3.05
void  OSTaskQPost (OS_TCB      *p_tcb,
                   void        *p_void,
                   OS_MSG_SIZE  msg_size,
                   OS_OPT       opt,
                   OS_ERR      *p_err)

...

File

...

Called from

...

Code enabled by

...

os_q.c

...

Task or ISR

...

Description

OSTaskQPost() sends  sends a message to a task through its local message queue. A message is a pointer-sized variable, and its use is application specific. If the task’s message queue is full, an error code is returned to the caller. In this case, OSTaskQPost() immediately  immediately returns to its caller, and the message is not placed in the message queue.

If the task receiving the message is waiting for a message to arrive, it will be made ready-to-run. If the receiving task has a higher priority than the task sending the message, the higher-priority task resumes, and the task sending the message is suspended; that is, a context switch occurs. A message can be posted as first-in first-out (FIFO), or last-in-first-out (LIFO), depending on the value specified in the the opt argument argument. In either case, scheduling occurs unless unless opt is  is set to to OS_OPT_POST_NO_SCHED.

Files

os.h/os_task.c

Prototype

Arguments

p_tcb

is a pointer to the TCB of the task. Note that it is possible to post a message to the calling task (i.e., self) by specifying a NULL pointer, or the address of its TCB.

...

You should use this option if the task (or ISR) calling OSTaskQPost() will be doing additional posts, the user does not want to reschedule until all done, and multiple posts are to take effect simultaneously.

...

p_err

is a pointer to a variable that will contain an error code returned by this function.

...

If the call was successful and the message was posted to the task’s message queue.

OS_ERR_INT_Q_FULL

If OS_CFG_ISR_POST_DEFERRED_EN is to DEF_ENABLED in os_cfg.hIf the deferred interrupt post queue is full.

OS_ERR_MSG_POOL_EMPTY

If running out of OS_MSG to hold the message being posted.

OS_ERR_OPT_INVALID

If OS_CFG_ARG_CHK_EN is set to DEF_ENABLED in os_cfg.h: if a valid option is not specified.

OS_ERR_OS_NOT_RUNNING

If OS_CFG_INVALID_OS_CALLS_CHK_EN is set to DEF_ENABLED in os_cfg.h: if µC/OS-III is not running yet.

OS_ERR_Q_MAX

If the task’s message queue is full and cannot accept more messages.

OS_ERR_STATE_INVALID

If the task is in an invalid state.

Returned Value

None

Required Configuration

OS_CFG_TASK_Q_EN must be enabled in os_cfg.h. Refer to µC-OS-III Configuration Manual.

Callers

Application and ISRs.

Notes/Warnings

None

Example Usage