Ethernet Developers Guide

The receive state machine maintains a variable which is the number of bytes received. Initially the receive state machine is in the RX_HEADER state, and the number of bytes received is zero.

When OnTcpIpRead is called and the receive state is RX_HEADER OnTcpIpRead calls rx_msg with receive size equal to the header size. On return OnTcpIpRead examines the number of bytes received. If the number of bytes received is not equal to the header size, then receive machine remains in the RX_HEADER state, and OnTcpIpRead returns.

If upon return, the number bytes received is the same size as the header size, then the header has been received. OnTcpIpRead sets the number of bytes received to zero, and the receive size is obtained from the header. These two values will be used the next time rx_msg is called. OnTcpIpRead also obtains the transaction identifier and the protocol type from the header. If the transaction identifier matches the transmit request identifier and the protocol type is MODBUS, then OnTcpIpRead changes the receive state to RX_BODY. However if either transaction identifier does not match or the protocol is not MODBUS, then OnTcpIpRead changes the receive state to DUMP_BODY.

When OnTcpIpRead is called and the receive state is RX_BODY, OnTcpIpRead calls rx_msg with receive size equal to the value obtained from the header. On return OnTcpIpRead examines the number of bytes received. If the number of bytes received is not equal to the receive size, then the receive machine remains in the RX_HEADER state, and OnTcpIpRead returns.

If upon return the number of bytes received is the same as the receive size, then OnTcpIpRead has read the response to a transaction. OnTcpIpRead saves the results and invalidates the client area which causes the results to be display. OnTcpIpRead also changes the transmit state to WAIT_TO_TX, and resets the state receive state machine by setting the state to RX_HEADER and the number of bytes received to zero. It then returns.

When OnTcpIpRead is called and the receive state is DUMP_BODY, OnTcpIpRead calls rx_msg with receive size equal to the value obtained from the header. On return OnTcpIpRead examines the number of bytes received. If the number of bytes received is not equal to the receive size, then the receive machine remains in the RX_HEADER state, and OnTcpIpRead returns.

If upon return the number of bytes received is the same as the receive size, the OnTcpIpRead has completed reading the message. Since this message does not correspond to an transaction, the only processing OnTcIpRead performs is resetting the receive state machine.

840 USE 115 00 Version 1.0

75

Page 85
Image 85
Schneider Optics Modicon Quantum Ethernet manual Ethernet Developers Guide