Skip to content

fix(meade): accept the UTC offset format INDI sends - #303

Open
rbhbokka wants to merge 1 commit into
OpenAstroTech:developfrom
rbhbokka:fix/meade-utc-offset-format
Open

fix(meade): accept the UTC offset format INDI sends#303
rbhbokka wants to merge 1 commit into
OpenAstroTech:developfrom
rbhbokka:fix/meade-utc-offset-format

Conversation

@rbhbokka

@rbhbokka rbhbokka commented Sep 7, 2026

Copy link
Copy Markdown

Regression from #291. INDI cannot set the site's UTC offset, so local time is wrong for every INDI/KStars session.

The defect

The :SG arm of handleMeadeSet() uses Cursor::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:

:SL10:42:31  :SC09/05/26  :SG+7.0  :Sg121*53  :St+37*20

:SG+7.0# is answered 0, the handler never fires, and the offset is silently left unset. The pre-#291 handler ran toInt() over the remainder (inCmd.substring(1, 4).toInt()), which accepted all of these forms.

The fix

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 parses 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.5 half-hour case (India, Newfoundland), which truncates because setLocalUtcOffset() takes an int — pinned so the limitation is documented rather than discovered in the field.

One existing test asserted that G+5 was 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 on develop + 9 added − 1 repointed). Builds clean for oaeboardv1 and ramps.

Deliberately not included

No range validation. :SG+13 / :SG-15 are accepted on develop today and the tests pin that as-is — adding a -14..+14 check 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 :SG only. :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 :Sg change (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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant