Issue with EOFError Handling in _parse_nmea Method #131
Replies: 7 comments 1 reply
-
The NMEA protocol specifies that sentences should end with CRLF (b"\x0d\x0a") - this is what GNSS receivers output and this is what the NMEA parser checks for. This is intentional behaviour. The relevant NMEA EOM check is here - the code segment you link to to above only applies to UBX or RTCM binary message types, which do not use a CRLF terminator. In what way is this problematic? NB: some generic text editors (e.g. Notepad) can corrupt NMEA data logs by stripping out the CR or LF character. It's possible this may be the cause of your issue. I recommend viewing or editing NMEA data files with a proper hex editor that preserves the CRLF line ending. This issue is explicitly mentioned in the Troubleshooting section of README.md. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
FYI here's an example code snippet that WILL parse your from pynmeagps import NMEAReader
with open("test.log", "rb") as infile:
i = 0
while True:
raw = infile.readline()
if not raw:
break
msg = NMEAReader.parse(raw)
print(msg)
i += 1
print(f"{i} NMEA messages read from input file") ...
<NMEA(GPGGA, time=15:42:48.730000, lat=51.5895333333, NS=N, lon=-0.4811666667, EW=W, quality=1, numSV=12, HDOP=1.0, alt=0.0, altUnit=M, sep=0.0, sepUnit=M, diffAge=, diffStation=)>
<NMEA(GPGSA, opMode=A, navMode=3, svid_01=1, svid_02=2, svid_03=3, svid_04=4, svid_05=5, svid_06=6, svid_07=7, svid_08=8, svid_09=9, svid_10=10, svid_11=11, svid_12=12, PDOP=1.0, HDOP=1.0, VDOP=1.0)>
<NMEA(GPRMC, time=15:42:48.730000, status=A, lat=51.5895333333, NS=N, lon=-0.4811666667, EW=W, spd=2263.8, cog=298.1, date=2023-11-28, mv=0.0, mvEW=W)>
8583 NMEA messages read from input file However, in parsing this data I notice that this appears to be a very old version of the NMEA protocol (< NMEA 2.3 - the latest version is 4.11) - e.g. the GPRMC messages lack the |
Beta Was this translation helpful? Give feedback.
-
Hi again, I also have one more thing to add. I thought this might be something you or others using your library could be interested in. It's not every day you get to decode a bit of a mystery, right? If you think this info could be useful, I'm more than happy to share what I've found. (if someone else haven't found/published them yet whici I'm not aware of :D ) Your library has been a great help in this little adventure. Let me know if this sounds interesting to you and how I might share these discoveries with the community. |
Beta Was this translation helpful? Give feedback.
-
Hi again @ariansharifi You are not the first to suggest this. There is unfortunately a bit of a long story here... The UBX © protocol is a proprietary protocol, copyrighted by u-blox™. The GNSS device interface specifications are published by u-blox on their web site and are effectively in the public domain (e.g. https://www.u-blox.com/sites/default/files/u-blox-M9-SPG-4.04_InterfaceDescription_UBX-21022436.pdf). It is these documents that However, some aspects of the UBX protocol are NOT in the public domain and u-blox only makes this restricted information available to developers under NDA (Non-Disclosure Agreement). This NDA-protected material cannot (legally) be incorporated into an open-source library like The restricted information includes, for example, UBX payloads relating to:
I am myself an NDA signatory and have in the past asked u-blox if they would be prepared to allow me to include some or all of these restricted payload definitions in So the current situation is that
In the illustration above, the messages are actually internal debug messages but their content is known only to u-blox engineers (and NDA signatories). Hope this helps. FYI you might be interested to read this older Discussions topic on the same subject: #120 |
Beta Was this translation helpful? Give feedback.
-
ok got it, so we don't dig into message that what's are they but I can give my app that can update a firmware file to ublox reciver using your lib :D we don't know what those messages are exactly, but we can do our own firmware update with those ( if you can publish it in the example folder without any legal problem) |
Beta Was this translation helpful? Give feedback.
-
So - yes - it is technically possible to update u-blox firmware via UBX UPD messages, but it wouldn't be a trivial undertaking. I have sight of the necessary UPD firmware upgrade protocols (under NDA) and have a private fork of pyubx2 that already implements most of the necessary functionality, but for reasons I've already outlined I'm not at liberty to put that in the public domain. The current public version of pyubx2 does NOT implement the necessary UPD message types and the update process itself is quite complex - it's not a case of simply sending a UBX firmware payload to the receiver. The other issue (as I've mentioned in earlier Discussion threads) is that adding a firmware upgrade facility to pyubx2 introduces a very real risk of users bricking their devices (either through bugs in the code or end-user abuse). So while the BSD-2 license explicitly excludes any kind of warranty, I couldn't in all conscience introduce such a facility without rigorous testing across a range of u-blox devices, and as an unpaid volunteer project I simply don't have the resources to do that. Obviously you're at liberty to do whatever you want with the pyubx2 library, but I would advise caution in this area. Happy to continue this Discussion thread but suggest moving it to a separate topic. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I hope this message finds you well. I've been using your pyubx2 library, and I'm really impressed with its functionality and design. Recently, I encountered a potential issue when feeding a file with NMEA content into the library, which I wanted to bring to your attention.
Issue Description
In the
_parse_nmea
method source code here, the library checks for the end of an NMEA message to see if it terminates with a CRLF (\x0D\x0A
):Potential Concern
The above check raises an EOFError if the last two bytes of the message are not CRLF. However, this can be problematic, particularly when reading files with NMEA content. In my case, the method incorrectly raised an EOFError, leading to an early exit from the file processing.
Suggestion
It may be beneficial to revisit the EOF determination logic better to remove it, since EOF file check already done here:
I greatly appreciate the effort you've put into developing this library and hope this feedback is constructive. If there's any additional information I can provide or if I can assist in resolving this issue, please feel free to reach out.
Thank you for your time and contributions to the open-source community.
Best regards,
Beta Was this translation helpful? Give feedback.
All reactions