Add serial barcode scanner#1028
Open
alexjamesgodfrey wants to merge 1 commit intoPyLabRobot:v1b1from
Open
Conversation
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.
Summary
Adds a generic serial barcode scanner implementation.
This supports barcode scanners configured as RS-232 or USB virtual COM devices, which I use to read WONE NICE scanners when configured to
USB virtual COM. The implementation uses PLR's existingpylabrobot.io.Serialwrapper and exposes the existingBarcodeScannercapability through aSerialBarcodeScannerdevice.WONE NICE usage
For the WONE NICE wireless scanner, I had to scan these setup barcodes from the manual so that it would stream barcodes via the com port:
Restore defaultsMatchInstant upload ModeUSB virtual COMAdd Carriage ReturnorCRDuplicate detection-OFFContinuous ModeorKeys TriggerAfter switching to
USB virtual COM, unplug/replug the USB receiver. It should appear as a serial port, for example:COM5/dev/ttyACM0or/dev/ttyUSB0Example:
If using VID/PID discovery instead of an explicit port:
Observed WONE NICE behavior: the scanner emits barcode data when it performs a decode event. With a barcode sitting statically in front of the scanner, it may not repeatedly emit the same barcode. Moving the barcode out of and back into the scan field creates a new decode event. This is scanner firmware behavior, not PLR behavior.
What's included
SerialBarcodeScannerDriverSerialconnection.portor VID/PID serial port resolution.SerialBarcodeScannerBackendBarcodeScannerBackend.Barcodeon successful read.Nonewhen the read window elapses without a barcode.trigger_commandanduntrigger_commandfor scanners with documented serial trigger commands.SerialBarcodeScannerDevicewiring driver + barcode scanning capability.Docs/API exports for the barcode scanning capability.
11 unit tests covering line reads, timeout behavior, trigger-command behavior, validation, and device lifecycle wiring.
Notes
I intentionally did not add WONE NICE-specific code. The WONE NICE works as a generic USB virtual COM barcode scanner, and the manuals I found do not document a host-side serial trigger protocol.
No native binaries, package data, HID dependencies, or Windows-specific code are added.
Validation
python3 -m unittest pylabrobot.capabilities.barcode_scanning.serial_testsuv run --extra test pytest pylabrobot/capabilities/barcode_scanning/serial_tests.pyuvx ruff check pylabrobot/capabilities/barcode_scanning/serial.py pylabrobot/capabilities/barcode_scanning/serial_tests.pyuvx mypy --follow-imports=skip pylabrobot/capabilities/barcode_scanning/serial.py pylabrobot/capabilities/barcode_scanning/serial_tests.pyHardware observed on WONE NICE receiver:
COM5USB Serial Device0C2E:0900YUNEW2263408636\r