SerialLineControl

SerialLineControl 1:

The SerialLineControl function block looks after the communication between a serial interface (KL60xx, EL60xx or COM interface) and the PLC. The function block is called cyclically, and places received data into the RxBuffer. Data made available in the TxBuffer transmit buffer is sent to the interface at the same time.

Because the function operates independently of the application, it is referred to as background communication and can, particularly in the case of serial bus terminals, also operate in a fast task (see Communication concept and Supported hardware).

SerialLineControl 2: Inputs

VAR_INPUT
  Mode             : ComSerialLineMode_t;
  pComIn           : POINTER TO BYTE;
  pComOut          : POINTER TO BYTE;
  SizeComIn        : INT;
END_VAR

Name

Type

Description

Mode

ComSerialLineMode_t

The Mode input specifies unambiguously which serial hardware is being used.

pComIn

POINTER TO BYTE

Universal pointer to the input variable of the process data for the serial hardware (data types: PcComInData, EL6inData22b, KL6inData, KL6inData5b, KL6inData22b). The pointer is assigned with the ADR() function.

pComOut

POINTER TO BYTE

Universal pointer to the output variable of the process data for the serial hardware (data types: PcComOutData, EL6outData22b, KL6outData, KL6outData5b, KL6outData22b). The pointer is assigned with the ADR() function.

SizeComIn

INT

Size of the input process image of the serial hardware being used. The size is determined and assigned with the SIZEOF() function.

SerialLineControl 3: Inputs/outputs

VAR_IN_OUT
  TxBuffer         : ComBuffer;
  RxBuffer         : ComBuffer;
END_VAR

Name

Type

Description

TxBuffer

ComBuffer

Send data buffer that corresponds to the interface used. The buffer is filled by functions such as SendByte, SendData or SendString.

RxBuffer

ComBuffer

Receive data buffer corresponding to the interface in use. The buffer is read by functions such as ReceiveByte, ReceiveData and ReceiveString.

SerialLineControl 4: Outputs

VAR_OUTPUT
  Error      : BOOL;
  ErrorID    : ComError_t;
END_VAR

Name

Type

Description

Error

BOOL

This output Error goes TRUE as soon as an error occurs.

ErrorID

ComError_t

The ErrorID output provides an error code when an error occurs.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4012

PC or CX (ARM, x86, x64)

Tc2_SerialCom