1.1.9.4.13 DRV_USART_ReadQueuePurge Function

C

bool DRV_USART_ReadQueuePurge( const DRV_HANDLE handle )

Summary

Removes all buffer requests from the queue for the given client and also aborts the on-going read request.

Description

This function removes all the buffer requests from the queue and aborts the on-going read request that is submitted to the PLIB.

The client can use this function to purge the queue on timeout or to remove unwanted stalled buffer requests or in any other use case.

Precondition

DRV_USART_Open must have been called to obtain a valid opened device handle.

Parameters

ParamDescription
handleHandle of the communication channel as returned by the DRV_USART_Open function.

Returns

true - Read queue purge is successful.

false - Read queue purge has failed.

Example

// myUSARTHandle is the handle returned by the DRV_USART_Open function.
// Use DRV_USART_ReadBufferAdd to queue read requests

// Application timeout function, where remove queued buffers.
void APP_TimeOut(void)
{
    if(DRV_USART_ReadQueuePurge(myUSARThandle) == false)
    {
        //Couldn't purge the read queue, try again.
    }
    else
    {
        //Queue purge successful.
    }
}

Remarks

This function is thread safe when used in an RTOS environment. Avoid this function call from within the callback.