20.02.2018, 22:23
(This post was last modified: 20.02.2018, 22:23 by Erwin van der Zwart.)
Hi Uwe,
Can you try this? I'm not sure how the chars are written in the register so it could not work like this (maybe it's HEX based)
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485', 19200, 'E', 8, 1, 'H')
mb:connect()
mbetslave(1)
r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16 = mb:readregisters(7,16)
result = lmcore.inttostr(r1) .. lmcore.inttostr(r2) .. lmcore.inttostr(r3) .. lmcore.inttostr(r4) .. lmcore.inttostr(r5) .. lmcore.inttostr(r6) .. lmcore.inttostr(r7) .. lmcore.inttostr(r8) .. lmcore.inttostr(r9) .. lmcore.inttostr(r10) .. lmcore.inttostr(r11) .. lmcore.inttostr(r12) .. lmcore.inttostr(r13) .. lmcore.inttostr(r14) .. lmcore.inttostr(r15) .. lmcore.inttostr(r16)
log(result)
mb:close()
BR,
Erwin
Can you try this? I'm not sure how the chars are written in the register so it could not work like this (maybe it's HEX based)
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485', 19200, 'E', 8, 1, 'H')
mb:connect()
mbetslave(1)
r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16 = mb:readregisters(7,16)
result = lmcore.inttostr(r1) .. lmcore.inttostr(r2) .. lmcore.inttostr(r3) .. lmcore.inttostr(r4) .. lmcore.inttostr(r5) .. lmcore.inttostr(r6) .. lmcore.inttostr(r7) .. lmcore.inttostr(r8) .. lmcore.inttostr(r9) .. lmcore.inttostr(r10) .. lmcore.inttostr(r11) .. lmcore.inttostr(r12) .. lmcore.inttostr(r13) .. lmcore.inttostr(r14) .. lmcore.inttostr(r15) .. lmcore.inttostr(r16)
log(result)
mb:close()
BR,
Erwin