#barcode #scanner #usb #scan

barcode-scanner

Linux interface to barcode USB hand scanners

1 unstable release

0.1.0 Feb 24, 2023

#1440 in Hardware support

Download history 5/week @ 2024-01-22 3/week @ 2024-01-29 33/week @ 2024-02-12 19/week @ 2024-02-19 46/week @ 2024-02-26 9/week @ 2024-03-04 34/week @ 2024-03-11 6/week @ 2024-03-18 10/week @ 2024-03-25 29/week @ 2024-04-01 3/week @ 2024-04-08 8/week @ 2024-04-15 23/week @ 2024-04-22

64 downloads per month

BSD-2-Clause OR Apache-2.0

10KB
125 lines

barcode-scanner

Scan 1D barcodes using a hand scanner for Rust.

The barcode-scanner crate provides a Linux interface to barcode USB hand scanners. It works with the Device struct from the evdev crate.

Currently supported features:

  • One BarcodeScanner struct for all USB hand scanners that operate as a keyboard.
  • Prevent other clients from receiving events from the selected device by grabbing it.
  • Read 1D barcode consisting of numbers and letters.
  • Omit special characters in a barcode.

Example

This example grabs a hand scanner and prints a barcode that is read.

	use barcode_scanner::BarcodeScanner;

	let scanner = BarcodeScanner::new("usb-0000:00:14.0-3/input0")?;
	loop {
    	let barcode = scanner.read()?;
    	println!("{}", barcode);
	}

License: BSD-2-Clause OR Apache-2.0


lib.rs:

Scan 1D barcodes using a hand scanner for Rust.

The barcode-scanner crate provides an interface to USB barcode scanners on Linux. It is built on top of the evdev crate. It works with any barcode scanner that acts as a keyboard.

Currently supported features:

  • One BarcodeScanner struct for all USB hand scanners that operate as a keyboard.
  • Prevent other clients from receiving events from the selected device by grabbing it.
  • Read 1D barcode consisting of numbers and letters.
  • Omit special characters in a barcode.

Example

This example grabs a hand scanner and prints a barcode that is read.

   use barcode_scanner::BarcodeScanner;

   let mut scanner = BarcodeScanner::open("/dev/input/by-id/usb-USB_Adapter_USB_Device-event-kbd")?;
   loop {
       let barcode = scanner.read()?;
       println!("{}", barcode);
   }

Dependencies

~2.9–4.5MB
~98K SLoC