fix(meade): accept the UTC offset format INDI sends - #303
Open
rbhbokka wants to merge 1 commit into
Open
Conversation
Regression from OpenAstroTech#291. The :SG arm of handleMeadeSet() uses Cursor::signed2(), which requires a leading sign and exactly two digits. INDI sends one digit and a fractional part, captured on connect to an OpenAstroExplorer: :SL10:42:31 :SC09/05/26 :SG+7.0 :Sg121*53 :St+37*20 So :SG+7.0# is answered "0", the handler never fires, and the site's UTC offset is silently left unset for every INDI/KStars session. Add a readUtcOffset() helper alongside the other read* helpers, accepting an optional sign and one or two digits and leaving trailing characters unconsumed so "+7.0" reads as +7. That matches the pre-OpenAstroTech#291 handler, which ran toInt() over the remainder, rather than inventing a new grammar. Every form that already parsed is unchanged, sign included. The one existing test that asserted ":SG+5" was rejected was pinning the regression -- the pre-OpenAstroTech#291 handler accepted it -- so it is repointed at genuinely malformed input; the rejection path is now covered by two tests instead of one. Range validation is deliberately not added: :SG+13 is accepted today and the tests pin that as-is, since rejecting it would change behaviour beyond the reported fault. Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Sep 7, 2026
rbhbokka
marked this pull request as ready for review
September 7, 2026 03:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Regression from #291. INDI cannot set the site's UTC offset, so local time is wrong for every INDI/KStars session.
The defect
The
:SGarm ofhandleMeadeSet()usesCursor::signed2(), which requires a leading+/-and exactly two digits. INDI sends one digit and a fractional part.Captured off the wire on an INDI connect to an OpenAstroExplorer:
:SG+7.0#is answered0, the handler never fires, and the offset is silently left unset. The pre-#291 handler rantoInt()over the remainder (inCmd.substring(1, 4).toInt()), which accepted all of these forms.The fix
A
readUtcOffset()helper alongside the otherread*helpers, accepting an optional sign and one or two digits, and leaving trailing characters unconsumed so+7.0parses as+7— matching the pre-#291 behaviour rather than inventing a new grammar.Every form that already parsed behaves identically, sign included;
+05→ 5 and-08→ −8 on both sides of the change.Tests
Added under the existing
---- UTC Offset (G) ----block: the exact INDI form; single-digit positive and negative (the suite never covered that intersection); unsigned; and the+5.5half-hour case (India, Newfoundland), which truncates becausesetLocalUtcOffset()takes anint— pinned so the limitation is documented rather than discovered in the field.One existing test asserted that
G+5was rejected. That was pinning the regression, since the pre-#291 handler accepted it, so it is repointed at genuinely malformed input rather than removed; the rejection path is now covered by two tests instead of one.pio test -e native: 277 pass (269 ondevelop+ 9 added − 1 repointed). Builds clean foroaeboardv1andramps.Deliberately not included
No range validation.
:SG+13/:SG-15are accepted ondeveloptoday and the tests pin that as-is — adding a-14..+14check would change behaviour beyond the reported fault and could reject something a real client sends. Happy to fold it in if you'd rather have it here.Scope is
:SGonly.:Sg(site longitude) has a related but separate #291 regression with a contested sign convention, so it is not touched here.File overlap
Touches the same two files as my
:Sgchange (MeadeParserSet.cpp,MeadeProtocol.hpp), in different blocks. Each is mergeable on its own; whichever lands second will need a trivial rebase and I'm happy to do it.