The semValue() function will return the current value of the specified semaphore.
Input:
sem : SEMAPHORE
The semaphore to query.
Returns: INT
-1
|
Semaphore not initialized.
|
>=0
|
Value of the semaphore.
|
Declaration:
FUNCTION semValue : INT;
VAR_INPUT
sem : SEMAPHORE;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR
sem : SEMAPHORE;
END_VAR;
PROGRAM test;
...
sem := semInit(initval:=3);
IF semValue(sem:=sem) = -1 THEN DebugMsg(message:="sem failed to init!"); END_IF;
...
BEGIN
...
IF semWait(sem:=sem,timeout:=1000) = 0 THEN
...
semSignal(sem:=sem);
END_IF;
...
END;
END_PROGRAM;
|