Изменил(а) на 'mbrtu/src/main/java/MainSlave.java'

This commit is contained in:
Михаил Бабинцев 2023-06-21 17:40:41 +00:00
parent 1a79a0ff77
commit 3c95ea4641

View File

@ -31,7 +31,7 @@ public class MainSlave {
serialParameters.setStopBits(1);
slave = ModbusSlaveFactory.createModbusSlaveRTU(serialParameters);
slave.setReadTimeout(0); // if not set default timeout is 1000ms, I think this must be set to 0 (infinitive timeout)
slave.setReadTimeout(0);
Modbus.setLogLevel(Modbus.LogLevel.LEVEL_DEBUG);
MyOwnDataHolder dh = new MyOwnDataHolder();
@ -82,14 +82,9 @@ public class MainSlave {
ir.set(1,234);
slave.getDataHolder().setInputRegisters(ir);
slave.setServerAddress(1);
/*
* using master-branch it should be #slave.open();
*/
slave.listen();
/*
* since 1.2.8
*/
if (slave.isListening()) {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
@ -104,9 +99,6 @@ public class MainSlave {
slave.wait();
}
/*
* using master-branch it should be #slave.close();
*/
slave.shutdown();
}
} catch (RuntimeException e) {