1.4.4.6 OSAL_SEM_GetCount Function
1.4.4.6 C
uint8_t OSAL_SEM_GetCount(OSAL_SEM_HANDLE_TYPE* semID)
1.4.4.6 Summary
Returns the current value of a counting semaphore.
1.4.4.6 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.
1.4.4.6 Precondition
Semaphore must have been created.
1.4.4.6 Parameters
| Parameters | Description |
|---|---|
| semID | Pointer to the Semaphore ID |
1.4.4.6 Returns
0 - Semaphore is unavailable.
1-255 - Current value of the counting semaphore.
1.4.4.6 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
...
}
1.4.4.6 Remarks
None.
