You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the helpers to get/set 32/64 bit values from 16bit registers expect to get each register as a parameter.
regs = read_registers(0x2000, 20)
local number = mb.get_s64(regs[10],regs[11], regs[12], regs[13])
when pulling out multiple numbers, it might be nice to support indexing a register table instead? Could automatically attempt to do the right thing based on the type of the first argument?
regs = read_registers(0x2000, 20)
local number = mb.get_s64(regs, 10)
The text was updated successfully, but these errors were encountered:
How about adding a separate metatable to handle decoding the data from the registers? Similar to how it works in pyModbus?
Something along the line of;
localmb=require("libmodbus")
-- Perform a request to get some register valueslocaldecoder=mb.new_decoder(register_values)
print(decoder.get_float32_abcd()) -- 1234.456print(decoder.get_uint32()) -- 1000
The idea is to have the decoder keep track of the current offset in the register_values table.
To handle encoding, the reverse would apply.
localmb=require("libmodbus")
localencoder=mb.new_encoder()
encoder.add_float32_abcd(1234.456)
encoder.add_uint16(1000)
encoder.add_int32(2000)
print(encoder.registers()) -- or encoder.build()
Currently, the helpers to get/set 32/64 bit values from 16bit registers expect to get each register as a parameter.
when pulling out multiple numbers, it might be nice to support indexing a register table instead? Could automatically attempt to do the right thing based on the type of the first argument?
The text was updated successfully, but these errors were encountered: