Package: py-gpsd2
Python3 GPSD clientThis is a library for polling gpsd in Python3.Forked from (gpsd-py3)[https://github.com/MartijnBraam/gpsd-py3]InstallationInstall through pip::$ pip3 install py-gpsd2UsageJust import it and poll the gps. Only a single gpsd server a time is supported::import gpsd2

# Connect to the local gpsd
gpsd2.connect()

# Connect somewhere else
gpsd2.connect(host="127.0.0.1", port=123456)

# Get gps position
packet = gpsd2.get_current()

# See the inline docs for GpsResponse for the available data
print(packet.position())GpsResponse Object InformationPropertiesDescription and information copied fromhttp://catb.org/gpsd/gpsd_json.html.modeDescription:Indicates the status of the GPS receptionAvailability:AlwaysData Type:IntPossible Values:0=no mode value yet seen, 1=no fix, 2=2D fix, 3=3D fixsatsDescription:The number of satellites received by the GPS unitAvailability:AlwaysData Type:IntlatDescription:Latitude in degreesAvailability:mode >= 2Data Type:Possible Values:-90.0 to 90.0lonDescription:Longitude in degreesAvailability:mode >= 2Data Type:floatPossible Values:-180.0 to 180.0trackDescription:Course over ground, degrees from true northAvailability:mode >= 2Data Type:floathspeedDescription:Speed over ground, meters per secondAvailability:mode >= 2Data Type:floattimeDescription:Time/date stamp in ISO8601 format, UTC. May have a fractional part of up to .001sec precision May be absent if mode is not 2 or 3.Availability:mode >= 2Data Type:stringSample Value:2016-08-05T01:51:44.000ZerrorDescription:Error informationc - ecp: Climb/sink error estimate in meters/sec, 95% confidence.s - eps: Speed error estinmate in meters/sec, 95% confidence.t - ept: Estimated timestamp error (%f, seconds, 95% confidence). Present if time is present.v - epv: Estimated vertical error in meters, 95% confidence. Present if mode is 3 and DOPs can be calculated from the satellite view.x - epx: Longitude error estimate in meters, 95% confidence. Present if mode is 2 or 3 and DOPs can be calculated from the satellite view.y - epy: Latitude error estimate in meters, 95% confidence. Present if mode is 2 or 3 and DOPs can be calculated from the satellite view.Availability:mode >= 2(NOTE:c & v require mode >= 3)Data Type:dictionaryPossible Values:altDescription:Altitude in metersAvailability:mode >= 3Data Type:floatclimbDescription:Climb (positive) or sink (negative) rate, meters per secondAvailability:mode >= 3Data Type:floatMethodspositionDescription:Get the latitude and longtitude as tupleAvailability:mode >= 2Parameters:NoneReturn Type:tuple (latitude, longitude)Sample Value:(39.8333333, -98.585522)speedDescription:Get the horisontal speed with the small movements filtered outAvailability:mode >= 2Parameters:NoneReturn Type:floatposition_precisionDescription:Get the error margin in meters for the current fixAvailability:mode >= 2Parameters:NoneReturn Type:tuple (x-y plane, z direction)get_time(local_time: bool)Description:Get the GPS time in UTC or in local timezoneAvailability:mode >= 2Parameters:local_timeReturn Type:datetimemap_urlDescription:Get a openstreetmap url for the current positionAvailability:mode >= 2Parameters:NoneReturn Type:stringSample Value:http://www.openstreetmap.org/?mlat=39.8333333&mlon=-98.585522&zoom=15altitudeDescription:Get the altitude in metersAvailability:mode >= 3Parameters:NoneReturn Type:floatmovementDescription:Get the speed and direction of the current movement as dictAvailability:mode >= 3Parameters:NoneReturn Type:dictionaryspeedtrackclimbspeed_verticalDescription:Get the vertical speed with the small movements filtered outAvailability:mode >= 3Parameters:NoneReturn Type:floatException InformationNoFixError: Raised when a value is requested with the mode below the threshold for obtaining the dataNeeds at least 2D fixNeeds at least 3D fixGeneral ExceptionsUnexpected message received from gps: ...Unexpected data received as welcome. Is the server a gpsd 3 server?Information on Available FunctionsconnectDescription:Connect to a GPSD instanceParameters:host="127.0.0.1", port=2947Return Type:Noneget_currentDescription:Poll gpsd for a new positionParameters:NoneReturn Type:GpsResponse ObjectdeviceDescription:Get information about current gps deviceParameters:NoneReturn Type:dictionarypathspeeddriverSample Data:{'speed': 9600, 'path': '/dev/ttyS0', 'driver': 'MTK-3301'}Sample Code#!/usr/bin/env python3importgpsd# Connect to the local gpsdgpsd.connect()# Connect somewhere elsegpsd.connect(host="127.0.0.1",port=123456)# Get gps positionpacket=gpsd.get_current()# See the inline docs for GpsResponse for the available dataprint(" ************ PROPERTIES ************* ")print("  Mode: "+str(packet.mode))print("Satellites: "+str(packet.sats))ifpacket.mode>=2:print("  Latitude: "+str(packet.lat))print(" Longitude: "+str(packet.lon))print(" Track: "+str(packet.track))print("  Horizontal Speed: "+str(packet.hspeed))print(" Time: "+str(packet.time))print(" Error: "+str(packet.error))else:print("  Latitude: NOT AVAILABLE")print(" Longitude: NOT AVAILABLE")print(" Track: NOT AVAILABLE")print("  Horizontal Speed: NOT AVAILABLE")print(" Error: NOT AVAILABLE")ifpacket.mode>=3:print("  Altitude: "+str(packet.alt))print(" Climb: "+str(packet.climb))else:print("  Altitude: NOT AVAILABLE")print(" Climb: NOT AVAILABLE")print(" ************** METHODS ************** ")ifpacket.mode>=2:print("  Location: "+str(packet.position()))print(" Speed: "+str(packet.speed()))print("Position Precision: "+str(packet.position_precision()))print("  Time UTC: "+str(packet.time_utc()))print("Time Local: "+str(packet.time_local()))print("   Map URL: "+str(packet.map_url()))else:print("  Location: NOT AVAILABLE")print(" Speed: NOT AVAILABLE")print("Position Precision: NOT AVAILABLE")print("  Time UTC: NOT AVAILABLE")print("Time Local: NOT AVAILABLE")print("   Map URL: NOT AVAILABLE")ifpacket.mode>=3:print("  Altitude: "+str(packet.altitude()))# print("  Movement: " + str(packet.movement()))# print("  Speed Vertical: " + str(packet.speed_vertical()))else:print("  Altitude: NOT AVAILABLE")# print("  Movement: NOT AVAILABLE")# print(" Speed Vertical: NOT AVAILABLE")print(" ************* FUNCTIONS ************* ")print("Device: "+str(gpsd.device()))Sample Output************ PROPERTIES *************
                  Mode: 3
            Satellites: 10
              Latitude: 39.8333333
             Longitude: -98.585522
                 Track: 237.31
      Horizontal Speed: 0.0
                  Time: 2016-08-05T03:02:13.000Z
                 Error: {'v': 31.97, 't': 0.005, 'x': 10.055, 'c': (63.94,), 's': 35 .16, 'y': 17.58}
              Altitude: 100.3
                 Climb: 0.0
     ************** METHODS **************
               Location: (39.8333333, -98.585522)
                  Speed: 0
     Position Precision: (17.58, 31.97)
               Time UTC: 2016-08-05 03:02:13
             Time Local: 2016-08-04 23:02:13-04:00
                Map URL: http://www.openstreetmap.org/?mlat=39.8333333&mlon=-98.585522&zoom=15
               Altitude: 100.3
     ************* FUNCTIONS *************
                 Device: {'driver': 'MTK-3301', 'path': '/dev/ttyS0', 'speed': 9600}