-
Notifications
You must be signed in to change notification settings - Fork 18
Modbus Loop API
Cloud-Automation edited this page Oct 3, 2014
·
5 revisions
- Setup a Modbus Loop
- Read Holding Registers (FC 03)
- Read Input Registers (FC 04)
- Start the loop
- Stop the loop
- Events
- Optimization
loop = new ModbusLoop(client);
- client A ModbusClient Instance.
loop.readHoldingRegisters(start, count)
- start Start Address for the Holding Registers to be read.
- count Number of Registers to be read.
- Returns the loop object.
loop.readInputRegisters(start, count)
- start Start Address for the Input Registers to be read.
- count Number of Registers to be read.
- Returns the loop object.
loop.start()
loop.stop()
loop.on('update', function (inputRegisters, holdingRegisters) { ... });
When every request for the input and holding registers has finished the update
event will be fired. You can get your desired data from the inputRegisters
and holdingRegisters
Parameter.
loop.on('error', function (err) { ... });
Normally fired when there is an unexpected error on the Modbus Client. The loop will be stopped.
The Modbus Loop will automatically optimize your requests. So when you register
loop.readInputRegisters(0, 10)
and
loop.readInputRegisters(10, 10)
the request that is actually been send through the client is
client.readInputRegisters(0, 20)