I created a Queue with one item, and the item size is 2048 bytes.
I use this queue to pass commands or data to a 3G module.
the maximum size that a command can reach is about 256 bytes but for data can reach 2048.
I was wondering if I send 15 bytes in the queue will the xQueueSend() copy 2048 bytes or just 15 bytes ? and the same question for xQueueReceive() ?
Another question is from what I understand and in ordre to use queue. I have to copy the source buffer into the queue when sending, and copy the same data again when receiving the queue.
Basically I'll have to use three times 2048 bytes : to pass data from the source buffer in the sending task to the queue and finally to recieve it in the receiving task. It it possible to use only the queue array that i reserved when creating the queue ?
I'm aware of passing pointers rather then actual data, (queue will be :2048 item, sizeof(item) = char) but that require to use global buffer and i'm trying to avoid global variable as much as possible.
any better ideas or help will be much appreciated
You do not get the option of how many bytes to copy into or out of a queue other than when you set the size of the queue at the time you call xQueueCreate().
Unless you have lots of RAM and can spare the time it takes to copy the data into and out of the queue I would very much recommend passing the data by reference. You may even be able to do it zero copy all the way through by having a task allocate the buffer (dynamically or from a pre-allocated pool [the pool size could be 1 if the task can wait for a buffer to be available!]), pass it by reference to whichever intermediary tasks there are, with the final task that touches the data passing the buffer to the 3G interface which is then set up to send the data directly from the original buffer. When the data has been sent the buffer is freed (either dynamically or by returning it to a pool of free buffers). This is how the zero copy interface in FreeRTOS+UDP works.
You have probably read it already, but the following link may have ideas:
Thank you for the informations
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.