Microstack Node 0.1.0 documentation

L80GPS GPS Module Reference

«  Examples   ::   Contents   ::   MMA8452Q Accelerometer Reference  »

L80GPS GPS Module Reference

class microstacknode.gps.l80gps.L80GPS(device='/dev/ttyAMA0')

Thread that reads a stream of L80 GPS protocol lines and stores the information. Methods may raise exceptions if data is invalid (usually becasue of a poor GPS reception - try moving the GPS module outside).

always_locate()

Turns on AlwaysLocate(TM). Turn off with set_periodic_normal.

check_pmtk_ack()

Waits for an validates a PMTK_ACK. Raises an exception if PMTK_ACK reports error.

get_nmea_pkt(pattern)

Returns the next valid NMEA string which contains the pattern provided. For example:

>>> gps.get_nmea_pkt('GPRMC')
'$GPRMC,013732.000,A,3150.7238,N,11711.7278,E,0.00,0.00,220413,,,A*68'
gpgga

Returns the latest GPGGA message.

gpgll

Returns the latest GPGLL message.

Rasies:DataInvalidError
gpgsa

Returns the latest GPGSA message.

gpgsv

Returns the latest GPGSV message.

gprmc

Returns the latest GPRMC message.

Rasies:DataInvalidError
gptxt

Returns the latest GPTXT message.

gpvtg

Returns the latest GPVTG message.

locus_erase()

Erases the internal log.

locus_query()

Returns the status of the locus logger.

locus_query_data(raw=False, num_attempts=5)

Returns a list of parsed LOCUS log data.

Parameters:
  • raw (boolean) – Return raw bytearray instead of list of dict’s.
  • num_attempts (int) – Number of attempts to get raw data (it sometimes fails)
Rasies:

LOCUSQueryDataError

locus_start()

Starts the logger.

locus_stop()

Stops the logger.

send_nmea_pkt(pkt)

Write pkt to the serial port.

set_periodic_normal()

Sets the periodic mode to normal.

sleep()

Puts the GPS into sleep mode. Wake with set_periodic_normal.

standby()

Puts the GPS into standby mode.

microstacknode.gps.l80gps.checksum_is_valid(data_bytes, checksum)

Returns True is the logical OR of each consecutive databyte is the same as the checksum.

microstacknode.gps.l80gps.degrees_and_minutes_to_degrees(degrees_and_minutes, direction)

Converts dddmm.mmmm to ddd.dddd... direction’s ‘s’ and ‘w’ are negative.

microstacknode.gps.l80gps.gpgga_as_dict(gpgga_str)

Returns the GPGGA as a dictionary and the checksum.

Returns latitude and longitude as degrees.

>>> gpgga_as_dict('$GPGGA,015540.000,A,3150.68378,N,11711.93139,E,1,17,0.6,0051.6,M,0.0,M,,*58')
({'message_id': 'GPGGA',
  'utc': 015540.000,
  'latitude': 3150.68378,
  'ns': 'N',
  'longitude': 11711.93139,
  'ew': 'E',
  'fix': 1,
  'number_of_sv': 17,
  'hdop': 0.6,
  'altitude': 0051.6,
  'geoid_seperation': 0.0,
  'dgps_age': '',
  'dgps_station_id': ''},
  77)
microstacknode.gps.l80gps.gpgll_as_dict(gpgll_str)

Returns the GPGLL as a dictionary and the checksum.

>>> gpgll_as_dict('$GPGLL,3110.2908,N,12123.2348,E,041139.000,A,A*59')
({'message_id': GPGLL,
  'latitude': 3110.2908,
  'ns': 'N',
  'longitude': 12123.2348,
  'ew': 'E',
  'utc': 041139.000,
  'data_valid': 'A',
  'pos_mode': 'A'},
 59)
microstacknode.gps.l80gps.gpgsa_as_dict(gpgsa_str)

Returns the GPGSA as a dictionary and the checksum.

