| 854 | /*-----------------------------------------------------------*/ |
| 855 | |
| 856 | size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) |
| 857 | { |
| 858 | StreamBuffer_t * const pxStreamBuffer = xStreamBuffer; |
| 859 | size_t xReturn, xBytesAvailable, xOriginalTail; |
| 860 | configMESSAGE_BUFFER_LENGTH_TYPE xTempReturn; |
| 861 | |
| 862 | configASSERT( pxStreamBuffer ); |
| 863 | |
| 864 | /* Ensure the stream buffer is being used as a message buffer. */ |
| 865 | if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER ) != ( uint8_t ) 0 ) |
| 866 | { |
| 867 | xBytesAvailable = prvBytesInBuffer( pxStreamBuffer ); |
| 868 | |
| 869 | if( xBytesAvailable > sbBYTES_TO_STORE_MESSAGE_LENGTH ) |
| 870 | { |
| 871 | /* The number of bytes available is greater than the number of bytes |
| 872 | * required to hold the length of the next message, so another message |
| 873 | * is available. Return its length without removing the length bytes |
| 874 | * from the buffer. A copy of the tail is stored so the buffer can be |
| 875 | * returned to its prior state as the message is not actually being |
| 876 | * removed from the buffer. */ |
| 877 | xOriginalTail = pxStreamBuffer->xTail; |
| 878 | ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, xBytesAvailable ); |
| 879 | xReturn = ( size_t ) xTempReturn; |
| 880 | pxStreamBuffer->xTail = xOriginalTail; |
| 881 | } |
| 882 | else |
| 883 | { |
| 884 | /* The minimum amount of bytes in a message buffer is |
| 885 | * ( sbBYTES_TO_STORE_MESSAGE_LENGTH + 1 ), so if xBytesAvailable is |
| 886 | * less than sbBYTES_TO_STORE_MESSAGE_LENGTH the only other valid |
| 887 | * value is 0. */ |
| 888 | configASSERT( xBytesAvailable == 0 ); |
| 889 | xReturn = 0; |
| 890 | } |
| 891 | } |
| 892 | else |
| 893 | { |
| 894 | xReturn = 0; |
| 895 | } |
| 896 | |
| 897 | return xReturn; |
| 898 | } |
| 899 | /*-----------------------------------------------------------*/ |
| 900 | |
| 901 | size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, |
no test coverage detected