Skip to content

fix(camera): ToupTek software trigger ignored after a switch on a stopped stream - #704

Closed
maragall wants to merge 1 commit into
feat/record-zstack-acquisitionfrom
fix/toupcam-software-trigger-source
Closed

maragall wants to merge 1 commit into
feat/record-zstack-acquisitionfrom
fix/toupcam-software-trigger-source

Conversation

@maragall

@maragall maragall commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

On a ToupTek camera, switching from Hardware Trigger to Software Trigger while the stream is stopped leaves the camera unable to take software-triggered frames. The trigger mode becomes software, but the trigger source stays on the hardware input, so Trigger() is ignored.

Record + Z-Stack (#564) stops the stream between its phases, so a run started from Hardware Trigger live view hits this. The recording completes, then the z-stack's first trigger times out (Timed out waiting ... for a frame, aborting acquisition) and no z-stack is written. This happened 3/3 times on an ITR3CMOS26000KMA.

Cause

The SDK moves the trigger source (IOCONTROLTYPE_TRIGGERSOURCE: 1 = GPIO0, 5 = software) along with OPTION_TRIGGER only while the stream runs. _set_acquisition_mode_imp sets the source explicitly for hardware trigger, but leaves it to the SDK for software trigger. Measured at camera level, with no Record + Z-Stack involved:

Sequence Source after the switch Software trigger
Hardware → Software, stream running 5 frame in 0.08 s
Hardware-trigger live, then Software, stream running 5 frame in 0.08 s
Hardware → Software, stream stopped 1 no frame
Same, with a continuous recording in between 1 no frame
Previous state, source set to 5 by hand 5 frame in 0.08 s

Fix

When entering SOFTWARE_TRIGGER, set the trigger source to software explicitly, the way the hardware branch sets its own source. A camera that rejects the call only logs a warning, which is the same behaviour as today. Only ToupTek cameras are affected, and only when they enter software trigger. At startup and on a live-view switch the source is already 5, so the write changes nothing there.

test_camera_toupcam_trigger_source.py models the stopped-stream behaviour with a fake SDK. It fails without the change and passes with it.

Verified on hardware

On the ITR3CMOS26000KMA:

Not tested: level-mode hardware trigger (this microscope uses edge mode) and other ToupTek models.

Stacking

This PR is based on feat/record-zstack-acquisition (#564) and merges into it; #564 is the branch that merges to master. The fix was briefly pushed directly on #564 (eb441dd) and has been reverted there (ee706e1), so this PR now holds it alone.

🤖 Generated with Claude Code

…eps the hardware trigger source

The SDK moves the trigger source to software along with OPTION_TRIGGER only while the
stream runs. Record + Z-Stack stops the stream between phases, so a run started from
hardware-trigger live view switched to software trigger with the source still on GPIO0:
the first z-stack trigger was ignored and the run aborted with no z-stack (3/3 on an
ITR3CMOS26000KMA). Set the source explicitly, as the hardware branch does for its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maragall added a commit that referenced this pull request Oct 12, 2026
…tream keeps the hardware trigger source"

This reverts commit eb441dd. The fix moves to its own PR, #704,
which is stacked on this branch and merges into it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maragall
maragall force-pushed the fix/toupcam-software-trigger-source branch from 9cb9dcf to c550ee7 Compare October 12, 2026 12:30
@maragall
maragall changed the base branch from feat/in-process-zarr-saving to feat/record-zstack-acquisition October 12, 2026 12:31
@maragall

Copy link
Copy Markdown
Collaborator Author

Closing: we are fixing this inside #564 instead (the z-stack switches to software trigger after its stream starts), so the shared ToupTek driver stays unchanged.

?? Generated with Claude Code

@maragall maragall closed this Oct 12, 2026
@maragall
maragall deleted the fix/toupcam-software-trigger-source branch October 12, 2026 12:36
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