xMessageBufferCreateStatic example

There is page about xMessageBufferCreateStatic

I suggest fix errors!

  1. ucStoragegBuffer != ucBufferStorage != ucStorageBuffer

Thanks for pointing this out, we will fix.

1 Like

It is not all about xMessageBufferCreateStatic page.

"Must point to a uint8_t array that is at least xBufferSizeBytes + 1 big. This is the array to which messages are copied when they are written to the message buffer. "

But in example

xMessageBuffer = xMessageBufferCreateStatic( sizeof( ucStorageBuffer ),
                                                 ucStorageBuffer,
                                                 &xMessageBufferStruct );

I can’t see + 1 big…

And… “+ 1 big” means + sizeof( size_t ) [usually 4 bytes] not just +1 byte?

So " The maximum number of bytes that can be stored in the message buffer is actually (xBufferSizeBytes - 1). " need "is actually (xBufferSizeBytes - sizeof(size_t)). "?

The +1 is bytes, as the buffer needs one always empty byte to distinguish full from empty. The maximum message that can be sent minus the size of configMESSAGE_BUFFER_LENGTH_TYPE which will default to size_t, so the provided buffer size must be bigger than the largest message by at least that much.

While it defaults to size_t, I can’t see a reason it can’t normally be changed to unsigned short or unsigned character, as I can’t imagine using a buffer for messages over 65k bytes long.

Is example from xMessageBufferCreateStatic page correct? I can’t see +1 or -1 there

Yes, I think so. See the comment::

/* Used to dimension the array used to hold the messages. The available space
will actually be one less than this, so 999. */
#define STORAGE_SIZE_BYTES 1000

1 Like