ErrorResponseException,ModbusInitException{BatchRead<Integer>batch=newBatchRead<Integer>();batch.addLocator(0,BaseLocator.holdingRegister(1,1,DataType.FOUR_BYTE_FLOAT));batch.addLocator(1,BaseLocator.inputStatus(1,0));ModbusMaster master=getMaster...
.holdingRegister(slaveID,30, DataType.FOUR_BYTE_FLOAT_SWAPPED)); batchRead.addLocator(Config.Voltage_Vc_2, BaseLocator .holdingRegister(slaveID,32, DataType.FOUR_BYTE_FLOAT_SWAPPED)); batchRead.addLocator(Config.Voltage_Avg_2, BaseLocator .holdingRegister(slaveID,34, DataType.FOUR_BYTE_FLOAT_...
case Constants.ValueType.LONG: return DataType.FOUR_BYTE_INT_SIGNED; case Constants.ValueType.FLOAT: return DataType.FOUR_BYTE_FLOAT; case Constants.ValueType.DOUBLE: return DataType.EIGHT_BYTE_FLOAT; default: return DataType.TWO_BYTE_INT_SIGNED; } } } 搞定 这么简单 注意:这里是使用的tcp协议...
Number v031 = readHoldingRegister(1, 1, DataType.FOUR_BYTE_FLOAT);// 注意,float Number v032 = readHoldingRegister(1, 3, DataType.FOUR_BYTE_FLOAT);// 同上 System.out.println("v031:" + v031); System.out.println("v032:" + v032); // 04测试 Number v041 = readInputRegisters(1, ...
Modbus协议是一项应用层报文传输协议,包括ASCII、RTU、TCP三种报文类型。 标准的Modbus协议物理层接口有RS232、RS422、RS485和以太网接口,采用master/slave方式通信。 Modbus和RS485的关系:Modbus是协议,物理层接口有RS232、RS422、RS485和以太网接口几种
*/publicstaticvoidbatchRead()throws ModbusTransportException,ErrorResponseException,ModbusInitException{BatchRead<Integer>batch=newBatchRead<Integer>();batch.addLocator(0,BaseLocator.holdingRegister(1,1,DataType.FOUR_BYTE_FLOAT));batch.addLocator(1,BaseLocator.inputStatus(1,0));ModbusMaster master=get...
();BatchRead<Integer>batch=newBatchRead<>();batch.addLocator(0,BaseLocator.inputRegister(1,0,BaseLocator.DataType.FOUR_BYTE_FLOAT));BatchResults<Integer>results=tcpMaster.send(batch);floatvalue=results.getIntValue(0);System.out.println("Value read: "+value);tcpMaster.disconnect();}catch(...
功能码03,选择Float类型 signed:有符号unsigned:无符号hex:十六进制binary:二进制 big-endian:大端,将高序字节存储在起始地址(高位编址)little-endian:小端,将低序字节存储在起始地址(低位编址) swap:交换 双击第一个地址输入数据,会提示输入数据的类型,32位数据占2个地址,所以下一个地址是-- ...
Example 1: When 12345 is written, the corresponding hexadecimal value is 0x3039. If this parameter is set to false, the byte order for sending and receiving the value is 30 39. If this parameter is set to true, the order is 39 30. ...
File records: support File Records function code 0x14 and 0x15 of different types of numeric records (int16, uint16, int32, uint32, float and double). Endianness: Define how bytes are arranged in the modbus register. ABCD(swapWord: false, swapByte: false) CDAB(swapWord: true, swapByt...