Function Block - Serial communication - using arrays of bytes.

Inputs

Input

Data type

Description

RUN

BOOL

Enable communication (opens the comm port).

CONF

STRING

Configuration of the communication port.

DATASND

USINT

Data to send - must be an array of bytes.

IXSND

DINT

Index of the first byte to send in DATASND array.

MAXSND

DINT

Number of bytes to send - see remarks.

DATARCV

DINT

Array of bytes where to store received data.

IXRCV

DINT

Index in DATASND array where to copy the first byte received.

MAXRCV

DINT

Maximum number of bytes to receive - see remarks.

Outputs

Output

Data type

Description

OPEN

BOOL

TRUE if the communication port is open.

NSND

DINT

Number of bytes sent.

NRCV

DINT

Number of bytes received.

Remarks

The RUN input does not include an edge detection. The block tries to open the port on each call if RUN is TRUE and if the port is still not successfully open. The CONF input is used for settings when opening the port. Please refer to your OEM instructions for further details about possible parameters.

On every call to the SERIO_B block, the following operations are performed:

- try to send MAXSND characters from the DATASND array, starting at the IXSND index. The NSND output contains the number of bytes actually sent during the call. It can be less than the specified MAXSND value in case system buffers are full.

- pump received characters and store them, in the DATARCV array, starting at the IXRCV index and not exceeding MAXRCV. The NRCV output contains the number of bytes actually received during the call.

The SERIO_B works asynchronously. The physical sending and receiving of characters is performed as a background by system drivers. The block simply exchange data with the FIFOs of the system drivers.


Created with the Personal Edition of HelpNDoc: Effortlessly Create Professional Documentation with HelpNDoc's Clean UI