-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo_pylontech.py
54 lines (40 loc) · 1.15 KB
/
demo_pylontech.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import time
import serial
from pylontech import *
# port = '/dev/ttyACM0'
port = "/dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0" # Raspberry Home (rechts oben)
pack_number = 2
com = serial.Serial(port, baudrate=115200, timeout=0.5) # non blocking
# === serial_number ===
for i in range(pack_number):
try:
d = read_serial_number(com, i)
print(d)
except Exception as e:
print("Exception", e)
time.sleep(1)
# === manufacturer_info === ACHTUNG !!! im Verbund nicht zuverlässig !!!
for i in range(pack_number):
try:
d = read_manufacturer_info(com, i)
print(d)
except Exception as e:
print("Exception", e)
time.sleep(1)
while True:
# === analog_value ===
for i in range(pack_number):
try:
d = read_analog_value(com, i)
print(i, d)
except Exception as e:
print("Exception", e)
time.sleep(2)
# === alarm_info ===
for i in range(pack_number):
try:
d = read_alarm_info(com, i)
print(i, d)
except Exception as e:
print("Exception", e)
time.sleep(2)