mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Fix regressions introduced by introduction of configMESSAGE_BUFFER_LENGTH_TYPE constant - specifically enabling big endian support and updates to xStreamBufferNextMessageLengthBytes.
This commit is contained in:
parent
3ec86b7a98
commit
025088c280
|
@ -41,7 +41,7 @@
|
|||
#define mbMESSAGE_BUFFER_LENGTH_BYTES ( ( size_t ) 50 )
|
||||
|
||||
/* The number of additional bytes used to store the length of each message. */
|
||||
#define mbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( size_t ) )
|
||||
#define mbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) )
|
||||
|
||||
/* Start and end ASCII characters used in messages sent to the buffers. */
|
||||
#define mbASCII_SPACE 32
|
||||
|
@ -191,7 +191,8 @@ UBaseType_t uxOriginalPriority;
|
|||
additional 4 bytes are added to hold the item's size. That means adding
|
||||
6 bytes to the buffer will actually add 10 bytes to the buffer. Therefore,
|
||||
with a 50 byte buffer, a maximum of 5 6 bytes items can be added before the
|
||||
buffer is completely full. */
|
||||
buffer is completely full. NOTE: The numbers in this paragraph assume
|
||||
sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) == 4. */
|
||||
for( xItem = 0; xItem < xMax6ByteMessages; xItem++ )
|
||||
{
|
||||
configASSERT( xMessageBufferIsFull( xMessageBuffer ) == pdFALSE );
|
||||
|
@ -377,6 +378,10 @@ UBaseType_t uxOriginalPriority;
|
|||
xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES, mbDONT_BLOCK );
|
||||
configASSERT( xReturned == 0 );
|
||||
( void ) xReturned; /* In case configASSERT() is not defined. */
|
||||
#ifndef configMESSAGE_BUFFER_LENGTH_TYPE
|
||||
{
|
||||
/* The following will fail if configMESSAGE_BUFFER_LENGTH_TYPE is set
|
||||
to a non 32-bit type. */
|
||||
xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES - 1, mbDONT_BLOCK );
|
||||
configASSERT( xReturned == 0 );
|
||||
( void ) xReturned; /* In case configASSERT() is not defined. */
|
||||
|
@ -386,6 +391,8 @@ UBaseType_t uxOriginalPriority;
|
|||
xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES - 3, mbDONT_BLOCK );
|
||||
configASSERT( xReturned == 0 );
|
||||
( void ) xReturned; /* In case configASSERT() is not defined. */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Don't expect any messages to be available as the above were too large to
|
||||
get written. */
|
||||
|
|
|
@ -799,6 +799,7 @@ size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer )
|
|||
{
|
||||
StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
|
||||
size_t xReturn, xBytesAvailable, xOriginalTail;
|
||||
configMESSAGE_BUFFER_LENGTH_TYPE xTempReturn;
|
||||
|
||||
configASSERT( pxStreamBuffer );
|
||||
|
||||
|
@ -815,7 +816,8 @@ size_t xReturn, xBytesAvailable, xOriginalTail;
|
|||
returned to its prior state as the message is not actually being
|
||||
removed from the buffer. */
|
||||
xOriginalTail = pxStreamBuffer->xTail;
|
||||
( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, xBytesAvailable );
|
||||
( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, xBytesAvailable );
|
||||
xReturn = ( size_t ) xTempReturn;
|
||||
pxStreamBuffer->xTail = xOriginalTail;
|
||||
}
|
||||
else
|
||||
|
@ -901,6 +903,7 @@ static size_t prvReadMessageFromBuffer( StreamBuffer_t *pxStreamBuffer,
|
|||
size_t xBytesToStoreMessageLength )
|
||||
{
|
||||
size_t xOriginalTail, xReceivedLength, xNextMessageLength;
|
||||
configMESSAGE_BUFFER_LENGTH_TYPE xTempNextMessageLength;
|
||||
|
||||
if( xBytesToStoreMessageLength != ( size_t ) 0 )
|
||||
{
|
||||
|
@ -909,10 +912,8 @@ size_t xOriginalTail, xReceivedLength, xNextMessageLength;
|
|||
returned to its prior state if the length of the message is too
|
||||
large for the provided buffer. */
|
||||
xOriginalTail = pxStreamBuffer->xTail;
|
||||
/* Ensure xNextMessageLength is cleared to 0 in case
|
||||
sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) != sizeof( size_t ). */
|
||||
xNextMessageLength = 0;
|
||||
( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );
|
||||
( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );
|
||||
xNextMessageLength = ( size_t ) xTempNextMessageLength;
|
||||
|
||||
/* Reduce the number of bytes available by the number of bytes just
|
||||
read out. */
|
||||
|
|
Loading…
Reference in a new issue