我想使用modbus tcp / ip模拟器来获取使用端口号502的坦克的实时数据。如何在java中编写代码以从模拟器获取保持寄存器值并且我还想控制值它的。
答案 0 :(得分:0)
如果您使用Modbus library like this one,大部分工作已经为您完成。
ModbusTcpMasterConfig config = new ModbusTcpMasterConfig.Builder("localhost").build();
ModbusTcpMaster master = new ModbusTcpMaster(config);
CompletableFuture<ReadHoldingRegistersResponse> future =
master.sendRequest(new ReadHoldingRegistersRequest(0, 10), 0);
future.thenAccept(response -> {
System.out.println("Response: " + ByteBufUtil.hexDump(response.getRegisters()));
ReferenceCountUtil.release(response);
});
答案 1 :(得分:0)
insert into email_table (select * from email);