====== OSA : OS_Queue_Wait_TO ======
<color blue>**OS_Queue_Wait_TO (queue, os_msg_type_var, timeout)**</color>\\ 
=== ===

{{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_Queue_Wait|OS_Queue_Wait]]##. If timeout expires before message received, then stop waiting with Timeout flag set (see ##[[en:osa:ref:allservices:OS_IsTimeout|OS_IsTimeout]]##)

##[[en:osa:ref:appendix:configuration#System constants|OS_ENABLE_QUEUE]]## constant must be defined in ##[[en:osa:ref:appendix:configuration|OSAcfg.h]]##.
<note>
For PIC16, message queues can be allocated only in **bank0** or **bank1**
</note>


=== Call allowed: ===
Only in task


=== Parameters: ===
{| class = "fpl"
|-
|//''queue''//
|Queue of messages descriptor. Variable of ##[[en:osa:ref:description:data_types#OST_QUEUE|OST_QUEUE]]## 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: ===
<code cpp>
OST_QUEUE queue;

void Task (void)
{
    OST_MSG msg;
    for (;;) {
        /*...*/
        OS_Queue_Wait_TO (queue, msg, 100);
        if (!OS_IsTimeout()) {
            // Message received and stored into msg
            /*...*/
        }
        /*...*/
    }
}
</code>


=== Old style name ===
<color gray>**OS_WaitQMsgTimeout**</color>\\ 








=== See also ===
  * [[en:osa:ref:allservices:OS_Queue_Create|OS_Queue_Create]]

  * [[en:osa:ref:allservices:OS_Queue_Send|OS_Queue_Send]]
  * [[en:osa:ref:allservices:OS_Queue_Send_TO|OS_Queue_Send_TO]]
  * [[en:osa:ref:allservices:OS_Queue_Send_Now|OS_Queue_Send_Now]]


  * [[en:osa:ref:allservices:OS_Queue_Check|OS_Queue_Check]]
  * [[en:osa:ref:allservices:OS_Queue_IsFull|OS_Queue_IsFull]]

  * [[en:osa:ref:allservices:OS_Queue_Wait|OS_Queue_Wait]]

----
  * [[en:osa:ref:services:alphabetical|Alphabetical]]
  * [[en:osa:ref:services:brieflist|All services]]
~~UP~~