We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
public static ModbusFactory modbusFactory = new ModbusFactory();
/** * 获取tcpMaster */ public static ModbusMaster getMaster() throws Exception { IpParameters params = new IpParameters(); params.setHost("192.168.100.66"); params.setPort(502); params.setEncapsulated(false); ModbusMaster tcpMaster = modbusFactory.createTcpMaster(params, false); tcpMaster.setTimeout(500); tcpMaster.setRetries(3); tcpMaster.init(); return tcpMaster; }
public static void readHoldingRegister(int slaveId, int offset, int dataType) throws Exception { BaseLocator locator = BaseLocator.holdingRegister(slaveId, offset, dataType); Number value = getMaster().getValue(locator); System.out.println("HoldingRegister寄存器第" + offset + "位数据为:" + value); }
The text was updated successfully, but these errors were encountered:
怎么解决的
Sorry, something went wrong.
No branches or pull requests
public static ModbusFactory modbusFactory = new ModbusFactory();
public static void readHoldingRegister(int slaveId, int offset, int dataType) throws Exception {
BaseLocator locator = BaseLocator.holdingRegister(slaveId, offset, dataType);
Number value = getMaster().getValue(locator);
System.out.println("HoldingRegister寄存器第" + offset + "位数据为:" + value);
}
The text was updated successfully, but these errors were encountered: