In [1]:
import serial

In [2]:
ser = serial.Serial('/dev/ttyS0', 9600, parity=serial.PARITY_EVEN)

In [3]:
ser


Out[3]:
Serial<id=0x7f36f4283650, open=True>(port='/dev/ttyS0', baudrate=9600, bytesize=8, parity='E', stopbits=1, timeout=None, xonxoff=False, rtscts=False, dsrdtr=False)

In [4]:
ser.isOpen()


Out[4]:
True

In [5]:
#status?
ser.write('0248ffff03'.decode('hex')) #status?
s = ser.read(5)
h = s.encode('hex')
int(h[4:8], 16)


Out[5]:
0

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]:
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]:
10

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]:
100

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]:
0

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]:
0

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]:
152

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]:
0

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]:
100

In [ ]:
ser.close()

In [ ]: