Skip to content

Andor: hold one SDK lock across camera selection and SDK calls (slicecam L frame showing R's image) - #493

Open
cfremling wants to merge 1 commit into
mainfrom
fix/andor-sdk-camera-race
Open

cfremling wants to merge 1 commit into
mainfrom
fix/andor-sdk-camera-race

Conversation

@cfremling

@cfremling cfremling commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

The Andor SDK has one current camera per process. acquire_one() selected its camera only when starting the exposure, then waited (WaitForAcquisitionTimeOut) and read (GetAcquiredData16) on whatever camera was current seconds later. slicecamd's 60 s temperature thread selects L then R; when it ran during L's exposure, L's wait returned at once and L read R's last frame, so the slicecam L image showed R's. Fine acquisition centroids on that same image.

  • Interface::sdk_mtx (static, recursive) is held from select_camera() through the SDK calls in every method, and never while taking image_data_mutex.
  • acquire_one(): start under the lock, wait by handle (WaitForAcquisitionByHandleTimeOut) without it, then select and read the data and temperature under it.
  • wait_for_acquisition() and get_image_data() no longer select a camera.
  • close() selects its camera before ShutDown(); open() and set_image() release the lock around image_data_mutex.

The display-level change (sky level subtracted from the displayed image, BGSUB) is now #512.

Rebuild, restart slicecamd and acamd. Tested on sky using branch cf/summit-20261020 on 2026-10-28/29 (no swapped frame in a 30-minute watch of 193 frames, none seen all night) and using branch cf/summit-20261030 on 2026-11-03.

Jira: PAL-178.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T18:20:34.543891Z 2a3d081 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cfremling cfremling changed the title Andor: hold one SDK lock across camera selection and SDK calls (slicecam L frame showing R's image) slicecam: fix L frame showing R's image (Andor SDK camera race); display L and R at one level Oct 28, 2026
cfremling added a commit that referenced this pull request Oct 28, 2026
Reverts e5953dd (BGSUB), 722c8f1 (DATASEC median subtraction) and
044b658 (Andor SDK lock). CF 2026-10-28: see what the slicecam frames look
like on main's code. The subtraction did not level L: L's DATASEC starts
well left of its illuminated columns, so its median is not L's lit level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cfremling
cfremling force-pushed the fix/andor-sdk-camera-race branch from c8d391a to 6fedcbf Compare October 28, 2026 19:15
@cfremling

cfremling commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

Tested on sky 2026-10-28/29 UT using branch cf/summit-20261020: the Andor lock ran from 18:20 UT, 0 swapped L/R frames in a 30-minute watch of /tmp/slicecam.fits (193 frames, temperature polls every 60 s) and none seen by the observers through the night; the sky-level display subtraction ran from 19:21 UT and the observers judged it good on the night sky.

The Andor SDK has one current camera per process. acquire_one() selected its
camera only when starting the exposure, then waited (WaitForAcquisitionTimeOut)
and read (GetAcquiredData16) on whatever camera was current seconds later.
slicecamd's 60 s temperature thread selects L then R; when it ran during L's
exposure, L's wait returned at once and L read R's last frame, so the slicecam
L image (also used by fine acquisition) showed R's.

- Interface::sdk_mtx (static, recursive) is held from select_camera() through
  the SDK calls in every method, and never while taking image_data_mutex.
- acquire_one(): start under the lock, wait by handle without it, then select
  and read the data and temperature under it.
- wait_for_acquisition() and get_image_data() no longer select a camera.
- close() selects its camera before ShutDown(); open() and set_image()
  release the lock around image_data_mutex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cfremling
cfremling force-pushed the fix/andor-sdk-camera-race branch from 6fedcbf to 8df99d5 Compare November 5, 2026 18:55
@cfremling cfremling changed the title slicecam: fix L frame showing R's image (Andor SDK camera race); display L and R at one level Andor: hold one SDK lock across camera selection and SDK calls (slicecam L frame showing R's image) Nov 5, 2026

This branch has not been deployed

No deployments
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.

3 participants