MartijnBraam / gpsd-py3

Python 3 GPSD client
107 stars 45 forks source link

KeyError: 'epc' #1

Closed kaylathedev closed 8 years ago

kaylathedev commented 8 years ago

I'm getting an error called, "KeyError: 'epc'" on line 69.

Here's the traceback.

Traceback:
    File "<stdin>", line 1, in <module>
    File "........ gpsd/__init.py", line 179, in get_current
      return GpsResponse.from_json(response)
    File "........ gpsd/__init__.py", line 69, in from_json
      result.error['c'] = last_tpv['epc'],
KeyError: 'epc'

I telneted into the GPSD server, and here's what I get. The lines beginning with "?" are what I typed.

$ telnet localhost 2947
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
{"class":"VERSION","release":"3.6","rev":"3.6","proto_major":3,"proto_minor":7}
?WATCH={"enable":true}
{"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttyAMA0","activated":"2016-03-13T18:46:05.860Z","flags":1,"driver":"Generic NMEA","native":1,"bps":9600,"parity":"N","stopbits":1,"cycle":1.00}]}
{"class":"WATCH","enable":true,"json":false,"nmea":false,"raw":0,"scaled":false,"timing":false}
?POLL;
{"class":"POLL","time":"2016-03-13T18:46:16.134Z","active":1,"tpv":[{"class":"TPV","tag":"GLL","device":"/dev/ttyAMA0","mode":3,"time":"2016-03-15T01:57:22.000Z","ept":0.005,"lat":0.0,"lon":0.0,"alt":0.0,"epx":0.0,"epy":0.0,"epv":0.0,"track":0.0000,"speed":0.0,"climb":0.000,"eps":0.0}],"gst":[{"class":"GST","tag":"GLL","device":"/dev/ttyAMA0","time":"1970-01-01T00:00:00.000Z","rms":0.000,"major":0.000,"minor":0.000,"orient":0.000,"lat":0.000,"lon":0.000,"alt":0.000}],"sky":[{"class":"SKY","tag":"GLL","device":"/dev/ttyAMA0","xdop":0.0,"ydop":0.0,"vdop":0.0,"tdop":0.0,"hdop":0.0,"gdop":0.0,"pdop":0.0,"satellites":[{"PRN":0,"el":0,"az":0,"ss":0,"used":true},{"PRN":0,"el":0,"az":0,"ss":0,"used":false}]}]}

I stripped out any numbers that could potentially identify my location.

It looks like that your script is looking for the "epc" key in the last "tpv" entry, but it doesn't exist.

I don't know what epc stands for, but all I have is eps, epx, epy, and epv which I would assume are the errors for speed, position, etc.

Feel free to ask for more information if needed.

MartijnBraam commented 8 years ago

epc is the error for the vertical (climb) speed. It's strange that the key is missing since you have a 3D fix and your GPS does return a vertical speed.

I've added some code to use 0 as error for missing values. The fix is uploaded to pypi in version 0.1.1

kaylathedev commented 8 years ago

It works! The get_current function is now returning a GpsResponse object.