App - 5
MELSEC-F
APPENDIX
App - 5
Appendix 4 Program Examples
The program examples presented in this section test the connection between the
Ethernet module and an external device (personal computer) that is connected to the
same Ethernet.
For each program, only the minimum programming that is required to perform the
communication test is done. Modify the IP address, port number and other values
according to your system configuration. In addition, abnormal handling may be added.
(1) Receive processing of target device
A receive processing example on the target device side is shown below.
For Ethernet communications, the TCP socket functions are used inside the
personal computer. However, these functions do not have any limits. Therefore,
when the "send" function is executed once to transmit data, the receiving end (node)
needs to execute the "recv" function once or more in order to read the data ("send"
and "recv" is not proportional to 1:1 execution). For this reason, the receiving
procedure explained above, is required.
Background
Request message/transmission processing
Response message/reception processing
Is the TCP connection open?
The TCP connection is closed
Timeout of monitoring timer
Error handlingEnd
If a response message to the
next request was received
Receive remaining
response messages
Insufficient size
of data received
Check the size of the received data
Was the reception data
received within the time allotted
by the monitoring timer?
Response message processing
Have all the received
messages been processed?
Communication processing
on the external device side