| 1682 | /*-----------------------------------------------------------*/ |
| 1683 | |
| 1684 | BaseType_t xQueuePeek( QueueHandle_t xQueue, |
| 1685 | void * const pvBuffer, |
| 1686 | TickType_t xTicksToWait ) |
| 1687 | { |
| 1688 | BaseType_t xEntryTimeSet = pdFALSE; |
| 1689 | TimeOut_t xTimeOut; |
| 1690 | int8_t * pcOriginalReadPosition; |
| 1691 | Queue_t * const pxQueue = xQueue; |
| 1692 | |
| 1693 | /* Check the pointer is not NULL. */ |
| 1694 | configASSERT( ( pxQueue ) ); |
| 1695 | |
| 1696 | /* The buffer into which data is received can only be NULL if the data size |
| 1697 | * is zero (so no data is copied into the buffer. */ |
| 1698 | configASSERT( !( ( ( pvBuffer ) == NULL ) && ( ( pxQueue )->uxItemSize != ( UBaseType_t ) 0U ) ) ); |
| 1699 | |
| 1700 | /* Cannot block if the scheduler is suspended. */ |
| 1701 | #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) |
| 1702 | { |
| 1703 | configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); |
| 1704 | } |
| 1705 | #endif |
| 1706 | |
| 1707 | /*lint -save -e904 This function relaxes the coding standard somewhat to |
| 1708 | * allow return statements within the function itself. This is done in the |
| 1709 | * interest of execution time efficiency. */ |
| 1710 | for( ; ; ) |
| 1711 | { |
| 1712 | taskENTER_CRITICAL(); |
| 1713 | { |
| 1714 | const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; |
| 1715 | |
| 1716 | /* Is there data in the queue now? To be running the calling task |
| 1717 | * must be the highest priority task wanting to access the queue. */ |
| 1718 | if( uxMessagesWaiting > ( UBaseType_t ) 0 ) |
| 1719 | { |
| 1720 | /* Remember the read position so it can be reset after the data |
| 1721 | * is read from the queue as this function is only peeking the |
| 1722 | * data, not removing it. */ |
| 1723 | pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom; |
| 1724 | |
| 1725 | prvCopyDataFromQueue( pxQueue, pvBuffer ); |
| 1726 | traceQUEUE_PEEK( pxQueue ); |
| 1727 | |
| 1728 | /* The data is not being removed, so reset the read pointer. */ |
| 1729 | pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition; |
| 1730 | |
| 1731 | /* The data is being left in the queue, so see if there are |
| 1732 | * any other tasks waiting for the data. */ |
| 1733 | if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) |
| 1734 | { |
| 1735 | if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) |
| 1736 | { |
| 1737 | /* The task waiting has a higher priority than this task. */ |
| 1738 | queueYIELD_IF_USING_PREEMPTION(); |
| 1739 | } |
| 1740 | else |
| 1741 | { |
no test coverage detected