-
Notifications
You must be signed in to change notification settings - Fork 126
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
fix garmin serial/usb device character encoding/decoding. #1117
Conversation
Coverage summary from CodacyMerging #1117 (b4181cd) into
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
On phone, but I think I like it. ... And most of my hyperactive heart attack in this code is in the layer below. It's mostly the jeeps level of stuff that can break a quarter of the world. A streetpioli and a 60 are both USB, but very different in the wire. Heck, a 60c and 60cx are very different. |
By default the receiver charset is US-ASCII. The switch on gps_waypt_type and gps_save_id may update this to windows-1252. After all that if the codec option was used we will override the automatically selected codec with whatever was asked for in that option. At this point on all platforms, with Qt5 or Qt6, we should have access to at least the minimal set of "supported encodings" promised by Qt5. This works on Qt6 because we are using the Qt 5 Core Compat module. Included in the minimal set of supported encodings is Windows-1250 to 1258. If you feel like it checking the lengths of the converted strings in the writer might be helpful. Also looking for any implicit conversions in the reader I missed (I did catch a couple). |
Is his ID missed in the switch that would have auto selected 1252? Maybe
it's a localized device with a different ID. Garmin does that. We've had to
special cases devices in the market for Japanese and such before. They
would get the default, disallowing spaces and lowercase and such.
We'll lose qt5cimoat with qt7 ... or before. Without that do we have at
least minimal common codecs? (I don't much care about the full list of 200
or whatever that you just posted. 125x, latin1, utf8/16, and ...)
…On Mon, May 15, 2023, 3:05 PM tsteven4 ***@***.***> wrote:
By default the receiver charset is US-ASCII. The switch on gps_waypt_type
and gps_save_id may update this to windows-1252. After all that if the
codec option was used we will override the automatically selected codec
with whatever was asked for in that option.
At this point on all platforms, with Qt5 or Qt6, we should have access to
at least the minimal set of "supported encodings" promised by Qt5
<https://doc.qt.io/qt-5/qtextcodec.html>. This works on Qt6 because we
are using the Qt 5 Core Compat module. Included in the minimal set of
supported encodings is Windows-1250 to 1258.
If you feel like it checking the lengths of the converted strings in the
writer might be helpful. Also looking for any implicit conversions in the
reader I missed (I did catch a couple).
—
Reply to this email directly, view it on GitHub
<#1117 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCSD33Q2R5ZU7UV3N3U3YLXGKD7LANCNFSM6AAAAAAYCT76PU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I don't think it is missed. Before I added the codec option he was seeing the line I think were good with Qt5Compat until Qt7, then I think we will only have codecs if Qt is built with ICU support. And I don't think the Qt supplied builds don't have ICU support enabled on all platforms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I quite like it. Merge it down whenever you're ready.
assert(!QString(valid_waypt_chars).contains('^')); | ||
assert(!QString(valid_waypt_chars).contains('-')); | ||
assert(!QString(valid_waypt_chars).contains('[')); | ||
assert(!QString(valid_waypt_chars).contains(']')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be a single QString::contains(const QRegularExpression &re, but it would admittedly be a quoting nightmare and wouldn't give you a single error message like this will. Your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and it would save a bunch of QString construction. But, the code is only run on init, and only in debug builds, so I thought clarity was better.
@robertlipe, Lines 1012 to 1021 in 488aa41
|
Coverage summary from CodacyMerging #1117 (ced87b9) into
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
You're right. That loop at 1012 is underachieving. We toss those those instead of "fixing" them, but such a receiver would have surely had 'must_upper' set, so it's presumably a very minority case. I'd expect the right thing to do here is replacing this with a call to write_char_string after a conditional toUpper on the string if mustupper is set. I think you're done here. Nice work! |
We clear badchars for newer devices already, effectively not cleaning wpt names.
@robertlipe are you good with this resolution of rtept names? For wpt names we defeat the cleaning function of mkshort when receiver_must_upper is false, see the similar comment in the code. Lines 1058 to 1065 in 911ab99
|
Yes. It's definitely less wrong than what we already have, so commit this,
please.
There may be other dragons lurking, but these are dark, dark corners so
let's not deadlock on "perfect".
Thanx!
…On Fri, May 19, 2023 at 1:28 PM tsteven4 ***@***.***> wrote:
@robertlipe <https://github.com/robertlipe> are you good with this
resolution of rtept names? For wpt names we defeat the cleaning function of
mkshort when receiver_must_upper is false, see the similar comment in the
code.
https://github.com/GPSBabel/gpsbabel/blob/911ab99766b7eb84336be8863f857ffd872ae4f6/garmin.cc#L1058-L1065
—
Reply to this email directly, view it on GitHub
<#1117 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCSD3ZEPB2DLKGVIQOD2V3XG63WPANCNFSM6AAAAAAYCT76PU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
* attempt to use correct codec with garmin reader. the garmin writer is unchanged as of yet. * fix garmin writer wrt encoding. * add garmin option to force codec. * update serialization ref files for garmin codec option. * fix potential overwrite bug with route/track names in garmin writer. * fix up for old Qt. * correct assertion * use static_assert to for fixed buffer size checks. * document garmin codec option * don't clean rtept/trkpt names for newer devices. We clear badchars for newer devices already, effectively not cleaning wpt names.
We got away with breaking this for a long time, but we finally got caught.
This resolves #1115
@svintuss has tested both read and write on his Garmin GPSmap 60cx using windows-1251.