beautypg.com

B.7.2 application message format – Schneider Optics Web Embedded Server User Manual

Page 80

background image

Ethernet Developers Guide

70

840 USE 115 00 Version 1.0

One of the parameters to the WSAAsyncSelect is a user defined message the
window socket DLL sends to the window. The sample application user message is
WM_TCPIP_EVENT and is defined in the file wn_msh.h. MFC architectural
framework calls the CSample_View tcpip_event member function to process this
message. Like all functions which process messages, tcpip_event parameters are
a word and a long word. The word parameter is the socket, and the long word
parameter contains the network event , and an error code. Tcpip_event examines
the network event and calls the member function indicated in the following table.

B.7.2

Application Message Format

TCP/IP transmits a message as a stream. There is no indication of the start of a
message nor the end of the message. The NOE option module adds a header to
determine the message boundaries. The message is a Modbus message. The
header contains the following fields.

z

Invoke Identifier. This two byte field associates a request with the response.
The client application picks the invoke identifier, and server returns the same
invoke identifier in the response.

z

Protocol Type. This two byte field identifies the protocol type. Currently, the
only protocol supported is Modbus.

z

Command Length. This two byte field is the size of the rest of the message.

z

Destination Identifier. This one byte field is reserved for future use.

The Modbus message follows the header. The message does not contain the
address field, instead, the first byte is the Modbus function code.

The data structure for the header is declared in modbus.h and the CSample_View
encode_header function encodes the header. The member functions
encode_clear_stats, encode_read_stats, encode_read_rq, and encode_write_rq
encode the corresponding Modbus messages.

Network Event

Member Function

FD_READ

OnTcpIpRead()

FD_WRITE

OnTcpIpWrite()

FD_OOB

OnTcpIpOob()

FD_CONNECT

OnTcpIpConnect

FD_CLOSE

OnTcpIpClose()