Message Buffer

Message buffers work a lot like stream buffers, but instead of having the receiver request a certain amount of data, the first part of the message specifies the message length. Additionally, a message can only be read out as the length specified, and not as individual bytes.

Message buffers are implemented using stream buffers, so the assumption of only one reader and one writer applies here as well. The message buffer also works in the same way as the stream buffer such that a sender will block if the buffer is full, and a receiver will block if the buffer is empty.

A message buffer is created with the function xMessageBufferCreate(bufferSizeBytes). The size specified should equal the total number of bytes (not messages) the buffer should be able to contain.

Sending and receiving data is done by using the functions below.
xMessageBufferSend(messageBuffer, *pvTxData, xDataLengthBytes, ticksToWait);
xMessageBufferReceive(messageBuffer, *pvRxData, bufferLengthBytes, ticksToWait);