Skip to content

Commit 4e10730

Browse files
mbus scan
1 parent 9c6aef8 commit 4e10730

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

mbus/mbus_scan.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys, time
2+
import load_config as conf
3+
serial_port, baud_rate, address = conf.load()
4+
5+
sys.path.append('/opt/openenergymonitor/emonhub/src')
6+
from interfacers import *
7+
mbus = EmonHubMBUSInterfacer.EmonHubMBUSInterfacer("MBUS",serial_port,False,False,baud_rate)
8+
9+
for address in range(0, 254):
10+
11+
mbus.mbus_short_frame(address, 0x40)
12+
time.sleep(1.0)
13+
reply = False
14+
while mbus.ser.in_waiting:
15+
val = ord(mbus.ser.read(1))
16+
if val==229:
17+
print("ACK received from address "+str(address))
18+
reply = True
19+
20+
if not reply:
21+
print("no reply received from address "+str(address))
22+
sys.exit(0)
23+

0 commit comments

Comments
 (0)