-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
38 lines (29 loc) · 774 Bytes
/
test.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
__author__ = 'adam'
import pv
import serial
import sys
pv.debug()
pv.debug_color()
try:
port = serial.Serial('/dev/tty.usbserial', timeout = 10, write_timeout = 5)
#port.open()
from pv import cms
inv = cms.Inverter(port)
inv.reset()
sn = inv.discover()
ok = inv.register(sn) # Associates the inverter and assigns default address
if not ok:
print "Inverter registration failed."
sys.exit(1)
print inv.version()
param_layout = inv.param_layout()
parameters = inv.parameters(param_layout)
for field in parameters:
print "%-10s: %s" % field
status_layout = inv.status_layout()
status = inv.status(status_layout)
for field in status:
print "%-10s: %s" % field
except:
print("Serial connection did not answer");
port.close()