将二维码读取器连接到 Linux

将二维码读取器连接到 Linux

我正在尝试通过 USB 将二维码读取器连接到在虚拟机中运行的 Linux(Debian 5)。以下是各种命令的定制输出:

消息

$ dmesg 
[ 1141.368166] usb 1-2.1: new full speed USB device using uhci_hcd and address 5
[ 1141.650721] usb 1-2.1: configuration #1 chosen from 1 choice
[ 1141.656035] usb 1-2.1: New USB device found, idVendor=0db5, idProduct=0129
[ 1141.656041] usb 1-2.1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 1141.656046] usb 1-2.1: Product: ACCESS IS LSR110

hal 设备

$ hal-device
3: udi = '/org/freedesktop/Hal/devices/usb_device_db5_129_noserial'
  usb_device.configuration_value = 1  (0x1)  (int)
  usb_device.max_power = 250  (0xfa)  (int)
  usb_device.num_configurations = 1  (0x1)  (int)
  usb_device.num_ports = 0  (0x0)  (int)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb1/1-2/1-2.1'  (string)
  info.subsystem = 'usb_device'  (string)
  usb_device.num_interfaces = 2  (0x2)  (int)
  usb_device.linux.device_number = 5  (0x5)  (int)
  info.parent = '/org/freedesktop/Hal/devices/usb_device_e0f_2_noserial'  (string)
  usb_device.device_class = 2  (0x2)  (int)
  info.vendor = 'Unknown (0x0db5)'  (string)
  info.product = 'ACCESS IS LSR110'  (string)
  usb_device.device_subclass = 0  (0x0)  (int)
  usb_device.speed = 12  (double)
  info.udi = '/org/freedesktop/Hal/devices/usb_device_db5_129_noserial'  (string)
  info.linux.driver = 'usb'  (string)
  usb_device.device_protocol = 0  (0x0)  (int)
  usb_device.version = 2  (double)
  usb_device.vendor_id = 3509  (0xdb5)  (int)
  usb_device.is_self_powered = false  (bool)
  usb_device.product_id = 297  (0x129)  (int)
  usb_device.can_wake_up = false  (bool)
  linux.hotplug_type = 2  (0x2)  (int)
  usb_device.bus_number = 1  (0x1)  (int)
  linux.subsystem = 'usb'  (string)
  usb_device.product = 'ACCESS IS LSR110'  (string)
  linux.device_file = '/dev/bus/usb/001/005'  (string)
  usb_device.linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb1/1-2/1-2.1'  (string)
  usb_device.device_revision_bcd = 4098  (0x1002)  (int)

lsusb-t

$ lsusb -t
Bus#  2
`-Dev#   1 Vendor 0x1d6b Product 0x0002
Bus#  1
`-Dev#   1 Vendor 0x1d6b Product 0x0001
  |-Dev#   2 Vendor 0x0e0f Product 0x0003
  `-Dev#   3 Vendor 0x0e0f Product 0x0002
    `-Dev#   5 Vendor 0x0db5 Product 0x0129

我对比了ls -1 /dev插入设备前后的情况。插入后会创建以下额外条目:

usbdev1.5_ep00 usbdev1.5_ep01 usbdev1.5_ep82 usbdev1.5_ep83

的内容/etc/udev/rules.d/000_mydev.rules已更新:

KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="0db5", ATTRS{idProduct}=="0129"  NAME="barcode"

但是,为了能够从设备读取数据,我错过了 的条目/dev。我在一台运行 Ubuntu 14.04.1 LTS(64 位,真实机器)的计算机上安装了相同的设备,并且/dev/ttyACM0创建了一个作为设备的接入点,我可以轻松cat /dev/ttyACM0获取数据。在 VM Debian 中没有创建类似的东西。

问题:如何从设备读取数据?

答案1

有两个问题。

  1. 内核太旧。已升级至 2.6.32

  2. tty 端口配置错误...应用正确设置后(stty -F /dev/ttyACM3 115200 raw -echo -echoe -echok -echoctl -echoke -clocal -iexten)一切正常

相关内容