Read Holding Registers
t, err = mbo:rhr(adr, regs, regc, [rfmt, [ms]])
t, err = modbus.rhr(cpo, adr, regs, regc, [rfmt, [ms]])
Read holding registers (Modbus function 03)
Parameter | Type | Description |
---|---|---|
mbo |
object table | Modbus Object |
cpo |
object | COM Port Object |
adr |
integer | Slave address |
regs |
integer | First register to read |
regc |
integer | Number of registers to read |
rfmt |
string | Receive format string ([Modbus Format Strings]) |
ms |
integer | Receive timeout |
The receive format string allows unpacking of arbitrary data formats.
Returns | Type | Description |
---|---|---|
t |
table | Boolean values (one for each input) |
err |
string | Modbus error (if applicable) |
e.g.
local t = modbus.rhr(dp,1,28,6,'W+') -- read DVP readings
Each "Holding Register" is 16-bits wide.