9 Stream & Message Buffers Flashcards
What can stream buffers be used for?
Stream buffers can be used as an alternative to queues, there are more light-weight in implantation. They are single read and write. They are used to send streams of bytes with no start or end.
What can message buffers be used for?
Used as an alternative to queues, its more light-weight in impletation and is single read and write. They can be used to send packets of data of varying sizes.
How is data passed in stream buffers?
Through packets of data.
What do the 10 and 5 parameters mean?
streamBuffer = xStreamBufferCreate(10,5);
10: The stream buffer can hold up to 10 bytes.
5: The receive task will unblock when there are 5 bytes in the stream buffer
What do each of these parameters mean?
xStreamBufferSend(streamBuffer, &num, 1, 0);
streamBuffer – name/handler of the stream buffer.
&num – a pointer to a variable that holds the data to be passed to the stream buffer
1 – number of bytes to be copied into the stream buffer
0 – Time to wait before timing out.
What do each of these parameters mean?
xStreamBufferReceive(streamBuffer, &rxData, SampleTrigger, pdMS_TO_TICKS(110000));
streamBuffer – name/handle of the stream buffer.
&rxData – pointer to the buffer where the bytes will be
copied
sampleTrigger – Size of the receive buffer. Max number
of bytes that can be received.
pdMS_TO_TICKS – time to wait before timing out.
Give an example of where a stream buffer can be used?
Use a stream buffer to stream a sample reading every second using a timer interrupt. If you were to do it with a queue, you would need to allocate a buffer in the interrupt.
What do each of these parameters mean?
xMessageBufferReceive(dataMessageBuffer, rxData, sizeof(rxData), pdmMs_TO_TICKS(1000));
dataMessageBuffer - name/handle of message buffer.
rxData – pointer to buffer where received bytes will be
copied.
Sizeof(rxData) – the size of the message buffer.
pdMS_TO_TICKS – Time before timing out.
Give an example of a message buffer.
Send GPS data.
Compare Stream Buffer vs Message Buffer vs Queue.
Stream buffer
* Single read and write.
* Sends stream of bytes.
* Light-weight compared to a queue.
Message buffer
* Single read and write.
* Built on stream buffer
* Designed to handle variable sized messages
* Sent in fixed packets.
* Light-weight compared to a queue.
Queue
* Most advanced communication object.
* Most common communication object used in
FreeRTOS.
* Can have multiple read and write, between tasks,
interrupt handlers.
* A queue uses a fixed message.