Advertisement
silver2row

GPS lib. Class...

Oct 5th, 2020
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.72 KB | None | 0 0
  1. class GPS:
  2.  
  3.     def __init__(self):
  4.         #This sets up variables for useful commands.
  5.         #This set is used to set the rate the GPS reports
  6.         UPDATE_10_sec = b"$PMTK220,10000*2F\n" #Update Every 10 Seconds
  7.         UPDATE_5_sec = b"$PMTK220,5000*1B\n"   #Update Every 5 Seconds
  8.         UPDATE_1_sec = b"$PMTK220,1000*1F\n"   #Update Every One Second
  9.         UPDATE_200_msec = b"$PMTK220,200*2C\n" #Update Every 200 Milliseconds
  10.         #This set is used to set the rate the GPS takes measurements
  11.         MEAS_10_sec = b"$PMTK300,10000,0,0,0,0*2C\n" #Measure every 10 seconds
  12.         MEAS_5_sec = b"$PMTK300,5000,0,0,0,0*18\n"   #Measure every 5 seconds
  13.         MEAS_1_sec = b"$PMTK300,1000,0,0,0,0*1C\n"   #Measure once a second
  14.         MEAS_200_msec = b"$PMTK300,200,0,0,0,0*2F\n"  #Meaure 5 times a seconds
  15.         #Set the Baud Rate of GPS
  16.         BAUD_57600 = b"$PMTK251,57600*2C\n"       #Set Baud Rate at 57600
  17.         BAUD_9600 = b"$PMTK251,9600*17\n"         #Set 9600 Baud Rate
  18.         #Commands for which NMEA Sentences are sent
  19.         ser.write(BAUD_57600.encode()
  20.         sleep(1)
  21.         ser.baudrate=57600
  22.         GPRMC_ONLY = b"$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\n" #Send only the GPRMC Sentence
  23.         GPRMC_GPGGA = b"$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\n"#Send GPRMC AND GPGGA Sentences
  24.         SEND_ALL = b"$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28\n" #Send All Sentences
  25.         SEND_NOTHING = b"$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\n" #Send Nothing
  26.         ser.write(UPDATE_1_sec()
  27.         sleep(1)
  28.         ser.write(MEAS_1_sec()
  29.         sleep(1)
  30.         ser.write(GPRMC_GPGGA()
  31.         sleep(1)
  32.         ser.flushInput()
  33.         ser.flushInput()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement