Skip to content

Use ASCOM Gain Value mode only; fix NINA "Index was out of range" on connect (#8) - #9

Merged
Scdouglas1999 merged 1 commit into
mainfrom
fix/issue-8-gain-mode
Aug 31, 2026
Merged

Scdouglas1999 merged 1 commit into
mainfrom
fix/issue-8-gain-mode

Conversation

@Scdouglas1999

Copy link
Copy Markdown
Owner

Summary

Fixes #8Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') when NINA connects to an X-T4 / X-H2S with Fujicom 3.0.0.

Root cause. 3.0.0 exposed both ICameraV3 gain modes at once: Gain returned the ISO value (e.g. 800) while Gains also returned the 24-entry list of fixed ISO values. NINA treats a populated Gains list as authoritative, maps it to indices, and reads Gains[device.Gain]Gains[800], which throws inside NINA during connection. The exception is NINA's (.NET 8 (Parameter 'index') formatting), not the driver's, which is why the driver logs show a clean connect followed by a disconnect.

2.x only avoided this because its XSDK_CapSensitivity P/Invoke had a bogus extra int lDR parameter: the call failed, the ISO list stayed empty, and clients silently fell back to value mode. Correcting that signature in 3.0.0 exposed the latent contract violation.

Fix. The driver now uses a single mode, ASCOM Gain Value:

  • Gain = ISO number, GainMin/GainMax = SDK-discovered range, Gains throws PropertyNotImplementedException.
  • Gain set maps in-range values that fall between the camera's fixed ISO steps onto the nearest supported ISO (FujifilmCapabilities.NearestSensitivity) instead of passing an unsupported value to the SDK.
  • Value mode was chosen over index mode because NINA's index mode shows bare indices (0–23) in its UI and writes the index into FITS GAIN; value mode gives GAIN=800, matching what 2.x users effectively had.

Also: version → 3.0.1, release notes, README clarification, new core tests (nearest-ISO mapping + a regression guard that the COM-facing driver exposes exactly one gain mode).

Validation

  • 10/10 core checks pass (dotnet run --project tests/Fujicom.Core.Tests).
  • Fuji/Fuji.csproj compiles on Linux with the same msbuild invocation CI uses.
  • build/verify-sdk-interop.py passes (25 XAPI exports, 7 LibRaw exports, 5 contracts).
  • Not verifiable in CI: an actual NINA connect on Windows with a body.

🤖 Generated with Claude Code

https://claude.ai/code/session_01S5cJ7xcdK2my6cUFBhwPCi

…connect

Fujicom 3.0.0 exposed both ICameraV3 gain modes at once: Gain returned the
ISO value while Gains also returned the list of fixed ISO values. Clients
such as NINA treat a populated Gains list as authoritative, map it to
indices, and read Gains[device.Gain] -> Gains[800], which throws
ArgumentOutOfRangeException inside the client during connection (#8).
Earlier releases avoided this only because their XSDK_CapSensitivity
P/Invoke had the wrong signature, failed, and left Gains empty.

- Gains now throws PropertyNotImplementedException; Gain is the ISO
  number bounded by GainMin/GainMax (Gain Value mode).
- Gain set maps in-range values that fall between the camera's fixed ISO
  steps onto the nearest supported ISO instead of passing them to the SDK.
- Add FujifilmCapabilities.NearestSensitivity with tests, plus a
  regression guard that the driver exposes exactly one gain mode.
- Bump version to 3.0.1; add release notes and README clarification.

Fixes #8

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S5cJ7xcdK2my6cUFBhwPCi
@Scdouglas1999
Scdouglas1999 merged commit 3260812 into main Aug 31, 2026
2 checks passed
@Scdouglas1999
Scdouglas1999 deleted the fix/issue-8-gain-mode branch August 31, 2026 23:35
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.

index was out of range

1 participant