SerIn

(Engine-Level Function)

Description: Get Serial Port Byte. This function returns the next byte in the receive buffer.
Returns: Byte
Usage: Script Only.
Function Groups: Serial Port
Related to: COMPort | SerCheck | StrLen | SerOut | SerRcv | SerRTS | SerSend | SerStrEsc | SerString | SerWait
Format:  SerIn(Port, Peek)
Parameters:  
Port
Required. Any numeric expression for the serial port number (opened with a ComPort function) or any stream value.
Peek
Required. Any status expression to control whether the byte being read should also be removed from the receive buffer.
If Peek is true, the byte is not removed from the receive buffer.
Comments: If no byte is available, the return value is invalid.

Example:

If 1 Continue;
[
  chkSum = SerIn(2, 0);
  IfThen(! Valid(chkSum), ForceState("Wait"));
]

This reads one byte from the receive buffer for serial port 2. If none is available, chkSum will be invalid. Notice that the next state to become active is dependent on whether a byte has been successfully read.