Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Queues: How Does the Data get to the Task?

Posted by groger57 on June 14, 2017

On this link: http://www.freertos.org/a00117.html And on page 170 of there reference manual, shows essentially the same example. What I am trying to understand ishow the data gets into the task that performs xQueueSend? These examples show a task that does not use the vTaskDelayUntil( ... ) function.

I want to send a string to a UART from various tasks. For the sake of the example, let's say I am using the example struct "AMessage" Let's say I have function somewhere in another deterministic task that executes at 1 second intervals. I want to send a UART message from here. In contect of the provided examples, how do I do this?

Sorry if it's a silly question, but I do not see this clearly.

Thanks!


Queues: How Does the Data get to the Task?

Posted by rtel on June 15, 2017

I don't fully understand the scenario you are describing.

Is this right: You want to send a message to a UART from a task that executes every 1 second?

If so, where is a queue being used and what is being sent over the queue?

Or is this right: You want to send a string over a queue, but you don't know how to get a pointer to the string into the function that calls xQueueSend() (as its best to queue a pointer to the string, not the whole string)?

In which case it would not seem to be a FreeRTOS question, but a C question (passing data in function parameters, or in file scope variables, etc.) - which is why I don't think it is this case.

You mention the manual - do you mean the reference manual or the book. The book, which discusses queues, is available here: http://www.freertos.org/Documentation/RTOS_book.html


Queues: How Does the Data get to the Task?

Posted by richard_damon on June 15, 2017

A Queue basically provides the service of holding data, and manages task execution holding off tasks until there is room for data (on a send) or data available (on a take). The giving task/ISR needs to gather the information it wants to put in the Queue into a block of memory, call the send function, which when there is room, will copy that data into a corresponding block of memoryy inside the Queue, and when tthe receiving task/ISR does a take, it provides a similar buffer that the queue will copy the data to.

The Queue has nothing to do with how the sender filled the block of memory initially, or what the reciever does with its copy after it is given.

Because the data gets copies twice (once into the queue, and again out of the queue) it is best if the data is small, and if you want to send bigger blocks (or variable sized blocks) you actually just send a pointer to the data, and manage the data buffer so that the sender doesn't change that block of memory until after the reciever finishes using it, but instead it uses some other block of memory.


Queues: How Does the Data get to the Task?

Posted by groger57 on June 20, 2017

I am sorry for the question - it was kinda dumb. Got it all figured out and working. I do have another question about return values and wait times I will ask separately. thank you.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS