Please note the following caveats or limitations
-* the binding does *not* act as Modbus slave (e.g. as Modbus TCP server).
-* the binding does *not* support Modbus RTU over Modbus TCP, also known as "Modbus over TCP/IP" or "Modbus over TCP" or "Modbus RTU/IP", although normal "Modbus TCP" is supported. However, there is a workaround: you can use a Virtual Serial Port Server, to emulate a COM Port and Bind it with openHAB using Modbus Serial.
+* The binding does *not* act as Modbus slave (e.g. as Modbus TCP server).
+* The binding *does* support Modbus RTU over Modbus TCP, (also known as "Modbus over TCP/IP" or "Modbus over TCP" or "Modbus RTU/IP"), as well as normal "Modbus TCP".
## Background Material
Basic parameters
-| Parameter | Type | Required | Default if omitted | Description |
-| --------- | ------- | -------- | ------------------ | ----------------------------------------------------------- |
-| `host` | text | | `"localhost"` | IP Address or hostname |
-| `port` | integer | | `502` | Port number |
-| `id` | integer | | `1` | Slave id. Also known as station address or unit identifier. |
+| Parameter | Type | Required | Default if omitted | Description |
+| ------------ | ------- | -------- | ------------------ | ----------------------------------------------------------- |
+| `host` | text | | `"localhost"` | IP Address or hostname |
+| `port` | integer | | `502` | Port number |
+| `id` | integer | | `1` | Slave id. Also known as station address or unit identifier. |
+| `rtuEncoded` | boolean | | `false` | Use RTU encoding instead of regular TCP encoding. |
Advanced parameters
import static org.mockito.Mockito.*;
import static org.openhab.binding.modbus.internal.ModbusBindingConstantsInternal.*;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.concurrent.ScheduledFuture;
import java.util.function.Consumer;
import java.util.function.Function;
}
private Bridge createTcpMock() {
- ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502);
+ ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
Bridge tcpBridge = ModbusPollerThingHandlerTest.createTcpThingBuilder("tcp1").build();
ModbusTcpThingHandler tcpThingHandler = Mockito.mock(ModbusTcpThingHandler.class);
tcpBridge.setStatusInfo(new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, ""));
private void testOutOfBoundsGeneric(int pollStart, int pollLength, String start,
ModbusReadFunctionCode functionCode, ValueType valueType, ThingStatus expectedStatus,
BundleContext context) {
- ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502);
+ ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
// Minimally mocked request
ModbusReadRequestBlueprint request = Mockito.mock(ModbusReadRequestBlueprint.class);
private ModbusDataThingHandler testReadHandlingGeneric(ModbusReadFunctionCode functionCode, String start,
String transform, ValueType valueType, BitArray bits, ModbusRegisterArray registers, Exception error,
BundleContext context, boolean autoCreateItemsAndLinkToChannels) {
- ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502);
+ ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
int pollLength = 3;
private ModbusDataThingHandler testWriteHandlingGeneric(String start, String transform, ValueType valueType,
String writeType, ModbusWriteFunctionCode successFC, String channel, Command command, Exception error,
BundleContext context) {
- ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502);
+ ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
// Minimally mocked request
ModbusReadRequestBlueprint request = Mockito.mock(ModbusReadRequestBlueprint.class);
private void testValueTypeGeneric(ModbusReadFunctionCode functionCode, ValueType valueType,
ThingStatus expectedStatus) {
- ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502);
+ ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
// Minimally mocked request
ModbusReadRequestBlueprint request = Mockito.mock(ModbusReadRequestBlueprint.class);
public void testRefreshOnData() throws InterruptedException {
ModbusReadFunctionCode functionCode = ModbusReadFunctionCode.READ_COILS;
- ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502);
+ ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
int pollLength = 3;
ThingHandler foo = parent.getHandler();
addThing(parent);
} else {
- ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502);
+ ModbusSlaveEndpoint endpoint = new ModbusTCPSlaveEndpoint("thisishost", 502, false);
// Minimally mocked request
ModbusReadRequestBlueprint request = Mockito.mock(ModbusReadRequestBlueprint.class);