Quality RTOS & Embedded Software

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


Loading

xMessageBufferCreate() API - Meaning of xBufferSizeBytes

Posted by armandas on February 8, 2019

The xBufferSizeBytes parameter of the xMessageBufferCreate() needs to be manually increased by sizeof(size_t). Is there a good technical reason why this increment is not done internally?

E.g. inside xStreamBufferGenericCreate() we have an assert to check the buffer size: ~~~ if( xIsMessageBuffer == pdTRUE ) { /* Is a message buffer but not statically allocated. / ucFlags = sbFLAGSISMESSAGEBUFFER; configASSERT( xBufferSizeBytes > sbBYTESTOSTOREMESSAGE_LENGTH ); } ~~~ when we could simply increment the size: ~~~ if( xIsMessageBuffer == pdTRUE ) { / Is a message buffer but not statically allocated. */ ucFlags = sbFLAGSISMESSAGEBUFFER; xBufferSizeBytes += sbBYTESTOSTOREMESSAGE_LENGTH; } ~~~


xMessageBufferCreate() API - Meaning of xBufferSizeBytes

Posted by rtel on February 8, 2019

The way the parameter works is described on the API function's documentation page:

https://www.freertos.org/xMessageBufferCreate.html

The user needs to know how it works as, for example, if you wanted to store two messages, just adding one additional lot of sbBYTESTOSTOREMESSAGELENGTH bytes is not going to help (as two lots would be needed), and possible just confuse. It is considered best to let the application writer define the buffer's size explicitly.


xMessageBufferCreate() API - Meaning of xBufferSizeBytes

Posted by armandas on February 8, 2019

Thank you for the answer. I had missed the fact that you can store multiple messages in the buffer.


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


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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Mediatek

Renesas

RISC-V

SiFIve RISC-V

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

Xilinx Microblaze and Zynq partner