我正在为我的主板开发USB应用程序 . 它有两个USB端口 . 当我在每个插件中插入一个USB驱动器时,我在控制台上收到以下消息:
在端口1:
usb 1-1: new high speed USB device using atmel-ehci and address 4
usb 1-1: New USB device found, idVendor=0781, idProduct=5567
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: Cruzer Blade
usb 1-1: Manufacturer: SanDisk
usb 1-1: SerialNumber: 3515430A2EE2729D
scsi2 : usb-storage 1-1:1.0
scsi 2:0:0:0: Direct-Access SanDisk Cruzer Blade 8.02 PQ: 0 ANSI: 0 CCS
sd 2:0:0:0: [sdb] 7856127 512-byte logical blocks: (4.02 GB/3.74 GiB)
sd 2:0:0:0: [sdb] Write Protect is off
sd 2:0:0:0: [sdb] Assuming drive cache: write through
sd 2:0:0:0: [sdb] Assuming drive cache: write through
sdb:
sdb1
sd 2:0:0:0: [sdb] Assuming drive cache: write through
sd 2:0:0:0: [sdb] Attached SCSI removable disk
在端口2:
usb 1-2: USB disconnect, address 3
usb 1-2: new high speed USB device using atmel-ehci and address 5
usb 1-2: New USB device found, idVendor=0781, idProduct=5567
usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-2: Product: Cruzer Blade
usb 1-2: Manufacturer: SanDisk
usb 1-2: SerialNumber: 3515430A2EE2729D
scsi3 : usb-storage 1-2:1.0
scsi 3:0:0:0: Direct-Access SanDisk Cruzer Blade 8.02 PQ: 0 ANSI: 0 CCS
sd 3:0:0:0: [sda] 7856127 512-byte logical blocks: (4.02 GB/3.74 GiB)
sd 3:0:0:0: [sda] Write Protect is off
sd 3:0:0:0: [sda] Assuming drive cache: write through
sd 3:0:0:0: [sda] Assuming drive cache: write through
sda:
sda1
sd 3:0:0:0: [sda] Assuming drive cache: write through
sd 3:0:0:0: [sda] Attached SCSI removable disk
但这些消息在控制台上 .
我想检测哪个设备已连接到哪个端口与地址(如sda,sdb等)
我有点谷歌,发现两个独立的信息系统路径:1) /sys/bus/usb/devices/1-x
2) /sys/class/scsi_disk/x:0:0:0/device
第一个给出了这个信息:
1-2:1.0 bus maxchild
authorized busnum product
bConfigurationValue configuration quirks
bDeviceClass descriptors remove
bDeviceProtocol dev serial
bDeviceSubClass devnum speed
bMaxPacketSize0 devpath subsystem
bMaxPower driver uevent
bNumConfigurations ep_00 urbnum
bNumInterfaces idProduct usb_device:usbdev1.4
bcdDevice idVendor version
bmAttributes manufacturer
第二个给出了这个信息:
block:sdb iorequest_cnt scsi_disk:2:0:0:0
bus max_sectors scsi_level
delete modalias state
device_blocked model subsystem
driver queue_depth timeout
evt_media_change queue_type type
iocounterbits rescan uevent
iodone_cnt rev vendor
ioerr_cnt scsi_device:2:0:0:0
因此,这两个数据结构之间没有共同的信息 . 我可以得到没有的端口 . 和序列号 . 从第一条路径开始的USB设备 . 我可以从第二条路径获取地址(sda,sdb等) . 但他们之间没有共同的信息 . 我怎么知道端口1上的特定USB设备安装在sda上?或者如果安装在sdc上,端口2上的设备??