
After this function call, the task from which this function is called
is switched to the "wait state" until specified condition is
satisfied. For this reason, this function especially suits with
communication tasks.
This function is used for following purposes.
(1) Wait for transmit completion
ret = rs_wait( channel, param, trx_size, time_out ) ;
This waits for the number of untransmitted characters in the
transmit buffer to become less than or equal to the specified
value given by "param".
If param = 0, above function call waits for the completion of
transmission. This is used to know that whole data is sent to
the destination.
By setting param as param="Tx buffer size" - "Tx data size",
above function call informs that there is enough space in the
transmit buffer to accept new data. This is useful for
efficient data transmission.
(2) Wait for data to come
ret = rs_wait( channel, param, rtx_size, time_out ) ;
This waits for the number of received characters in the
receive buffer to become greater than or equal to the
specified value given by "param". This is efficient compared
to the polling method.
In case of fixed length data communication,
specify as param="packet size" to know that a set of data has
been received. If it is expected to know that a data of
whatever size has been received, specify param as "1".
(3) Wait for specified character
ret = rs_wait( channel, param, rtx_code, time_out ) ;
This function call waits for the character specified by
"param" to arrive.
This function is used for the case to know the arrival of the
data packet which ends with specific code.
Above wait state finishes when receiving data ,which arrives
after rs_wait() is called, matches the character specified by
"param". Those data, which have arrived before the execution
of this function and are not yet read by the application, are
not examined for character matching.
Specifying the maximum wait time by "time_out" avoids application
program to hang up when no answer comes back from the external device.
There can be some problem in the communication interface when time-out
error occurs. In this case, examine the state of the interface by
using rs_buffer() function or rs_status() function.