>>> gpgsa_as_dict('$GPGSA,A,3,14,06,16,31,23,,,,,,,,1.66,1.42,0.84*0F')
({'message_id': 'GPGSA',
  'mode': 'A',
  'fix': 3,
  'satellites_on_channel': [14, 06, 16, 31, 23, 0, 0, 0, 0, 0, 0, 0],
  'pdop': 1.66,
  'hdop': 1.42,
  'vdop': 0.84},
  77)
microstacknode.gps.l80gps.gpgsv_as_dict(gpgsv_str)

Returns the GPGSV as a dictionary and the checksum.

>>> gpgsv_as_dict('$GPGSV,3,1,12,01,05,060,18,02,17,259,43,04,56,287,28,09,08,277,28*77')
({'message_id': 'GPGSV',
  'num_messages': 3,
  'sequence_num': 1,
  'satellites_in_view': 12,
  'satellite': [{'id': 01,
                 'elevation': 05,
                 'azimuth': 060,
                 'snr': 18},
                {'id': 02,
                 'elevation': 17,
                 'azimuth': 259,
                 'snr': 43},
                {'id': 04,
                 'elevation': 56,
                 'azimuth': 287,
                 'snr': 28},
                {'id': 09,
                 'elevation': 08,
                 'azimuth': 277,
                 'snr': 28}]},
  77)
microstacknode.gps.l80gps.gprmc_as_dict(gprmc_str)

Returns the GPRMC as a dictionary and the checksum.

>>> gprmc_as_dict('$GPRMC,013732.000,A,3150.7238,N,11711.7278,E,0.00,0.00,220413,,,A*68')
({'message_id': 'GPRMC',
  'utc': 0.0,
  'data_valid': 'A',
  'latitude': 3150.7238,
  'ns': 0.0,
  'longitude': 0.1,
  'ew': 'A',
  'speed':,
  'cog':,
  'date':,
  'mag_var':,
  'eq':,
  'pos_mode':},
  0C)
microstacknode.gps.l80gps.gptxt_as_dict(self)

GPTXT Message ID XX Total number of messages in this transmission. (01~99) YY Message number in this transmission. (01~99) ZZ Severity of the message ‘00’= ERROR ‘01’= WARNING ‘02’= NOTICE ‘07’= USER Text messasage

microstacknode.gps.l80gps.gpvtg_as_dict(gpvtg_str)

Returns the GPVTG as a dictionary and the checksum.

>>> gpvtg_as_dict('$GPVTG,0.0,T,,M,0.0,N,0.1,K,A*0C')
({'message_id': 'GPVTG',
  'cogt': 0.0,
  't': 'A',
  'cogm': '',
  'speedn': 0.0,
  'speedk': 0.1,
  'pos_mode': 'A'},
  0C)
microstacknode.gps.l80gps.hexstr2bytearray(s)

Converts a string of hex characters to bytes.

‘DEADBEEF’

becomes

bytearray(b’\xde\xad\xbe\xef’)
microstacknode.gps.l80gps.l80gps_checksum_is_valid(gps_str)

Returns True if the checksum is valid in an GPS L80 protocol line.

!!!! This method assumes gps_str is a byte string. !!!!

microstacknode.gps.l80gps.parse_float(bytes)

Converts four bytes into a float.

microstacknode.gps.l80gps.parse_int(bytes)

Converts two bytes into an interger.

microstacknode.gps.l80gps.parse_locus_data(data, format='basic')

Returns the LOCUS data in a sensible structure according to the format.

microstacknode.gps.l80gps.parse_long(bytes)

Converts four bytes into a long integer.

microstacknode.gps.l80gps.pmtklog_as_dict(pmtklog_str)

Returns the PMTKLOG as a dictionary and the checksum.

>>> pmtklog_as_dict('$PMTKLOG,456,0,11,31,2,0,0,0,3769,46*48')
({'message_id': 'PMTKLOG',
  'serial': 456,
  'type': 0,
  'mode': 11,
  'content': 31,
  'interval': 2,
  'distance': 0,
  'speed': 0,
  'status': 0,
  'number': 3769,
  'percent': 46},
 48)

«  Examples   ::   Contents   ::   MMA8452Q Accelerometer Reference  »