Updated Jun 2025
xQueueSend
queue.h
1 BaseType_t xQueueSend(2 QueueHandle_t xQueue,3 const void * pvItemToQueue,4 TickType_t xTicksToWait5 );
This is a macro that calls
xQueueGenericSend()
xQueueSendToFront()
xQueueSendToBack()
xQueueSendToBack()
Post an item on a queue. The item is queued by copy, not by reference. This function must not be called from an interrupt service routine. See
xQueueSendFromISR()
Parameters:
-
xQueue
The handle to the queue on which the item is to be posted.
-
pvItemToQueue
A pointer to the item that is to be placed on the queue. The size of the items the queue will hold was defined when the queue was created, so this many bytes will be copied from
into the queue storage area.pvItemToQueue -
xTicksToWait
The maximum amount of time the task should block waiting for space to become available on the queue, should it already be full. The call will return immediately if the queue is full and
is set to 0. The time is defined in tick periods so the constantxTicksToWaitshould be used to convert to real time if this is required.portTICK_PERIOD_MSIf INCLUDE_vTaskSuspend is set to '1' then specifying the block time as
will cause the task to block indefinitely (without a timeout).portMAX_DELAY
Returns:
- pdPASS if the item was successfully posted,
- errQUEUE_FULL otherwise.
Example usage:
1struct AMessage2 {3 char ucMessageID;4 char ucData[ 20 ];5 } xMessage;67 unsigned long ulVar = 10UL;89 void vATask( void *pvParameters )10 {11 QueueHandle_t xQueue1, xQueue2;12 struct AMessage *pxMessage;1314 /* Create a queue capable of containing 10 unsigned long values. */15 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );1617 /* Create a queue capable of containing 10 pointers to AMessage structures.18 These should be passed by pointer as they contain a lot of data. */19 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );2021 /* ... */2223 if( xQueue1 != 0 )24 {25 /* Send an unsigned long. Wait for 10 ticks for space to become26 available if necessary. */27 if( xQueueSend( xQueue1,28 ( void * ) &ulVar,29 ( TickType_t ) 10 ) != pdPASS )30 {31 /* Failed to post the message, even after 10 ticks. */32 }33 }3435 if( xQueue2 != 0 )36 {37 /* Send a pointer to a struct AMessage object. Don't block if the38 queue is already full. */39 pxMessage = & xMessage;40 xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );41 }4243 /* ... Rest of task code. */44 }