|
|
 |
MODBUS/TCP Protocol
Function Documentation
| synchronized void openProtocol |
( |
String |
hostName |
) |
throws IOException [inherited] |
|
|
|
Connects to a MODBUS/TCP slave.
This function establishes a logical network connection between master and slave. After a connection has been established data and control functions can be used. A TCP/IP connection should be closed if it is no longer needed.
- Note:
- The default time-out for the connection is 1000 ms.
The default TCP port number is 502.
- Parameters:
-
| hostName | String with IP address or host name |
- Exceptions:
-
| IOException | An I/O error occured |
| ConnectException | Connection refused by remote, no service listening |
| BindException | Remote port in use |
| NoRouteToHostException | No route to host |
| UnknownHostException | Unknown host, e.g. wrong IP address or name |
| SecurityException | Security violation |
- Note:
- The time-out parameter does not apply for connection to a host. Instead the system's default time-out value will be used by the JVM.
|
| synchronized void closeProtocol |
( |
|
) |
throws IOException [virtual, inherited] |
|
|
|
Closes a TCP/IP connection to a MODBUS/TCP slave and releases any system resources associated with the connection.
- Exceptions:
-
| IOException | An I/O error occured |
Implements MbusMasterFunctions. |
| synchronized void setPort |
( |
int |
portNo |
) |
[inherited] |
|
|
|
Sets the TCP port number to be used by the protocol.
- Remarks:
- Usually the port number remains unchanged and defaults to 502. In this case no call to this function is necessary. However if the port number has to be different from 502 this function must be called before opening the connection with openConnection().
- Parameters:
-
| portNo | Port number to be used when opening the connection (Range: 0 - 0xFFFF) |
- Exceptions:
-
| IllegalStateException | Conection is open |
| IllegalArgumentException | Parameter is out of range |
|
| int getPort |
( |
|
) |
[inherited] |
|
|
|
Returns the TCP port number used by the protocol.
- Returns:
- Port number used by the protocol
|
| boolean isOpen |
( |
|
) |
[virtual, inherited] |
|
|
|
Returns whether currently connected or not.
- Return values:
-
| true | = connected |
| false | = not connected |
Implements MbusMasterFunctions. |
|
 |