Closed sterwen closed 5 years ago
GPS_nmea.py
looks like your own code here, and not pynmea.
The error seems to be that you are not decoding your input to ASCII before passing it to pynmea.
Hi Tom,
I found the error in the pynmea2 code. in the file stream.py, there is one statement that can't work in Python3 because it mix str and bytes. I have made the correction and some simplification in the file.
I can propose that to be posted to the main.
Rgds
Laurent Carré http://sterwen.typepad.com
Le dim. 12 mai 2019 à 22:50, Tom Flanagan notifications@github.com a écrit :
Closed #87 https://github.com/Knio/pynmea2/issues/87.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Knio/pynmea2/issues/87#event-2335442772, or mute the thread https://github.com/notifications/unsubscribe-auth/AHHVXVLTVREOMIM52YUNF2LPVB7JBANCNFSM4HGXV6XA .
Hello,
The bug still exist line 48 in the current version
lines = (self.buffer + data).split('\n')
This will raise an error because self.buffer is type if type(data) == str : line = data else: line = data.decode('ascii')
I have also removed the buffer because it is never used.
Actually, self.buffer
is used. Specifically if data
contains more than just one message, but last one is not yet complete.
I think self.buffer
should be initialized to b''
, instead of ''
, because it seems that NMEAStreamReader.stream.readline()
returns type bytes
, not str
.
<class 'bytes'> <class 'str'> Traceback (most recent call last): File "GPS_nmea.py", line 112, in
main()
File "GPS_nmea.py", line 106, in main
pos=nmeatty.getNMEAPosition()
File "GPS_nmea.py", line 69, in getNMEAPosition
for msg in self._reader.next():
File "/usr/local/lib/python3.4/dist-packages/pynmea2/stream.py", line 49, in next
lines = (self.buffer + data).split('\n')
TypeError: Can't convert 'bytes' object to str implicitly