Pieusb integration - #747
Draft
davide-b wants to merge 15 commits into
Draft
Conversation
…into pieusb_integration
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.
Add a second scanner backend: pieusb (direct USB)
Adds
PieusbBackendalongsideSaneBackend, driving Reflecta / Pacific Imagefilm scanners over raw USB through the pieusb
library instead of SANE. It is the first non-SANE backend, so a few
transport-neutral seams had to grow to fit it.
Requires
pieusb>=0.3.1, added as an optional dependency group (uv sync --group pieusb).What works
pieusb:{bus}:{address}device ids; capabilities derivedfrom INQUIRY
ScanParamsmaps onto pieusb's attribute-style options(
mode,color_depth,resolution,auto_exp, and the normalised windowscaled into device units).
analyze_preview+set_gain_offset("from preview")+updateGain2._ScanUnsupportedPlaceholderthere because python-sane has no Windows build;pieusb is pyusb + a bundled libusb, so that gate is gone.
Progress reporting gained a phase
The bar used to move only during the read. A pieusb scan has distinguishable
phases (configuring, warming up, calibrating, metering, scanning,
post-processing), and with auto-exposure it runs the whole sequence twice, so a
single fraction was misleading. When the phase name is not provided, it defaults to "Scanning"
ScanWorker.progress/AppController.scan_progressare nowpyqtSignal(float, str)and the bar renders"Calibrating… 42%". The backendcontract in
base.py:Consequences worth knowing when reviewing:
That is intentional; the label is what carries the meaning.
progress(fraction). Three of its signatures widened toCallable[..., None]so
SaneSessionstill satisfies theScannerSessionprotocol while itsone-argument calls stay valid; no call sites or logic touched.
progressdefault the phase (ScanWorker's emit wrapper, itsbatch closure,
PerFrameRollSession's discard lambda).Autofocus is now a capability
Added autofocus support in the scanner capabilities dataclass, as some Reflecta scanners don't support it. It will hide the checkbox and set it to unchecked if this function is not supprorted.
Other things to note
PieusbSessionis a stub —open_sessionraisesNotImplementedError.Nothing in
negpy/calls it: single scans,run_batchframes andPerFrameRollSessionpreview slots all go throughbackend.scan.vendor-driver-bound device on Windows currently just looks like "no devices").
tests/scanners/test_backend_contract.pystill runs against SANE only; addingpieusb needs a fake pieusb module and a Scanner double.
frameandframe_offset_mmare accepted and ignored.Risks / what to check before merging
base.py'sprotocol changed, so the shared paths deserve a look even though SANE's
behaviour is unchanged.