Skip to main content

7.15.8 TSEND

TSEND (Establish communication connection, send data)

Function

  • The TSEND system library is used to send specified data asynchronously.
    • No connection function is provided

Set up and establish communication connections

  • After the connection is successfully established, the user gives req a rising edge, which will trigger a data sending function;

  • The send data function TSEND only works when the communication connection has been successfully established;

  • The correct sending process requires a rising edge on the req pin first. You can see that the status word in the TSEND block changes from 0x7004 (connection has been established) → 0x7005 (data is being sent) → 0x7009 (data is sent successfully), indicating that the data has been sent successfully;

  • After giving the req pin a rising edge, if the connection is not established at this time, error = true will be displayed and the status code is 0x80A1 (the connection has not been established yet)

LD graphics

alt text

Parameter description

Interface VariablesDeclarationData TypeDescription
REQInputBOOLA data sending action is triggered only when a rising edge is recognized
LENInputUDINTSend data with length LEN. If it is 0, send all data
If it is larger than 65535 or larger than the size of DATA, an error will be reported directly
CONNECTInOutTCP_ConnectConfigFunction block instance for configuring connection parameters, see TCP_Connectconfig
DATAInOutANY_TYPEData block to be sent
DONEOutputBOOLState parameter with the following possible values:
0: Sending data has not been started or is still in progress
1: Sending data has been successfully executed
This status will only display one Cycle
BUSYOutputBOOLState parameter with the following possible values:
0: Sending data has not yet started or has been completed
1: Sending data has not yet been completed
ERROROutputBOOLState parameter with the following possible values:
0: No error
1: Error sending data
STATUSOutputWORDThe status of the current function execution process

Status code description

STATUS(WORD 16#)Description
0000Uncalled
7005In process of sending data
7009Data sent successfully
The following are exception status codesDescription
80A1The specified connection has not been established yet, used when the sending and receiving functions are activated, but the connection has not yet been established
80A4Data block is empty
80A580A5 appears for the following three reasons:
The parameter LEN is greater than 65536;
The value of LEN is greater than the size of the data block;
LEN is 0 and the size of the data block is greater than 65536
80A7Failed to obtain send buffer
80A8socket sending buffer is full
80A9Sending failed
80ACAsynchronous function enqueue failed
80C3The connection corresponding to the current TConnectConfig is already used by other TSEND blocks
80C5During the process of sending data, the peer actively disconnected

Example

  • LD example is shown in the following animation:

alt text

  • ST example is shown in the following code:
TSEND_1(
REQ:=bVar,
LEN:=0,
CONNECT:=TCP_CONNECTCONFIG_1,
DATA:=iVar,
DONE=>OUT,
BUSY=>OUT2,
ERROR=>OUT3,
STATUS=>OUT4
);
bVar:=not bvar;
iVar:= iVar+2;