Appendix C: Program Examples - Mitsubishi Electric FX3U-ENET-ADP User Manual

Table of Contents

Advertisement

FX
-ENET-ADP User's Manual
3U

Appendix C: Program Examples

The program examples presented in this section test the connection between the Ethernet adapter 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, handling for abnormalities may be added.
1) Receive processing of target device
A receive processing example on the target device side is shown below.
Receive remaining
response messages
Insufficient size
of data received
<Background>
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.
132
Communication processing
on the external device side
Request message/transmission processing
Response message/reception processing
Is the TCP connection open?
Was the reception data
received within the time allotted
by the monitoring timer?
Check the size of the received data
Response message processing
Have all the received
messages been processed?
End
The TCP connection is closed
Timeout of monitoring timer
If a response message to the
next request was received
Appendix C: Program Examples
Error handling

Advertisement

Table of Contents
loading

Table of Contents