flucto-gmbh / motion-sensor-box

Creative Commons Attribution Share Alike 4.0 International
4 stars 1 forks source link

msb_gps: issue with old python package. #68

Closed k323r closed 1 year ago

k323r commented 1 year ago

To reproduce: start msb_gps with gpsd running and a usb gps device present.

k323r commented 1 year ago

So, i chased the bug down to a call to json.loads with the keyword encoding="ascii". Apparently, this keyword has been deprecated as of python 3.9, as json.loads internally guesses the encoding (see discussion here. From the module documentation):

Changed in version 3.9: The keyword argument encoding has been removed.

In the current codebase of gps, the call to json.loads has been fixed:

 def unpack(self, buf):
        """Unpack a JSON string."""
        try:
            # json.loads(,encoding=) deprecated Python 3.1.  Gone in 3.9
            # like it or not, data is now UTF-8
            self.data = dictwrapper(json.loads(buf.strip()))
        except ValueError as e:
            raise json_error(buf, e.args[0])
        # Should be done for any other array-valued subobjects, too.
        # This particular logic can fire on SKY or RTCM2 objects.
        if hasattr(self.data, "satellites"):
            self.data.satellites = [dictwrapper(x)
                                    for x in self.data.satellites]

It seems like the release of gps via pypy is version 3.19, which is over 3 years old. @pacjac & @kawindme: we might have to manually build gpsd afterall...

k323r commented 1 year ago

Found the next bug, that is probably not a bug, but a removed feature: in gps.py, line 261, the elevation of a satellite in view is requested from a dict through the keyword el. That keyword does not exist.

k323r commented 1 year ago

As of now, the official procedure is to compile gpsd version 3.24 from scratch and use the pythonbindings from that build. Closing this issue now.