Complete the code to create a queue for communication between tasks.
QueueHandle_t xQueue = xQueueCreate([1], sizeof(int));The function xQueueCreate needs the number of items the queue can hold as the first argument.
Complete the code to send data to the queue from a producer task.
xQueueSend([1], &data, portMAX_DELAY);xQueueSend as the queue handle.xQueueReceive instead of the queue variable.The first argument to xQueueSend is the queue handle variable.
Fix the error in the consumer task code to receive data from the queue.
if(xQueueReceive([1], &receivedData, portMAX_DELAY) == pdPASS) { // process receivedData }
xQueueReceive as the queue handle.xQueueSend as the queue handle.The first argument to xQueueReceive must be the queue handle variable.
Fill both blanks to create a producer task that sends data to the queue.
void vProducerTask(void *pvParameters) {
int data = 0;
for(;;) {
data++;
xQueue[1]([2], &data, portMAX_DELAY);
vTaskDelay(pdMS_TO_TICKS(1000));
}
}Receive instead of Send.NULL as the queue handle.The function to send data to the queue is xQueueSend, and the first argument is the queue handle variable.
Fill all three blanks to create a consumer task that receives data and prints it.
void vConsumerTask(void *pvParameters) {
int receivedData;
for(;;) {
if(xQueue[1]([2], &receivedData, portMAX_DELAY) == [3]) {
printf("Received: %d\n", receivedData);
}
}
}Send instead of Receive.NULL as the queue handle.The function to receive data is xQueueReceive, the first argument is the queue handle variable, and the success return value is pdPASS.
