KX2 barcode reader#

The optional barcode reader is an independent serial device. Configure the reader for external triggering before connecting; PLR leaves its stored mode, symbologies and firmware read window unchanged. See installation for finding the serial port.

from pylabrobot.paa.kx2 import KX2BarcodeReader

reader = KX2BarcodeReader(port="/dev/ttyUSB0")

Connect#

Setup opens 9600-baud, 8-N-1 serial with no RTS/CTS and requests the firmware version.

await reader.setup()

Scan#

Place the label in the reading area. read_time is a host deadline in seconds, not a change to the scanner’s firmware read window. A no-read returns None; errors propagate. The trigger is switched off on success, timeout, failure and cancellation.

barcode = await reader.scan_barcode(read_time=5)
barcode

Read firmware version#

await reader.request_software_version()

Disconnect#

Stop joins any scan’s trigger cleanup and closes the port.

await reader.stop()

Use the reader attached to an arm#

You can instead construct KX2(barcode_port="/dev/ttyUSB0"); the arm then manages the reader lifecycle and exposes await kx2.scan_barcode(read_time=5). Do not open the same serial port with both objects.