-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent AP $ECRMB from being more than 82 characters #3914
Conversation
NMEA0183 standard says max length is 82 including '$' and "LF" not 80. Corrected. |
IMHO, we should add a unit test here. It's easy to test, and having it in the test suite handles regressions. Might be able to do this later. |
hm... can't sleep, digging a little. The need to truncate the waypoint name is obvious for RMB messages when they become too long. However, is decreasing From a formal POV it seems questionable to change an overall configuration value like this. From a more practical standpoint won't this mean that all message waypoints, not just RMB, will be truncated? Is this what we want? FWIW, my gut feeling is that the instead of updating Thoughts? |
Yes, my first action was to only change truncation for RMB sent to the AP. But it could be I was "too smart" and over-reacting? To change only (EC)RMB when transferring it to an AP is an easy fix. Thoughts? |
Seems like none of us are really sure here. In that situation I think it might be better to just fix RMB messages for two reasons. The first is that I'm pretty sensitive about modifying configuration values like this. Such values are designed to be maintained by the user only. Modifying them in runtime like this adds some hard to understand and maintain code paths. The other reason is that in a situation where we don't really understand the consequences it's probably better to change as little as possible. Might add that I don't really see anything bad coming from having different waypoint names in RMB compared to other messages. But that's just me. Did a quick implementation hack before I wrote this. Let me know if you want me to share it. |
One more thing: Auto-generated waypoints typically has names like W00001, W00002, etc. truncating these is then certain to create duplicate names. Would it be better to strip the prefix in all or some cases, creating names like "0001", "0002" instead? |
When OCPN make routes the WP's names are like 001, 002, 003. Your W00001 may be a MBS example? |
Here, untested:
|
"What do we do if message still is too long here?" - Unlikely but this code will then make an endless loop I think. - Risky? |
Not an endless loop, wp_len will always terminate it. But risk for an oversized message anyway. Should probably at least be logged. |
Could be optimized somewhat, but I doubt it is necessary. |
Somewhat faster and easier to read:
|
Thanks, I'll will adapt your suggestions. |
Please don't take my untested code for granted. I discovered a bug, now fixed, but there could certainly be more. The overall design is however ok IMHO |
I don't see what you have changed? Edit: I see. you added snt = SENTENCE(); but for any reason it's not needed. Wasn't there before. |
Adapted and rebased |
hm... I see this:
First of all, it looks wrong to me: "W" longitudes are negative, the same for "S" latitudes. Also, we should not use the useless, disturbing Isn't it better written like:
EDIT: abs() -> fabs() EDIT2: Sorry for the mess, reading c++ docs is what it is. |
I didn't touched the lat/lon. Just copied from before. |
Either it was already buggy, or you missed something when copying. Compare to for example around line 533:
Note that when Now, my four lines makes the same thing as the snippet above, and I think it is overall better. But in any case, the bug needs to be fixed, and removing |
About RMC lat/lon. |
Now I think it's finally ready. A long story for a small change but now good. |
hrmpf... 13 lines instead of four to do the same thing ;) But this is just a matter of style, I guess. Don't worry about the error. This is the kind of error anyone can do from time to time. And it is always great when someone else looks at the code, four eyes sees so much more than two. I you could rebase and just change the commit comment to read |
Done! Thanks. |
Thanks for the finding and the PR! |
A suggestion to solve this CF report
If RMC >80 chars we truncate WP's name further one step until <=80 chars.
This truncation will also affect APB but the philosophy is to transfer the same WP name by all sentences.
No need to check the size for other sentences. They are not close to the 80 chars limit.
Tested here: