Instruction Manual

89
Methods
ClearMessageCounter (LONG InterfaceHandle)
Method to reset the control’s message counter to zero. The
InterfaceHandle parameter passed to ClearMessageCounter must match
the LONG value returned from a ConnectSerial() or ConnectTCP()
method. The control maintains an internal counter for each open
connection detailing the number of successful message transactions which
have occured on between the control and the modbus master. The
ClearMessageCounter() method simply resets the designated counter to
zero.
CloseInterface (LONG InterfaceHandle)
Method used to close a modbus connection. The InterfaceHandle
parameter passed to CloseInterface must match the LONG value returned
from a ConnectSerial() or ConnectTCP() method. This method should be
used to gracefully close the modbus connection when the controlling
application terminates. The return value indicates success, (TRUE), or
failure of the operation.
ConnectSerial (SHORT PortNumber)
The ConnectSerial method instructs the control to open the designated
serial COM port and begin servicing requests from a modbus master
device. The port is opened using the current configuration properties,
(BaudRate, DataBits, Parity, StopBits, and TransmissionMode). The
value returned from ConnectSerial contains the handle, (LONG), to the
connection, and must be maintained by the controlling application as a
possible parameter passed to either CloseInterface() or
ResetMessageCounter(). If an error occurs duiring opening of the serial
port, the ConnectSerial method returns an INVALID_HANDLE_VALUE,
(-1).
ConnectTCP()
The ConnectTCP() method instructs the control to open a modbus/TCP
service port. TCP port number 502 is opened according to the
modbus/TCP protocol standard as published by Modicon. This allows any
modbus/TCP compatible master client application to connect and access
the control’s data through the connected network. The network may be
physically connected to the PC or accessed via modem using the built-in
dial-up capabilities of Windows. ConnectTCP() will return a non-zero,
(positive), value if the port was successfully opened.