Upload
ununx13
View
141
Download
10
Embed Size (px)
DESCRIPTION
Etn002 Socket Tcpopenactive
Citation preview
_ETN002_SOCKET_TcpOpenActive (1/3)
ETN -002 Open TCP Socket Active: _ETN002_SOCKET_TcpOpenActive Basic function
Issues a request to the specified Ethernet Unit to open a TCP socket using active processing.
Symbol Start trigger
Busy Flag
↑
Unit No. TCP socket No. Keep alive designation Local TCP port No. Destination IP address #1 Destination IP address #2 Destination IP address #3 Destination IP address #4 Destination TCP port No.
Busy Flag
Normal end
Error end
Communications error code(May be omitted.)
TCP error code (May be omitted.)
Local TCP port No. (May be omitted.)
_ETN002_SOCKET_TcpOpenActive (BOOL) EN
(BOOL) ENO
(INT) UnitNo
(BOOL) BUSY
(INT) TCPSocketNo
(BOOL) OK
(INT) KeepAlive
(BOOL) NG
(INT) TCPPortNo
(WORD) CmndErrorCode
(INT) DestIPAddress1
(WORD) TcpErrorCode
(INT) DestIPAddress2
(INT) TCPPortNo
(INT) DestIPAddress3
(INT) DestIPAddress4
(INT) DestTCPPortNo
File name Lib\FBL\omronlib\PLC\ETN\_ETN002_SOCKET_TcpOpenActive10.cxf Applicable models
CS1W-ETN21 and CJ1W-ETN21 Ethernet Units
Conditions for usage
CPU Unit Settings PLC Setup: Shared Settings for Communications Instructions in FBs
• Communications Instruction Response Timeout Time (default: 2 s) • Number of retries (default: 0)
Shared Resources • Communications ports (internal logical ports)
Other • Communications must be within one network and cannot cross to another network.
Function description
A TCP socket is opened using active processing for the Ethernet Unit specified by UnitNo. The socket is connected to another node. The local TCP port number is stored in the specified results storage area when the TCP connection has been established. If communications processing produces an error, a completion code indicating the error will be output to the Communications Error Code. If TCP socket open processing produces an error, a completion code indicating the error will be output to the TCP Error Code.
FB precautions
• The FB is processed over multiple cycles. The BUSY output variable can be used to check whether the FB is being processed.
• OK or NB will be turned ON for one cycle only after processing is completed. Use these flags to detect the end of FB processing.
Timechart Start Trigger
Busy Flag (BUSY)
Normal end (OK) or Error end (NG)
FB execution completed. At normal end: Socket is opened.
ON OFF
ON OFF
ON OFF
EN input condition
Connect EN to an OR between an upwardly differentiated condition for the start trigger and the BUSY output from the FB.
Restrictions Input variables
• Always use an upwardly differentiated condition for EN. • If the input variables are out of range, the ENO Flag will turn OFF and the FB will not be processed.
Output variables
• This FB requires multiple cycles to process. Always connect an OR including the BUSY output variable to the EN input variable to ensure that the FB is processed to completion (see Symbol).
• Do not turn the BUSY output variable ON or OFF outside the FB.
_ETN002_SOCKET_TcpOpenActive (2/3)
Application example
When bit A turns ON, a TCP socket open request is issued. Bit C will turn ON when the open request has been completed.
Bit A
Bit B
↑
Bit C Processing after opening TCP socket
CPU Unit Unit No.: 0 TCP socket No.: 1 (Keep alive designation)Automatic allocation of local TCP socket Destination IP address: 196.35.32.55 Destination port No.: 4096
Ethernet Unit
Busy Flag Bit B
Normal end Bit C
Error end Bit D
Communications error code
TCP error code
Local TCP port No. D11000
Unit No.&0
TCP socket No.&1
Keep alive designation&1
Local TCP port No.&0
Destination IP address #1&196
Destination IP address #2&35
Destination IP address #3&32
Destination IP address #4&55
Destination TCP port No.&4096
D11000 Local TCP port No.
Results Storage Format
Ethernet Unit
CPU Unit
IP address: 196.35.32.55 Port No.: 4096
_ETN002_SOCKET_TcpOpenActive (BOOL) EN
(BOOL)ENO
(INT) UnitNo
(BOOL)BUSY
(INT) TCPSocketNo
(BOOL)OK
(INT) KeepAlive
(BOOL)NG
(INT) TCPPortNo
(WORD)CmndErrorCode
(INT) DestIPAddress1
(WORD)TcpErrorCode
(INT) DestIPAddress2
(INT)TCPPortNo
(INT) DestIPAddress3 (INT) DestIPAddress4 (INT) DestTCPPortNo
Related manuals
TCP/UDP Error Codes Ethernet Units Construction of Networks Operation Manual (W420)
7-3 Command/Response Reference FINS Error Codes
Communications Commands Reference Manual (W342) 5-1-3 Error Codes
_ETN002_SOCKET_TcpOpenActive (3/3)
■ Variable Tables Input Variables Name Variable name Data type Default Range Description EN EN BOOL 1 (ON): FB started.
0 (OFF): FB not started. Unit No. UnitNo INT &0 &0 to &15 The unit number of the Ethernet Unit. TCP socket No. TCPSocketNo INT &1 &1 to &8 Keep alive designation
KeepAlive INT &0 &0 to &1 &1: Keep alive &0: Don’t keep alive
Local TCP port No.
TCPPortNo INT &0 If 0 is specified, an available port number will be automatically allocated.
Destination IP address #1
DestIPAddress1r INT &0 &0 to &254
Destination IP address #2
DestIPAddress2 INT &0 &0 to &254
Destination IP address #3
DestIPAddress3 INT &0 &0 to &254
Destination IP address #4
DestIPAddress4 INT &0 &0 to &254
Destination TCP port No.
DestTCPPortNo INT &0 &1 to
Output Variables Name Variable name Data type Range Description ENO (May be omitted.)
ENO BOOL 1 (ON): FB processed normally. 0 (OFF): FB not processed or ended in an error.
Busy Flag BUSY BOOL Automatically turns OFF when processing is completed.
Normal end OK BOOL Turns ON for one cycle when processing ends normally.
Error end NG BOOL Turns ON for one cycle when processing ends in an error.
Communications error code (May be omitted.)
CmndErrorCode WORD Outputs the error code when execution ends in an error in the communications command level. Refer to the FINS Command Reference Manual (W227) for details on the error codes.
TCP error code (May be omitted.)
TcpErrorCode WORD Outputs the error code when the TCP socket operation ends in an error. Refer to 7-3 Command/Response Reference in the Ethernet Units Construction of Networks Operation Manual (W420) for details on the error codes.
Local TCP port No. (May be omitted.)
TCPPortNo INT &1 to
■ Version History Version Date Contents 1.00 2004.6. Original production