====== OSA : OS_Wait_TO ======
**OS_Wait_TO (condition, timeout)**\\
=== ===
{{osa:ref:attr_call_task.png|Allowed only in task}}{{osa:ref:attr_call_ct_sw.png|Switches context}}{{osa:ref:attr_call_to.png|Uses timer}}
Wait until //condition// is true. If timeout expires before this event occurs, then stop waiting with Timeout flag set (see ##[[en:osa:ref:allservices:OS_IsTimeout|OS_IsTimeout]]##)
=== Call allowed: ===
Only in task
=== Parameters: ===
{| class = "fpl"
|-
|//''condition''//
|Any boolean expression
|-
|//''timeout''//
|Time of waiting in system ticks - calling ##[[en:osa:ref:allservices:OS_Timer|OS_Timer]]## periods
|}
=== Returns: ===
{| class = "fpl"
|-
|//''timeout''//
|If timeout expired then system service ##[[en:osa:ref:allservices:OS_IsTimeout|OS_IsTimeout]]## will return **true**
|}
=== Example: ===
void Task (void)
{
for (;;) {
/*...*/
OS_Wait_TO(RB1 == 1, 50); // Wait 50 ticks for RB1 == 1
if (!OS_IsTimeout()) {
//
/*...*/
}
/*...*/
}
}
=== Old style name ===
**OS_WaitConditionTimeout**\\
**OS_Cond_Wait_TO**\\
=== See also ===
----
* [[en:osa:ref:services:alphabetical|Alphabetical]]
* [[en:osa:ref:services:brieflist|All services]]
~~UP~~