SysGetSerialCTS, get serial CTS signal status

List

This page is part of the IEC 61131-3 Programming Manual. Go to the index.

This function returns the status of the CTS signal of the serial port connected to the File parameter, previously opened with the FB SysSerialPort.

information circle

Function

CODESYS: Not available

LogicLab: eLLabXUnified12Lib

Description

File (FILEP) Stream data stream returned by the FB SysSerialPort.

The function returns a (BOOL) FALSE CTS signal not active, TRUE active CTS signal.

Image F SysGetSerialCTS

Examples

How to use the examples.
In the following example, a serial communication port is opened and the state of the CTS signal is acquired, which is placed on the variable CTSIn. The execution error control is managed in the program by checking if the last error has ObjectID 9993, relating to the function.

LogicLab (Ptp116), ST_SysGetSerialCTS
PROGRAM ST_SysGetSerialCTS
VAR
    CTSIn : BOOL; (* CTS signal status *)
    IsError : BOOL; (* Execution error *)
    Sp : SysSerialPort; (* Serial port management *)
END_VAR

// *****************************************************************************
// PROGRAM "ST_SysGetSerialCTS"
// *****************************************************************************
// The program allows to read the status of the serial CTS signal.
// -----------------------------------------------------------------------------

    // -------------------------------------------------------------------------
    // INITIALIZATION
    // -------------------------------------------------------------------------

    IF (SysFirstLoop) THEN
        Sp.COM:=ADR('COM0'); //COM port definition
        Sp.Baudrate:=19200; //Baudrate
        Sp.Parity:='E'; //Parity
        Sp.DataBits:=8; //Data bits
        Sp.StopBits:=1; //Stop bits
        Sp.DTRManagement:=DTR_AUTO_WO_TIMES; //DTR management
        Sp.DTRComplement:=FALSE; //DTR complement
        Sp.EchoFlush:=FALSE; //Received echo flush
        Sp.DTROnTime:=0; //DTR On time delay (mS)
        Sp.DTROffTime:=0; //DTR Off time delay (mS)
        Sp.FlushTm:=0; //Flush time (mS)
        Sp.RxSize:=0; //Rx buffer size
        Sp.TxSize:=0; //Tx buffer size
    END_IF;

    // -------------------------------------------------------------------------
    // DTR MANAGEMENT
    // -------------------------------------------------------------------------
    // The DTR signal is managed.

    Sp(Open:=TRUE); //Serial port management
    IF (Sp.Opened) THEN
       CTSIn:=SysGetSerialCTS(Sp.File); //CTS signal status

        // To check if execution error, check if the return is FALSE and last
        // error code has the function ObjectID.

        IF NOT(CTSIn) THEN 
            IsError:=((SysGetLastError(TRUE)/1000) = 9993); //Execution error
        END_IF;
    END_IF;

// [End of File]
Was this article helpful?