[modbus] BaseModbusThingHandler: Add ability to retrieve slave address (#9181)

* [modbus] BaseModbusThingHandler: Add ability to retrieve slave address
* Rework error handling

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
This commit is contained in:
Fabian Wolter
2020-12-05 06:24:55 +01:00
committed by GitHub
parent 86bd264cb9
commit 568da33684
2 changed files with 54 additions and 58 deletions

View File

@@ -107,7 +107,7 @@ public class MyHandler extends BaseModbusThingHandler {
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (command instanceof RefreshType) {
ModbusReadRequestBlueprint blueprint = new ModbusReadRequestBlueprint(42,
ModbusReadRequestBlueprint blueprint = new ModbusReadRequestBlueprint(getSlaveId(),
ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS, 0, 1, 2);
submitOneTimePoll(blueprint, this::readSuccessful, this::readError);
@@ -115,12 +115,10 @@ public class MyHandler extends BaseModbusThingHandler {
}
@Override
public void initialize() {
super.initialize();
public void modbusInitialize() {
// do other Thing initialization
ModbusReadRequestBlueprint blueprint = new ModbusReadRequestBlueprint(42,
ModbusReadRequestBlueprint blueprint = new ModbusReadRequestBlueprint(getSlaveId(),
ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS, 0, 1, 2);
registerRegularPoll(blueprint, 1000, 0, this::readSuccessful, this::readError);