version 3
SET TIMEOUT (seconds)
Parameter | Type | Description | |
seconds | Number | Seconds until the timeout |
Description
SET TIMEOUT specifies how much time a serial port command has to complete. If the serial port command does not complete within the specified time, seconds, the serial port command is canceled, an error -9990 is generated, and the OK system variable is set to 0. You can catch the error with an error-handling method installed using ON ERR CALL.
Note that the time is the total time allowed for the command to execute, not the time between characters received. To cancel a previous setting and stop monitoring serial port communication, use a setting of 0 for seconds.
The commands that are affected by the timeout setting are:
Example
The following example sets the serial port to receive data. It then sets a time-out. The data is read with RECEIVE PACKET. If the data is not received in time, an error occurs:
SET CHANNEL (MacOS Serial Port; Speed 9600 + Data Bits 8 + Stop Bits One + Parity None) ` Open Serial Port SET TIMEOUT (10) ` Set the timeout for 10 seconds ON ERR CALL ("CATCH COM ERRORS") ` Do not let the method being interrupted RECEIVE PACKET (vtBuffer; Char (13)) ` Read until a carriage return is met If (OK=0) ALERT ("Error receiving data.") Else [People]Name:=vtBuffer ` Save received data in a field End if ON ERR CALL("")
See Also
ON ERR CALL, RECEIVE BUFFER, RECEIVE PACKET, RECEIVE RECORD, RECEIVE VARIABLE.