21.02.2018, 21:56
(This post was last modified: 21.02.2018, 22:00 by Erwin van der Zwart.)
Hi Uwe,
Thanks for the values, now i could figure out that each register holds 2 chars.
Try this (:
PS: Result is RUT955H7V020
BR,
Erwin
Thanks for the values, now i could figure out that each register holds 2 chars.
Try this (:
PS: Result is RUT955H7V020
Code:
require('luamodbus')
mb = luamodbus.tcp()
mb:open('192.168.2.1', 502)
mb:connect()
r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16 = mb:readregisters(71,16)
function twobytetochars(value)
charsvalue = lmcore.hextostr(lmcore.inttohex(value,2))
return charsvalue
end
if r1 then r1 = twobytetochars(r1) else r1 = "" end
if r2 then r2 = twobytetochars(r2) else r2 = "" end
if r3 then r3 = twobytetochars(r3) else r3 = "" end
if r4 then r4 = twobytetochars(r4) else r4 = "" end
if r5 then r5 = twobytetochars(r5) else r5 = "" end
if r6 then r6 = twobytetochars(r6) else r6 = "" end
if r7 then r7 = twobytetochars(r7) else r7 = "" end
if r8 then r8 = twobytetochars(r8) else r8 = "" end
if r9 then r9 = twobytetochars(r9) else r9 = "" end
if r10 then r10 = twobytetochars(r10) else r10 = "" end
if r11 then r11 = twobytetochars(r11) else r11 = "" end
if r12 then r12 = twobytetochars(r12) else r12 = "" end
if r13 then r13 = twobytetochars(r13) else r13 = "" end
if r14 then r14 = twobytetochars(r14) else r14 = "" end
if r15 then r15 = twobytetochars(r15) else r15 = "" end
if r16 then r16 = twobytetochars(r16) else r16 = "" end
result = r1 .. r2 .. r3 .. r4 .. r5 .. r6 .. r7 .. r8 .. r9 .. r10 .. r11 .. r12 .. r13 .. r14 .. r15 .. r16
log(result)
mb:close()
Erwin