1.4.4.6 OSAL_SEM_GetCount Function

C

uint8_t OSAL_SEM_GetCount(OSAL_SEM_HANDLE_TYPE* semID)

Summary

Returns the current value of a counting semaphore.

Description

This function returns the current value of a counting semaphore. The value returned is assumed to be a single value ranging from 0-255.

Precondition

Semaphore must have been created.

Parameters

ParamDescription
semIDPointer to the Semaphore ID

Returns

0 - Semaphore is unavailable

1-255 - Current value of the counting semaphore

Example

uint8_t semCount;

semCount = OSAL_SEM_GetCount(semUART);

if (semCount > 0)
{
    // obtain the semaphore
    if (OSAL_SEM_Pend(&semUART) == OSAL_RESULT_TRUE)
    {
        // perform processing on the comm channel
        ...
    }
}
else
{
    // no comm channels available
    ...
}

Remarks

None.