We will need the crc16 python code library :
http://code.google.com/p/pycrc16/downloads
1 |
tar -xzf crc16-0.1.1.tar.gz |
1 2 3 |
cd crc16-0.1.1 python setup.py build sudo python setup.py install |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import serial import struct ser = serial.Serial( port='/dev/<span style="color: #800000;">ttyUSB0</span>', baudrate=9600 ) print(ser.isOpen()) thestring = "\xAA\x05\x01\x50\xD5" ser.write(thestring) s = ser.read(20) print(s) ser.close() |