02.04.2020, 08:43
Hi
2. Looks OK, I would contact SE and ask them for function they use to read this value.
3. You already have product identification in register 100 only in numeric format. Product identifier 17032 = IFL12H
If you really need script for this then try this.
2. Looks OK, I would contact SE and ask them for function they use to read this value.
3. You already have product identification in register 100 only in numeric format. Product identifier 17032 = IFL12H
If you really need script for this then try this.
Code:
mbproxy = require('mbproxy')
mb = mbproxy.new()
mb:setslave(1)
function readstring(mb, address, length)
local data = { mb:readregisters(address, length) }
local bytes = {}
for _, reg in ipairs(data) do
if type(reg) == 'number' then
-- high 8 bits
local b1 = bit.band(bit.rshift(reg, 8), 0xFF)
if b1 > 0 then
bytes[ #bytes + 1 ] = b1
end
-- low 8 bits
local b2 = bit.band(reg, 0xFF)
if b2 > 0 then
bytes[ #bytes + 1 ] = b2
end
end
end
-- convert table of byte values to string
return string.char(unpack(bytes))
end
result = readstring(mb, 160, 9)
log(result)
------------------------------
Ctrl+F5
Ctrl+F5