SerCheck

(Engine-Level Function)

Description: Check Serial Port. This function returns the immediate or cumulative serial port status.
Returns: Numeric
Usage: Script Only.
Function Groups: Serial Port
Related to: COMPort | SerBreak | SerialStream
Format: SerCheck(Port, Reset)
Parameters:  
Port
Required. Any numeric expression for the serial port number (opened with a ComPort function) or serial stream value (returned from a SerialStream function).
Reset
Required. Any logical expression. If true (non-0), the serial port status register will be cleared.
Comments: The return value consists of 9 bits that indicate the status of the following

Bit

Meaning

0

Clear To Send (CTS)

1

Data Set Ready (DSR)

2

Ring Indicator (RI)

3

Carrier Detect (CD)

4

Overrun error

5

Parity error

6

Framing error

7

Break signal detected

8

Receive buffer overflow (always cumulative)

(See: Bitwise Parameters & Operations)

Example:

If 1 Send;
[
  parityErr = Cond(And(SerCheck(2, 0), 0b00100000), 1, 0);
  IfThen(parityErr, ForceState("Retry"));
]

In this script, port 2 is checked for a parity error. If there is one, a state transfer to state Retry will occur, otherwise the destination state in the script's trigger (state Send) will be active next.