ttlappalainen / NMEA0183

Library for handling NMEA0183 messages
73 stars 47 forks source link

Checksum use ? (Always ON?) #53

Closed dagnall53 closed 11 months ago

dagnall53 commented 11 months ago

First, huge thanks for this library. I am trying to make use of it in a N2K>0183 project that is based on a NMEA0183 multiplexer. This previous multiplexer code optionally allowed the acceptance of 0183 messages with incorrect checksums to be parsed. (This sometimes useful if you are trying handwritten 0183 messages and cannot run a checksum generator).

Am I correct that the 0183 handlers in the library ALL require the checksum to be correct? Or is there a "checkChecksum" boolean somewhere that I can turn on and off to allow parsing of incorrectly checksummed messages? ---I have tried to see where the checksum is "checked" but have failed.---- As far as I can see the NMEA decoders do not check checksums..!

One option I can see to "allow" incorrect checksums would be to parse all incoming messages and deliberately set (correct) checksums before passing them to the handler. But this seems a rather extreme approach!

Many thanks Dagnall

ttlappalainen commented 11 months ago

No option to pass checksum. That would also require different handling for reading message.

I'll prefer to think some automation for testing instead of handwriting messages.

dagnall53 commented 11 months ago

I may have found where I am confusing myself.. I have used LocalMsg.SetMessage(nmea_IN) to set my tNMEA0183Msg "LocalMsg" from my input (const char* nmea_IN). But have used it as a boolean .. so I was only parsing "correct" checksums.

dagnall53 commented 11 months ago

Many Thanks.. Our messages crossed.. In my case I have already checked for checksums (IF selected ) BEFORE I get to LocalMsg.SetMessage(nmea_IN).. So while I agree about an automated tester, :-) I have hacked the library to disable the checksum test right at the end of SetMessage -- and will need to remember to do that again if I update the Library!

PS.. Secondary Question Is there a way to get your libraries to automatically show in Arduino Libraries listings? So that I can update them when you update them - Cheers!

ttlappalainen commented 11 months ago

Note that your solution may have problem. If message does not have checksum ($...*CC) SetMessage will never be called.

With invalid checksum, it may mean that anywhere on message is error. So why to rely data without chcksum?

dagnall53 commented 11 months ago

HI.. I agree. Its not for times when the data is essential! When actually on the boat Checksums should be used!

Did you see the comment about getting this "library" (and the N2K) somehow included in the list that Arduino checks every time it starts?

ttlappalainen commented 11 months ago

About library update. In a way it is nice feature. But unfortunately I have learned that with many libraries updates are not always backward compatible. Then with single click you are in trouble - I have managed to keep compatibility.

After you have go more experienced, I'll prefer to move some better development environment e.g., VSCode and PlatformIO. There you can keep projects more separated and project local copy for special libraries. In this way if you update backward incompatible library for one project, it does not destroy others. It has pros and cons.