Sei sulla pagina 1di 10

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

Page 1 of 10

TSEND_C: Send data via Ethernet


This chapter contains the following information:

TSEND_C: Send data via Ethernet(S7-1200)

TSEND_C: Send data via Ethernet(S7-1500)

TSEND_C: Send data via Ethernet


Description
The "TSEND_C" instruction is executed asynchronously and has the following functions:

Setting up and establishing a communications connection:


"TSEND_C" Sets up and establishes a TCP or ISO-on-TCP communications connection. Once the connection has been
set up and established, it is automatically maintained and monitored by the CPU. The connection description specified at
the CONNECT parameter is used to set up the communications connection.
To establish a connection, the CONT parameter must be set to the value "1". If connection establishment is successful,
the DONE parameter is set to "1" for one cycle. An existing connection is terminated and the connection which has been
set up is removed when the CPU goes into STOP mode. To set up and establish the connection again, you must execute
"TSEND_C" again. For information on the number of possible communication connections, please refer to the technical
specifications for your CPU.

Sending data via an existing communications connection:


You specify the send area with the DATA parameter. This includes the address and the length of the data to be sent. Do
not use a data area with the data type BOOL or Array of BOOL at the DATA parameter. If you use purely symbolic values
at the DATA parameter, the LEN parameter must have the value "0".

The send job is executed when a rising edge is detected at the REQ parameter. With the LEN parameter, you specify the
maximum number of bytes sent with a send job. When sending data (rising edge at the REQ parameter), the CONT
parameter must have the value "1" in order to establish or maintain a connection. The data to be sent must not be edited
until the send job is completed. If the send job executes successfully, the DONE parameter is set to "1". Signal state "1"
at the DONE parameter is not confirmation that the data sent has already been read by the communications partner.

Terminating the communications connection:


The communications connection is terminated when the CONT parameter is set to "0".

TSEND_C is executed again when the COM_RST parameter is set to "1". This terminates the existing communications
connection and a new connection is established. If data is being transferred when it executes again, this can lead to a loss of
data.
To enable "TSEND_C" again after the execution (DONE = 1), call the instruction once with REQ = 0.
Parameter
The following table shows the parameters of the "TSEND_C" instruction:
Parameter

Declaration

Data type

Memory area

Description

REQ

Input

BOOL

I, Q, M, D, L

Starts the send job on a rising edge.

CONT

Input

BOOL

I, Q, M, D, L

Controls the communications connection:

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

0: Disconnect the communications

01/11/2016

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

Page 2 of 10

connection

1: Establish and maintain the


communications connection

When sending data (rising edge at the REQ


parameter), the CONT parameter must have the
value TRUE in order to establish or maintain a
connection.
LEN

Input

UINT

I, Q, M, D, L or
constant

Maximum number of bytes to be sent with the


job. If you use purely symbolic values at the
DATA parameter, the LEN parameter must have
the value "0".

CONNECT

InOut

TCON_Param

Pointer to the connection description


See also: Connection parameters with structure
according to TCON_Param

DATA

InOut

VARIANT

I, Q, M, D, L

Pointer to the send area containing the address


and the length of the data to be sent.

COM_RST

InOut

BOOL

I, Q, M, D, L

Restarts the instruction:

DONE

BUSY

ERROR

STATUS

Output

Output

Output

Output

BOOL

BOOL

BOOL

WORD

I, Q, M, D, L

I, Q, M, D, L

I, Q, M, D, L

I, Q, M, D, L

0: Irrelevant

1: Complete restart of the instruction causing


an existing connection to be terminated and
a new connection to be established.

Status parameter with the following values:

0: Job not yet started or still in progress

1: Job executed without errors

Status parameter with the following values:

0: Job not yet started or already completed

1: Job not yet completed. A new job cannot


be started.

Status parameter with the following values:

0: No error

1: Error occurred

Status of the instruction

You will find more detailed information on valid data types in "Overview of the valid data types".
Parameters BUSY, DONE, and ERROR
You can check the status of the execution with the BUSY, DONE, ERROR, and STATUS parameters. The BUSY parameter
indicates the processing status. With the DONE parameter, you can check whether or not a job executed successfully. The
ERROR parameter is set when errors occurred during execution of "TSEND_C". The error information is output at the
STATUS parameter.
The following table shows the relationship between the BUSY, DONE, and ERROR parameters:

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

01/11/2016

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

Page 3 of 10

BUSY

DONE

ERROR

Description

The job is being processed.

The job was completed successfully.

The job ended with an error. The cause of the error is specified in the STATUS
parameter.

No new job was assigned.

Parameters ERROR and STATUS


