我有一台 Opticon OPN-3002i,我想在 Linux 上运行,目前我的计算机运行 Kali Linux。不幸的是,ttyUSB0
尽管我将其设置为 USB-VCP 模式,但该设备并未显示为。这是我拔下和插入设备时的 dmesg。
[754566.684401] usb 2-1: USB disconnect, device number 17
[754570.040249] usb 2-1: new full-speed USB device number 18 using uhci_hcd
[754570.213170] usb 2-1: New USB device found, idVendor=065a, idProduct=a002
[754570.213185] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[754570.213196] usb 2-1: Product: USB Code Reader
[754570.213205] usb 2-1: Manufacturer: Optoelectronics Co., Ltd.
[754608.100374] usb 2-1: USB disconnect, device number 18
[754611.968205] usb 2-1: new full-speed USB device number 19 using uhci_hcd
[754612.142243] usb 2-1: New USB device found, idVendor=065a, idProduct=a002
[754612.142260] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[754612.142271] usb 2-1: Product: USB Code Reader
[754612.142280] usb 2-1: Manufacturer: Optoelectronics Co., Ltd.
[754853.620426] usb 2-1: USB disconnect, device number 19
[754858.460183] usb 2-1: new full-speed USB device number 20 using uhci_hcd
[754858.634224] usb 2-1: New USB device found, idVendor=065a, idProduct=a002
[754858.634240] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[754858.634250] usb 2-1: Product: USB Code Reader
[754858.634259] usb 2-1: Manufacturer: Optoelectronics Co., Ltd.
lsusb条目
Bus 002 Device 020: ID 065a:a002 Optoelectronics Co., Ltd
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x065a Optoelectronics Co., Ltd
idProduct 0xa002
bcdDevice 1.00
iManufacturer 1 Optoelectronics Co., Ltd.
iProduct 2 USB Code Reader
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 25
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4 USB VCP Code Reader
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 5
Device Status: 0x0000
(Bus Powered)
我对此的研究引导我找到了这两页
第一个链接(安装 USB-VCP)的问题是我的计算机没有文件夹/proc/bus/usb
,并且我无法使用mount -t usbfs procbususb /proc/bus/usb
.据我了解,usbfs 已经被淘汰了。我确实需要这个设备处于 ttyUSB 模式,这样我就可以通过串行发送命令。设备本身根据 被设置为 USB-VCP 模式lsusb
。
编辑:
从终端运行usb-devices
程序并为我的设备获取该程序。
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 23 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=065a ProdID=a002 Rev=01.00
S: Manufacturer=Optoelectronics Co., Ltd.
S: Product=USB Code Reader
C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
答案1
您需要强制 opticon 设备使用 opticon 驱动程序。看这个答案:https://stackoverflow.com/questions/442833/forcing-driver-to-device-match#442867
就像将供应商 ID 和产品 ID 回显到 new_id 文件中一样简单。
echo 0x065a 0xa002 > /sys/bus/usb-serial/drivers/opticon/new_id
拔下并重新插入以确保驱动程序正常工作。