2012-04-03 108 views
9

您如何确定已将哪种媒体连接到系统?如何确定连接的USB设备是否为USB闪存?

我有Ubuntu,当我插入SD卡时,它注意到它实际上是SD卡。 USB记忆棒的数量相同。

但是,如何在低级别上确定何时插入新设备,它是什么类型?

似乎根本没有任何信息可以找到。

编辑:只是要更加完整:我说这是一个Linux环境,但实际上它是嵌入式环境中的Android。我把它标记为Linux,因为我确实试图从命令行检查。

的udevadm命令不可用,并-vv的lsusb显示:

Bus 001 Device 001: ID 1d6b:0002 
Bus 001 Device 002: ID 0424:2640 
Bus 001 Device 003: ID 0424:4040 
Bus 002 Device 001: ID 1d6b:0001 

这是非常少的信息。

+0

你是什么意思“什么类型”到底是什么?什么媒体类型? (即CD,DVD,硬盘驱动器等) – Hasturkun 2012-04-03 12:17:42

+0

这属于Serverfault或超级用户 – KurzedMetal 2012-04-03 12:30:29

+0

是的,类型我完全是指CD,DVD,硬盘驱动器等我需要知道用户是否插入USB棒。 – Boy 2012-04-03 14:01:27

回答

9

lsusb命令列出系统中注册的USB设备。 尝试lsusb -vv了解更多详细信息。您可以使用-s标志来定位特定设备。

更新: 这取决于您的帐户的权限,一些细节需要更高的权限。例如这里的输出我的鼠标:

Bus 003 Device 003: ID 04f3:0230 Elan Microelectronics Corp. 
Device Descriptor: 
    bLength    18 
    bDescriptorType   1 
    bcdUSB    1.10 
    bDeviceClass   0 (Defined at Interface level) 
    bDeviceSubClass   0 
    bDeviceProtocol   0 
    bMaxPacketSize0   8 
    idVendor   0x04f3 Elan Microelectronics Corp. 
    idProduct   0x0230 
    bcdDevice   24.58 
    iManufacturer   0 
    iProduct    2 USB+PS/2 Optical Mouse 
    iSerial     0 
    bNumConfigurations  1 
    Configuration Descriptor: 
    bLength     9 
    bDescriptorType   2 
    wTotalLength   34 
    bNumInterfaces   1 
    bConfigurationValue  1 
    iConfiguration   0 
    bmAttributes   0xa0 
     (Bus Powered) 
     Remote Wakeup 
    MaxPower    100mA 
    Interface Descriptor: 
     bLength     9 
     bDescriptorType   4 
     bInterfaceNumber  0 
     bAlternateSetting  0 
     bNumEndpoints   1 
     bInterfaceClass   3 Human Interface Device 
     bInterfaceSubClass  1 Boot Interface Subclass 
     bInterfaceProtocol  2 Mouse 
     iInterface    0 
     HID Device Descriptor: 
      bLength     9 
      bDescriptorType  33 
      bcdHID    1.11 
      bCountryCode   0 Not supported 
      bNumDescriptors   1 
      bDescriptorType  34 Report 
      wDescriptorLength  52 
     Report Descriptors: 
      ** UNAVAILABLE ** 
     Endpoint Descriptor: 
     bLength     7 
     bDescriptorType   5 
     bEndpointAddress  0x81 EP 1 IN 
     bmAttributes   3 
      Transfer Type   Interrupt 
      Synch Type    None 
      Usage Type    Data 
     wMaxPacketSize  0x0004 1x 4 bytes 
     bInterval    10 
Device Status:  0x0000 
4

这可能是有用的运行这样的命令:

$ udevadm info -a -p $(udevadm info -q path -n /dev/sdX) 

输出可能看起来像如下:

[...] 
    looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5': 
    KERNELS=="1-1.5" 
    SUBSYSTEMS=="usb" 
    DRIVERS=="usb" 
    ATTRS{configuration}=="" 
    ATTRS{bNumInterfaces}==" 1" 
    ATTRS{bConfigurationValue}=="1" 
    ATTRS{bmAttributes}=="80" 
    ATTRS{bMaxPower}=="200mA" 
    ATTRS{urbnum}=="6519" 
    ATTRS{idVendor}=="13fe" 
    ATTRS{idProduct}=="1d00" 
    ATTRS{bcdDevice}=="0100" 
    ATTRS{bDeviceClass}=="00" 
    ATTRS{bDeviceSubClass}=="00" 
    ATTRS{bDeviceProtocol}=="00" 
    ATTRS{bNumConfigurations}=="1" 
    ATTRS{bMaxPacketSize0}=="64" 
    ATTRS{speed}=="480" 
    ATTRS{busnum}=="1" 
    ATTRS{devnum}=="3" 
    ATTRS{devpath}=="1.5" 
    ATTRS{version}==" 2.00" 
    ATTRS{maxchild}=="0" 
    ATTRS{quirks}=="0x0" 
    ATTRS{avoid_reset_quirk}=="0" 
    ATTRS{authorized}=="1" 
    ATTRS{manufacturer}=="Kingston" 
    ATTRS{product}=="DataTraveler 2.0" 
    ATTRS{serial}=="5B7A08A1010F" 
[...] 

你可以看到一些描述设备的ATTRS

+1

但你怎么知道这是一个USB棒而不是SD卡? – Boy 2012-04-03 14:03:11

-2

如何确定是否USB设备是USB棒

SCNR。 USB设备通常不公布其形状。想想:

  • 棒为主CDROM设备在那里 - 通常在移动连接设备推出其自己的Windows驱动程序
  • 棒用于无线键盘/鼠标/的HID /等,或用于音频插孔
  • 的形式
  • 那个阻挡附近所有其他USB端口的胖MP3播放器
+3

他们正在寻找一个闪存驱动器(通常被称为棒),而不是物理外壳。 – 2012-04-03 14:52:36