====== OSA : OS_Msg_Wait_TO ======
**OS_Msg_Wait_TO (msg_cb, os_msg_type_var, 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}}
Same as ##[[en:osa:ref:allservices:OS_Msg_Wait|OS_Msg_Wait]]##. If timeout expires before 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"
|-
|//''msg_cb''//
|Pointer to message descriptor. Variable of ##[[en:osa:ref:description:data_types#OST_MSG_CB|OST_MSG_CB]]## type
|-
|//''os_msg_type_var''//
|Variable of ##[[en:osa:ref:description:data_types#OST_MSG|OST_MSG]]## type, where pointer to message will be placed
|-
|//''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: ===
OST_MSG_CB msg_cb;
void Task (void)
{
OST_MSG msg;
for (;;) {
/*...*/
OS_Msg_Wait_TO (msg_cb, msg, 100); // wait 100 ticks for message
if (!OS_IsTimeout()) {
// Message received and stored into msg
/*...*/
}
/*...*/
}
}
=== Old style name ===
**OS_WaitMsgTimeout**\\
=== See also ===
* [[en:osa:ref:allservices:OS_Msg_Create|OS_Msg_Create]]
* [[en:osa:ref:allservices:OS_Msg_Send|OS_Msg_Send]]
* [[en:osa:ref:allservices:OS_Msg_Send_TO|OS_Msg_Send_TO]]
* [[en:osa:ref:allservices:OS_Msg_Send_Now|OS_Msg_Send_Now]]
* [[en:osa:ref:allservices:OS_Msg_Check|OS_Msg_Check]]
* [[en:osa:ref:allservices:OS_Msg_Accept|OS_Msg_Accept]]
* [[en:osa:ref:allservices:OS_Msg_Wait|OS_Msg_Wait]]
----
* [[en:osa:ref:services:alphabetical|Alphabetical]]
* [[en:osa:ref:services:brieflist|All services]]
~~UP~~