In [1]:
import serial
In [2]:
ser = serial.Serial('/dev/ttyS0', 9600, parity=serial.PARITY_EVEN)
In [3]:
ser
Out[3]:
In [4]:
ser.isOpen()
Out[4]:
In [5]:
#status?
ser.write('0248ffff03'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)
Out[5]:
In [6]:
#betriebsart entladen
ser.write('0249000603'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)
Out[6]:
In [7]:
#sollwert0 (I)
ser.write('0228000003'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)
Out[7]:
In [8]:
#sollwert1 (U)
ser.write('0229000003'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)
Out[8]:
In [9]:
#Messwert0 (mAh)
ser.write('0232000003'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)
Out[9]:
In [10]:
#Messwert1 (Ah)
ser.write('0233000003'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)
Out[10]:
In [11]:
#Messwert2 (U_mittel)
ser.write('0234000003'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)
Out[11]:
In [12]:
#Messwert2 (I_mittel)
ser.write('0235000003'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)
Out[12]:
In [13]:
#last zuschalten
ser.write('0247000003'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)
Out[13]:
In [ ]:
ser.close()
In [ ]: