6-3
Section
Using Socket Services with CMND(490)
133
6-3-6 UDP/IP Communications Programming Example
The following programming example illustrates transferring 100 bytes of data
between an Ethernet Unit and a host computer using UDP/IP communications.
System Configuration
The system configuration for the program example and the Ethernet Unit system
setup are shown below.
Host computer
Ethernet Unit
IP address:
196.36.32.55
Port number: 4096
IP address:
196.36.32.101
Port number:
4096
FINS network address: 01 Hex
Node address:
01 Hex
Unit number:
10 Hex
PC
Basic Operations
•
CIO 000000 is turned ON to request opening a UDP socket from the Ethernet
Unit.
•
CIO 000001 is turned ON to request closing the UDP socket from the Ethernet
Unit.
•
CIO 000002 is turned ON to request sending data from the Ethernet Unit. Data
(100 bytes) is sent beginning at D02008.
•
CIO 000003 is turned ON to request receiving data from the Ethernet Unit. The
data that is received (100 bytes) is stored beginning at D04025.
•
One of the bits between CIO 000100 and CIO 000103 will turn ON if an error
occurs. Refer to 6-2-2 Response Codes for information on errors. The follow-
ing areas can be used to access details about errors:
CMND(490) response codes
Response codes in results storage area
Network Communications Error Flags (A21900 to A21907)
Completion codes (A203 to A210)
Program Memory Maps
The send and receive data and bits (flags) used by the program are shown in the
following diagrams.
DM Area
000AH 0004H 0001H 0110H 0000H 0032H
0
1
2
3
4
5
6
7
8
9
D00000
Number bytes to receive: 4 bytes
Remote Ethernet Unit designation
Network address: 01
hex
Node number: 01
hex
Unit address: 10
hex
FINS communications port: Port #0
Response monitor time: 5 s
CMND(490) control data for UDP OPEN REQUEST
Number of bytes to send: 10 bytes (000A
hex
)