Querying the count value of a counting semaphore

jim-frenzel wrote on Tuesday, October 27, 2015:

I am running FreeRTOS version 8.2.2 and am wondering why there is no function provided to get the count value of a counting semaphore. While I did find a workaround - cast the handle as a queue handle and use uxQueueMessages Waiting() - it seems like having a dedicated function would be worthwhile. Any thoughts?

rtel wrote on Tuesday, October 27, 2015:

Any of the queue functions can be used on semahores too. I can add a “get current count” macro that calls the queue function.

Regards.

jim-frenzel wrote on Tuesday, October 27, 2015:

I think that would be great - particularly if it found its way into the documentation. :slight_smile:

rtel wrote on Wednesday, October 28, 2015:

I have added the line:

#define xSemaphoreGetCount( xSemaphore ) uxQueueMessagesWaiting( (
QueueHandle_t ) ( xSemaphore ) )

but not checked it in yet. It will get checked in after it has been tested.

Regards.