active_nmea.py 303 B

1234567891011121314151617
  1. #!/usr/bin/python3
  2. import serial
  3. st="PMTK314,0,1,1,0,0,0,0,0,0,0,0,0,0,0"
  4. EOL = "\r\n"
  5. serial = serial.Serial("/dev/ttyAMA0", 38400)
  6. i = 0
  7. checksum = 0
  8. while i < len(st):
  9. checksum ^= ord(st[i])
  10. i+= 1
  11. data = bytes("$" + st + "*" + "%02X"%checksum + EOL, 'ascii')
  12. serial.write(data)
  13. print(data)