Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Updated Jun 2025

xQueueSendToFront

[Queue Management]

queue.h

1 BaseType_t xQueueSendToFront( QueueHandle_t xQueue,
2 const void * pvItemToQueue,
3 TickType_t xTicksToWait );

This is a macro that calls xQueueGenericSend().

Post an item to the front of a queue. The item is queued by copy, not by reference. This function must not be called from an interrupt service routine. See xQueueSendToFrontFromISR () for an alternative which may be used in an ISR.

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 pvItemToQueue into the queue storage area

  • 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 this is set to 0. The time is defined in tick periods so the constant portTICK_PERIOD_MS should be used to convert to real time if this is required.

    If INCLUDE_vTaskSuspend is set to '1' then specifying the block time as portMAX_DELAY will cause the task to block indefinitely (without a timeout). |

Returns:

pdPASS if the item was successfully posted, otherwise errQUEUE_FULL.

Example usage:

1struct AMessage
2{
3 char ucMessageID;
4 char ucData[ 20 ];
5} xMessage;
6
7unsigned long ulVar = 10UL;
8
9void vATask( void *pvParameters )
10{
11QueueHandle_t xQueue1, xQueue2;
12struct AMessage *pxMessage;
13
14 /* Create a queue capable of containing 10 unsigned long values. */
15 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
16
17 /* Create a queue capable of containing 10 pointers to AMessage
18 structures. These should be passed by pointer as they contain a lot of
19 data. */
20 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
21
22 /* ... */
23
24 if( xQueue1 != 0 )
25 {
26 /* Send an unsigned long. Wait for 10 ticks for space to become
27 available if necessary. */
28 if( xQueueSendToFront( xQueue1,
29 ( void * ) &ulVar,
30 ( TickType_t ) 10 ) != pdPASS )
31 {
32 /* Failed to post the message, even after 10 ticks. */
33 }
34 }
35
36 if( xQueue2 != 0 )
37 {
38 /* Send a pointer to a struct AMessage object. Don't block if the
39 queue is already full. */
40 pxMessage = & xMessage;
41 xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
42 }
43
44 /* ... Rest of task code. */
45}