Hi @marcusjelsch!
I have tried to reproduce the issue with diagslave
and pollmb
, following the idea in wiki. I used openhab 1.8.2 (should not matter I think) with modbus binding 1.9.0 from cloudbees.
Unfortunately I could not reproduce any issue.
Can you please go through my findings and see if you anything that does not match your expectations? Can you repeat the test?
0. Openhab configuration
openhab.cfg
modbus:tcp.slave1.connection=127.0.0.1:55502
modbus:tcp.slave1.type=holding
modbus:tcp.slave1.length=2
modbus:tcp.slave1.valuetype=bit
default.items
Number ModbusItem0 "bit 0 [%d]" {modbus="slave1:0"}
Number ModbusItem1 "bit 1 [%d]" {modbus="slave1:1"}
Number ModbusItem2 "bit 2 [%d]" {modbus="slave1:2"}
Number ModbusItem3 "bit 3 [%d]" {modbus="slave1:3"}
Number ModbusItem4 "bit 4 [%d]" {modbus="slave1:4"}
Number ModbusItem5 "bit 5 [%d]" {modbus="slave1:5"}
Number ModbusItem6 "bit 6 [%d]" {modbus="slave1:6"}
Number ModbusItem7 "bit 7 [%d]" {modbus="slave1:7"}
Number ModbusItem8 "bit 8 [%d]" {modbus="slave1:8"}
Number ModbusItem9 "bit 9 [%d]" {modbus="slave1:9"}
Number ModbusItem10 "bit 10 [%d]" {modbus="slave1:10"}
Number ModbusItem11 "bit 11 [%d]" {modbus="slave1:11"}
Number ModbusItem12 "bit 12 [%d]" {modbus="slave1:12"}
Number ModbusItem13 "bit 13 [%d]" {modbus="slave1:13"}
Number ModbusItem14 "bit 14 [%d]" {modbus="slave1:14"}
Number ModbusItem15 "bit 15 [%d]" {modbus="slave1:15"}
Number ModbusItem16 "bit 16 [%d]" {modbus="slave1:16"}
Number ModbusItem17 "bit 17 [%d]" {modbus="slave1:17"}
Number ModbusItem18 "bit 18 [%d]" {modbus="slave1:18"}
Number ModbusItem19 "bit 19 [%d]" {modbus="slave1:19"}
Number ModbusItem20 "bit 20 [%d]" {modbus="slave1:20"}
Number ModbusItem21 "bit 21 [%d]" {modbus="slave1:21"}
Number ModbusItem22 "bit 22 [%d]" {modbus="slave1:22"}
Number ModbusItem23 "bit 23 [%d]" {modbus="slave1:23"}
Number ModbusItem24 "bit 24 [%d]" {modbus="slave1:24"}
Number ModbusItem25 "bit 25 [%d]" {modbus="slave1:25"}
Number ModbusItem26 "bit 26 [%d]" {modbus="slave1:26"}
Number ModbusItem27 "bit 27 [%d]" {modbus="slave1:27"}
Number ModbusItem28 "bit 28 [%d]" {modbus="slave1:28"}
Number ModbusItem29 "bit 29 [%d]" {modbus="slave1:29"}
Number ModbusItem30 "bit 30 [%d]" {modbus="slave1:30"}
Number ModbusItem31 "bit 31 [%d]" {modbus="slave1:31"}
default.sitemap
sitemap demo label="Main Menu" {
Text item=ModbusItem0
Text item=ModbusItem1
Text item=ModbusItem2
Text item=ModbusItem3
Text item=ModbusItem4
Text item=ModbusItem5
Text item=ModbusItem6
Text item=ModbusItem7
Text item=ModbusItem8
Text item=ModbusItem9
Text item=ModbusItem10
Text item=ModbusItem11
Text item=ModbusItem12
Text item=ModbusItem13
Text item=ModbusItem14
Text item=ModbusItem15
Text item=ModbusItem16
Text item=ModbusItem17
Text item=ModbusItem18
Text item=ModbusItem19
Text item=ModbusItem20
Text item=ModbusItem21
Text item=ModbusItem22
Text item=ModbusItem23
Text item=ModbusItem24
Text item=ModbusItem25
Text item=ModbusItem26
Text item=ModbusItem27
Text item=ModbusItem28
Text item=ModbusItem29
Text item=ModbusItem30
Text item=ModbusItem31
}
1. Start slave
$ ./diagslave -m tcp -p 55502
2. Write data using pollmb
(assumes pollmb script is available at subfolder pollmb
)
First register:
$ pollmb/pollmb.py -h 127.0.0.1 -p 55502 -f 16 -a 0 -d 42C8
Contacting Modbus host at 127.0.0.1 port 55502 timeout 60.0 sec.
Sending Modbus function: 16, addr: 0, qty: 1, data: 42C8 for 1 polls at 1 msec
1: Reply was: function: 16, data: 0001
Second register:
$ pollmb/pollmb.py -h 127.0.0.1 -p 55502 -f 16 -a 1 -d aaaa
Contacting Modbus host at 127.0.0.1 port 55502 timeout 60.0 sec.
Sending Modbus function: 16, addr: 1, qty: 1, data: 1234 for 1 polls at 1 msec
1: Reply was: function: 16, data: 0001
For details, consult help using pollmb/pollmb.py
.
Verify data
$ pollmb/pollmb.py -p 55502 -f 3 -a 0 -q 2
Contacting Modbus host at localhost port 55502 timeout 60.0 sec.
Sending Modbus function: 3, addr: 0, qty: 2, data: 0000 for 1 polls at 1 msec
1: Reply was: function: 3, data: 42c81234
Result in sitemap
http://localhost:8080/openhab.app
(newline added afterwards)
bit 0 0
bit 1 0
bit 2 0
bit 3 1
bit 4 0
bit 5 0
bit 6 1
bit 7 1
bit 8 0
bit 9 1
bit 10 0
bit 11 0
bit 12 0
bit 13 0
bit 14 1
bit 15 0
bit 16 0
bit 17 0
bit 18 1
bit 19 0
bit 20 1
bit 21 1
bit 22 0
bit 23 0
bit 24 0
bit 25 1
bit 26 0
bit 27 0
bit 28 1
bit 29 0
bit 30 0
bit 31 0
Note that (ref: hex-to-binary converter)
(42C8)16 = (0100 0010 1100 1000)2
(1234)16 = (0001 0010 0011 0100)2
If you read openhab bits “backards”
bits 15...0 : 0100 0010 1100 1000 (OK! matches (42C8)16 )
bits 31...16 : 0001 0010 0011 0100 (OK! matches (1234)16 )
Best,
Sami