ERROR

STATUS*

Description

(W#16#...)
0

0000

Job executed without errors

7000

No job processing active

7001

Start execution of the job

Establish connection

Wait for connection partner

7002

Data are being sent

7003

Connection is terminated

7004

Connection established and monitored, no job processing active.

80A0

Group error for error codes 80A1 and 80A2.

80A1

Connection or port already being used by user.

Communication error:

The specified connection has not yet been established.

The specified connection is being terminated. Transfer via this connection is not
possible.

The interface is being re-initialized.

80A2

Local or remote port is being used by the system.

80A3

Attempt being made to terminate a non-existent connection.

80A4

IP address of the remote endpoint of the connection is invalid, which means it corresponds to
the IP address of the local partner.

80A7

Communication error: You called the instruction with COM_RST = 1 before the send job was
complete.

80B2

The CONNECT parameter points to a data block that was generated with the attribute "Only
store in load memory".

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

01/11/2016

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

Page 4 of 10

80B3

Inconsistent parameter assignment: Group error for error codes 80A0 to 80A2, 80A4, 80B4
to 80B9.

80B4

You have violated one or both of the following conditions for passive connection
establishment (active_est = FALSE) when using the ISO-on-TCP protocol variant
(connection_type = B#16#12): "local_tsap_id_len >= B#16#02", and/or "local_tsap_id[1] =
B#16#E0".

80B5

Only passive connection establishment is permitted for connection type 13 = UDP.

80B6

Parameter assignment error in the connection_type parameter of the data block for
connection description.

80B7

Error in one of the following parameters of the data block for connection description:
block_length, local_tsap_id_len, rem_subnet_id_len, rem_staddr_len, rem_tsap_id_len,
next_staddr_len.

8085

The LEN parameter is larger than the highest permitted value.

8086

The ID parameter within the CONNECT parameter is outside the permitted range.

8087

Maximum number of connections reached; no additional connection possible.

8088

The value at the LEN parameter does not correspond to the receive area set at the DATA
parameter.

8089

The CONNECT parameter does not point to a data block.

8091

Maximum nesting depth exceeded.

809A

The CONNECT parameter points to a field that does not correspond to the length of the
connection description.

809B

The ID of the local device in the connection description does not correspond to the CPU.

80C3

80C4

All connection resources are in use.

A block with this ID is already being processed in a different priority group.

Temporary communication error:

The connection cannot be established at this time.

The interface is receiving new parameters or the connection is being established.

The configured connection is being removed by a "TDISCON" instruction.

The connection used is being terminated by a call with COM_RST= 1.

8722

CONNECT parameter: The source area is invalid. The area does not exist in the DB.

873A

CONNECT parameter: Access to the connection description is not possible (for example, DB
does not exist).

877F

CONNECT parameter: Internal error.

8822

DATA parameter: Invalid source area, the area does not exist in the DB.

8824

DATA parameter: Area error in the VARIANT pointer.

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

01/11/2016

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

Page 5 of 10

8832

DATA parameter: The DB number is too high.

883A

CONNECT parameter: Access to specified connection data not possible (e.g. because the
DB does not exist).

887F

DATA parameter: Internal error, e.g. invalid VARIANT reference.

893A

DATA parameter: Access to send area not possible (e.g. because the DB does not exist).

* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Note
Error messages of the instructions "TCON", "TSEND" and "TDISCON"
Internally, the TRV_C instruction uses the "TCON", "TSEND" and "TDISCON" instructions. The error messages of these
instructions are contained in the respective descriptions.

TSEND_C: Send data via Ethernet


Description
The "TSEND_C" instruction is executed asynchronously and implements the following functions in sequence:
1.

Setting up and establishing a communications connection:


"TSEND_C" sets up a communication connection and establishes this connection if a rising edge is detected at the REQ
parameter and no communication connection is in place yet. Once the connection has been set up and established, it is
automatically maintained and monitored by the CPU. The connection description specified at the CONNECT parameter
is used to set up the communications connection. The following connection types can be used:

TCP / UDP: Connection description via the structure TCON_IP_v4 at the parameter CONNECT

ISO-on-TCP: Connection description via the structure TCON_IP_RFC at the parameter CONNECT

ISO: Connection description via the structure TCON_ISOnative at the parameter CONNECT (only for CP1543-1)

FDL: Connection description via the structure TCON_FDL at the parameter CONNECT (only for CM1542-5)

An existing connection is terminated and the connection which has been set up is removed when the CPU goes into
STOP mode. To set up and establish the connection again, you must execute "TSEND_C" again. For information on the
number of possible communication connections, please refer to the technical specifications for your CPU.
2.

Sending data via an existing communications connection:


The send job is executed when a rising edge is detected at the REQ parameter. As described above, the
communications connection is established first. You specify the send area with the DATA parameter. This includes the
address and the length of the data to be sent. Do not use a data area with the data type BOOL or Array of BOOL at the
DATA parameter. With the LEN parameter, you specify the maximum number of bytes sent with a send job. If you use
purely symbolic values at the DATA parameter, the LEN parameter must have the value "0".
The data to be sent must not be edited until the send job is completed.

3.

Terminating the communications connection:


The communications connection is terminated after the data has been sent if the CONT parameter had the value "0" at
the time of the rising edge at the REQ parameter. Otherwise, the communications connection will be maintained.

If the send job executes successfully, the DONE parameter is set to "1". The communications connection may be terminated

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

01/11/2016

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

Page 6 of 10

before this (see the above description of the dependency on the CONT parameter). Signal state "1" at the DONE parameter
is not confirmation that the data sent has already been read by the communications partner.
TSEND_C is reset when the COM_RST parameter is set to "1". Data loss may occur if data is being transferred at this point.
The following scenarios are possible depending on the CONT parameter:

CONT = "0":
An existing communications connection is established.

CONT = "1" and a communications connection was established:


An existing communications connection is reset and established again.

CONT = "1" and no communications connection was established.


No communications connection is established.

The COM_RST parameter is reset following evaluation by the instruction "T_SEND". To enable "TSEND_C" again after the
execution (DONE = 1), call the instruction once with REQ = 0.
Parameters
The following table shows the parameters of the "TSEND_C" instruction:
Parameter

Declaration

Data type

Memory area

Description

REQ

Input

BOOL

I, Q, M, D, L, T,
C or constant

Starts the send job on a rising edge.

CONT

Input

BOOL

I, Q, M, D, L

Controls the communications connection:

0: Establish connection automatically.


Terminate communications connection after
data is sent.

1: Terminate communications connection


after data has been received.

The CONT parameter is only evaluated upon a


positive edge at REQ or when COM_RST = "1".
LEN

CONNECT

Input

InOut

UDINT

VARIANT

I, Q, M, D, L or
constant

Optional parameter (hidden)

Pointer to the connection description


corresponding to the structure of connection to
be described.

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

Maximum number of bytes to be sent with the


job. If you use purely symbolic values at the
DATA parameter, the LEN parameter must have
the value "0".

For TCP or UDP, use the structure


TCON_IP_v4

For description, refer to:Connection


parameters with structure according to
TCON_IP_v4

For ISO-on-TCP, use the structure


TCON_IP_RFC

For description, refer to: Connection

01/11/2016

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

Page 7 of 10

parameters with structure according to


TCON_IP_RFC

For ISO, use the structure TCON_ISOnative


(only for CP1543-1)

For description, refer to instruction "TCON":


"Structure of the connection description
according to TCON_ISOnative"

For FDL, use the structure TCON_FDL (only


for CM1542-5)
For the description, refer to instruction
"TCON": "Structure of the connection
description according to TCON_FDL"

The CONNECT parameter is only evaluated


upon a positive edge at REQ or when
COM_RST = 1.
DATA

InOut

VARIANT

I, Q, M, D, L

Pointer to the send area containing the address


and the length of the data to be sent.

ADDR

InOut

VARIANT

Optional parameter (hidden)


Pointer to the address of the recipient with the
connection type UDP. The address information
is mapped in the structure TADDR_Param ###.

COM_RST

InOut

BOOL

I, Q, M, D, L

Optional parameter (hidden)


Restarts the instruction:

0: Irrelevant

1: Completely restarts the instruction; the


existing connection is either terminated or
reset and established again in accordance
with CONT.

The COM_RST parameter is reset after


evaluation by the "T_SEND_C" instruction and
should not, therefore, be switched statically.
DONE

BUSY

ERROR

Output

Output

Output

BOOL

BOOL

BOOL

I, Q, M, D, L

I, Q, M, D, L

I, Q, M, D, L

Status parameter with the following values:

0: Send job not yet started or is still


executing.

1: Send job executed without errors. This


state is only displayed for one cycle.

Status parameter with the following values:

0: Send job not yet started or already


completed.

1: Send job not yet completed. A new send


job cannot be started.

Status parameter with the following values:

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

0: No error

01/11/2016

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

Page 8 of 10

STATUS

Output

WORD

I, Q, M, D, L

1: Error occurred during connection


establishment, data transmission or
connection termination.

Status of instruction (see the "ERROR and


STATUS" parameters" description).

You will find more detailed information on valid data types in "Overview of the valid data types".
Parameters BUSY, DONE, and ERROR
You can check the status of the execution with the BUSY, DONE, ERROR, and STATUS parameters. The BUSY parameter
indicates the processing status. With the DONE parameter, you can check whether or not a send job executed successfully.
The ERROR parameter is set when errors occurred during execution of "TSEND_C". The error information is output at the
STATUS parameter.
The following table shows the relationship between the BUSY, DONE, and ERROR parameters:
BUSY

DONE

ERROR

Description

The send job is being processed.

The send job was completed successfully.

The connection establishment or the send job was completed with an error. The cause
of the error is specified in the STATUS parameter.

No new send job was assigned.

Parameters ERROR and STATUS


ERROR

STATUS*

Description

(W#16#...)
0

0000

Send job was executed without errors.

7000

No active send job execution; no communications connection established.

7001

Start send job execution.

Establish connection.

Wait for connection partner.

7002

Data are being sent.

7003

Communications connection is being terminated.

7004

Communications connection established and monitored; no send job execution active.

7005

Communications connection is being reset.

80A0

Group error for error codes 80A1 and 80A2.

80A1

Connection or port already being used by user.

Communication error:

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

01/11/2016

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

The specified connection has not yet been established.

The specified connection is being terminated.

Page 9 of 10

Transfer via this connection is not possible.

The interface is being re-initialized.

80A2

Local or remote port is being used by the system.

80A3

Attempt being made to terminate a non-existent connection.

80A4

IP address of the remote endpoint of the connection is invalid, which means it corresponds to
the IP address of the local partner.

80A7

Communication error: You called the instruction with COM_RST = 1 before the send job was
complete.

80B2

The CONNECT parameter points to a data block that was generated with the attribute "Only
store in load memory".

80B3

Inconsistent parameter assignment: Group error for error codes 80A0 to 80A2, 80A4, 80B4
to 80B9.

80B4

You have violated one or both of the following conditions for passive connection
establishment (active_est = FALSE) when using the ISO-on-TCP protocol variant
(connection_type = B#16#12):

local_tsap_id_len >= B#16#02

local_tsap_id[1] = B#16#E0

80B5

Only passive connection establishment is permitted for connection type 13 = UDP.

80B6

Parameter assignment error in the connection_type parameter of the data block for
connection description.

80B7

Error in one of the following parameters of the data block for connection description:
block_length, local_tsap_id_len, rem_subnet_id_len, rem_staddr_len, rem_tsap_id_len,
next_staddr_len.

8085

The LEN parameter is larger than the highest permitted value.

8086

The ID parameter within the CONNECT parameter is outside the permitted range.

8087

Maximum number of connections reached; no additional connection possible.

8088

The value at the LEN parameter does not correspond to the receive area set at the DATA
parameter.

8089

The CONNECT parameter does not point to a data block.

8091

Maximum nesting depth exceeded.

809A

The CONNECT parameter points to a field that does not correspond to the length of the
connection description.

809B

The ID of the local device in the connection description does not correspond to the CPU.

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

01/11/2016

TSEND_C: Send data via Ethernet(S7-1200,S7-1500)

80C3

80C4

Page 10 of 10

All connection resources are in use.

A block with this ID is already being processed in a different priority group.

Temporary communication error:

The connection cannot be established at this time.

The interface is receiving new parameters or the connection is being established.

The configured connection is being removed by a "TDISCON" instruction.

The connection used is being terminated by a call with COM_RST = 1.

8722

CONNECT parameter: The source area is invalid. The area does not exist in the DB.

873A

CONNECT parameter: Access to the connection description is not possible (for example,
because DB does not exist).

877F

CONNECT parameter: Internal error.

8822

DATA parameter: Invalid source area, the area does not exist in the DB.

8824

DATA parameter: Area error in the VARIANT pointer.

8832

DATA parameter: The DB number is too high.

883A

CONNECT parameter: Access to specified connection data not possible (e.g. because the
DB does not exist).

887F

DATA parameter: Internal error, e.g. invalid VARIANT reference.

893A

DATA parameter: Access to send area not possible (e.g. because the DB does not exist).

* The error codes can be displayed as integer or hexadecimal values in the program editor. For additional information on
toggling display formats, refer to "See also".
Note
Error messages of the instructions "TCON", "TSEND" and "TDISCON"
Internally, the TRV_C instruction uses the "TCON", "TSEND" and "TDISCON" instructions. The error messages of these
instructions are contained in the respective descriptions.

file://C:\Users\TOP\AppData\Local\Temp\~hh5203.htm

01/11/2016

Potrebbero piacerti anche