我發展我的板USB應用。它有兩個USB端口。當我插上USB驅動器在他們每個人我得到控制檯以下消息:嵌入式Linux 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等)
我有谷歌這一點,發現獨立地給這個信息2條系統路徑: 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上的設備?
謝謝! :)這工作! – androidFan