The mistake is actually ridiculous, but isn't that (always) very common?
Here is my solution:
#1
My GPS modules send sentences which are not included here yet.
I have added them.
Code: Select all
# Key: currently supported NMEA sentences. Value: parse method.
self.supported_sentences = {'GPRMC': self._gprmc, 'GLRMC': self._gprmc,
'GPGGA': self._gpgga, 'GLGGA': self._gpgga,
'GPVTG': self._gpvtg, 'GLVTG': self._gpvtg,
'GPGSA': self._gpgsa, 'GLGSA': self._gpgsa, 'GNGSA': self._gpgsa,
'GPGSV': self._gpgsv, 'GLGSV': self._gpgsv,
'GPGLL': self._gpgll, 'GLGLL': self._gpgll, 'GNGLL': self._gpgll,
'GNGGA': self._gpgga, 'GNRMC': self._gprmc,
'GNVTG': self._gpvtg,
}
But that was not all.
#2
The parser is called from this dictionary really very elegantly.
in -gprmc the data set is then evaluated.
There are '' None fields in the record. E.g. for Speed or Course on stationary devices.
The conversion into a float leads to a ValueError and therefore the whole data set is not evaluated anymore.
Hence the callback is omitted.
Code: Select all
s_type = self.supported_sentences[segs[0]](segs) # Parse
except ValueError:
s_type = False
I then convert empty fields to "0". This works well for Course and Speed.
Code: Select all
segs = [i if i != "" else "0" for i in segs] #replace empty with zero for better float conversion
But when Magnetic variation should be evaluated, ValueError, because "0" instead of "WE" in the field.
Well, 2° actually don't play any role, so comment out.
Now the callback works exactly as expected, HURRA!
Would it be less time-consuming to leave the sentence as it was?
And put the float-conversion into a try: section?
Or if-check before the float conversion for None-Entries?
Thank you for good ideas.
RT