Read Multiple Holding Registers
Opened this issue · 3 comments
gtuceturan commented
Hello ,
Can I Read Multiple Holding Registers function this library ?
cabbi commented
I did a new package that handles register groups. Feel free to take a look at https://pub.dev/packages/modbus_client
brkpacaci commented
I am using readholdingregister function but i can read only 125 register. how can i read more data register
cabbi commented
This is the example of reading multiple registers by using a group:
import 'package:modbus_client/modbus_client.dart';
import 'package:modbus_client_tcp/modbus_client_tcp.dart';
enum BatteryStatus implements ModbusIntEnum {
offline(0),
standby(1),
running(2),
fault(3),
sleepMode(4);
const BatteryStatus(this.intValue);
@override
final int intValue;
}
void main() async {
// Create a modbus elements group
var batteryRegs = ModbusElementsGroup([
ModbusEnumRegister(
name: "BatteryStatus",
type: ModbusElementType.holdingRegister,
address: 37000,
enumValues: BatteryStatus.values),
ModbusInt32Register(
name: "BatteryChargingPower",
type: ModbusElementType.holdingRegister,
address: 37001,
uom: "W",
description: "> 0: charging - < 0: discharging"),
ModbusUint16Register(
name: "BatteryCharge",
type: ModbusElementType.holdingRegister,
address: 37004,
uom: "%",
multiplier: 0.1),
ModbusUint16Register(
name: "BatteryTemperature",
type: ModbusElementType.holdingRegister,
address: 37022,
uom: "°C",
multiplier: 0.1),
]);
// Create the modbus client.
var modbusClient = ModbusClientTcp("127.0.0.1", unitId: 1);
// Send a read request from the group
await modbusClient.send(batteryRegs.getReadRequest());
print(batteryRegs[0]);
print(batteryRegs[1]);
print(batteryRegs[2]);
print(batteryRegs[3]);
// Ending here
modbusClient.disconnect();
}