#!/usr/bin/python3 import serial st="PMTK314,0,1,1,0,0,0,0,0,0,0,0,0,0,0" EOL = "\r\n" serial = serial.Serial("/dev/ttyAMA0", 38400) i = 0 checksum = 0 while i < len(st): checksum ^= ord(st[i]) i+= 1 data = bytes("$" + st + "*" + "%02X"%checksum + EOL, 'ascii') serial.write(data) print(data)