This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Modbus, reading registers with strings
#3
Hello Erwin,

many thanks!

I tried your code, but unfortunately I got no result anywhere. "log(result)" serves nothing! It looks like the code stops at the (in homelynk unknown ?) function called "lmcore.inttostr()" ???
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)
log(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16)

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()

I read out the registers 71 to 87 which should contain the router name: "RUT955" and  logged the variables (r1 to r16) directly and this is the current log

Code:
RouterModbus 21.02.2018 20:07:10
* arg: 1
 * number: 21077
* arg: 2
 * number: 21561
* arg: 3
 * number: 13621
* arg: 4
 * number: 18487
* arg: 5
 * number: 22064
* arg: 6
 * number: 12848
* arg: 7
 * number: 0
* arg: 8
 * number: 0
* arg: 9
 * number: 0
* arg: 10
 * number: 0
* arg: 11
 * number: 0
* arg: 12
 * number: 0
* arg: 13
 * number: 0
* arg: 14
 * number: 0
* arg: 15
 * number: 0
* arg: 16
 * number: 0


I attached the routers short modbus manual.

B.R,

Uwe

Attached Files
.pdf   modbus_TCP_manual_v2(1).pdf (Size: 308.83 KB / Downloads: 32)
Reply


Messages In This Thread
RE: Modbus, reading registers with strings - by schippi - 21.02.2018, 19:34

Forum Jump: