我一直在尝试为设备编写 USB 驱动程序,但我尝试过的方法(libhid、libusb-0.1、libusb-1.0)都不起作用。我以前写过USB驱动。我还可以通过以太网与设备进行良好的通信。但无论我如何通过 USB 尝试,我总是收到“资源暂时不可用”的消息。
所以我认为当设备通过 USB 连接时它会控制设备。
$ lsusb
Bus 003 Device 010: ID 2457:2003
(yes the rest of line is blank)
$ usb-devices
T: Bus=03 Lev=01 Prnt=01 Port=05 Cnt=04 Dev#= 10 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=2457 ProdID=2003 Rev=01.17
S: Manufacturer=Ocean Optics
S: Product=OceanHDX
S: SerialNumber=HDX00415
C: #Ifs= 0 Cfg#= 0 Atr= MxPwr=
I: If#=0x Alt= 0 #EPs= 0 Cls=() Sub= Prot= Driver=
(note: it doesn't say Driver=(none) like some other devices)
$ cat /etc/udev/rules.d/10-oceanoptics.rules
ATTRS{idVendor}=="2457", ATTRS{idProduct}=="2003", SYMLINK+="oceanhdx-%n", MODE:="0666"
$ hd /dev/oceanhdx-6
000000 12 01 00 02 00 00 00 40 57 24 03 20 17 01 01 02 >.......@W$. ....<
000010 03 01 09 02 20 00 01 01 04 80 fa 09 04 00 00 02 >.... ...........<
000020 ff 00 00 05 07 05 01 02 00 02 00 07 05 81 02 00 >................<
000030 02 00 >..<
所以我的问题是:如果可以的话cat /dev/ocean-hdx-6
,显然会有司机接听。那是谁,那是什么代码?不同于?Driver=
什么也不产生。Driver=(none)
lsof /dev/ocean-hdx-6
$ sudo udevadm monitor --udev --property
UDEV [2454.018408] add /devices/pci0000:00/0000:00:14.0/usb3/3-6 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-6
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/003/010
DEVTYPE=usb_device
PRODUCT=2457/2003/117
TYPE=0/0/0
BUSNUM=003
DEVNUM=010
SEQNUM=9149
USEC_INITIALIZED=2454010185
ID_VENDOR=Ocean_Optics
ID_VENDOR_ENC=Ocean\x20Optics
ID_VENDOR_ID=2457
ID_MODEL=OceanHDX
ID_MODEL_ENC=OceanHDX
ID_MODEL_ID=2003
ID_REVISION=0117
ID_SERIAL=Ocean_Optics_OceanHDX_HDX00415
ID_SERIAL_SHORT=HDX00415
ID_BUS=usb
ID_USB_INTERFACES=:ff0000:
DRIVER=usb
MAJOR=189
MINOR=265
DEVLINKS=/dev/oceanhdx-6
UDEV [2454.020344] add /devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0
SUBSYSTEM=usb
DEVTYPE=usb_interface
PRODUCT=2457/2003/117
TYPE=0/0/0
INTERFACE=255/0/0
MODALIAS=usb:v2457p2003d0117dc00dsc00dp00icFFisc00ip00in00
SEQNUM=9150
USEC_INITIALIZED=2454020187
UDEV [2454.024168] bind /devices/pci0000:00/0000:00:14.0/usb3/3-6 (usb)
ACTION=bind
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-6
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/003/010
DEVTYPE=usb_device
DRIVER=usb
PRODUCT=2457/2003/117
TYPE=0/0/0
BUSNUM=003
DEVNUM=010
SEQNUM=9151
USEC_INITIALIZED=2454010185
ID_VENDOR=Ocean_Optics
ID_VENDOR_ENC=Ocean\x20Optics
ID_VENDOR_ID=2457
ID_MODEL=OceanHDX
ID_MODEL_ENC=OceanHDX
ID_MODEL_ID=2003
ID_REVISION=0117
ID_SERIAL=Ocean_Optics_OceanHDX_HDX00415
ID_SERIAL_SHORT=HDX00415
ID_BUS=usb
ID_USB_INTERFACES=:ff0000:
MAJOR=189
MINOR=265
DEVLINKS=/dev/oceanhdx-6