⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 using.sgml

📁 usb develop guide
💻 SGML
📖 第 1 页 / 共 2 页
字号:
<chapter>  <Title>Using Linux USB</><Sect1><Title>Reading the Linux USB Device Filesystem output</><Para>The USB device filesystem is a dynamically generated filesystem thatcomplements the normal device node system, and can be used to writeuser space device drivers. Writing of user space device drivers iscovered in the programmer's section of this guide. In addition to thedevice nodes, there are two files that are also generated - the<FileName>drivers</FileName> and <FileName>devices</FileName> files.If you followed the instructions in the installation chapter, youshould find them as <FileName>/proc/bus/usb/drivers</FileName> and<FileName>/proc/bus/usb/device</FileName> respectively. If the<FileName>/proc/bus/usb</FileName> directory is empty, you have notmounted the filesystem, or you have mounted it in the wrong location.</><Para><FileName>/proc/bus/usb/drivers</FileName> just lists the currentlyregistered drivers (even if the driver is not being used by any device). This is most useful when testing module installation, and checking forUSB support in an unknown kernel. Here is an example of its use:<screen>[bradh@rachel bradh]$ more /proc/bus/usb/drivershidov511cpiaprinterhub</screen></><Para><FileName>/proc/bus/usb/devices</FileName> lists information aboutthe devices currently attached to the USB bus. This is very useful whentrying to figure out if the device is correctly enumerated. Here is anexample of its use, showing the root hub, a hub, a mouse and acamera:<screen>T:  Bus=00 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2B:  Alloc= 28/900 us ( 3%), #Int=  2, #Iso=  0D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1P:  Vendor=0000 ProdID=0000 Rev= 0.00C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mAI:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hubE:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=255msT:  Bus=00 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=12  MxCh= 4D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1P:  Vendor=0451 ProdID=1446 Rev= 1.00C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mAI:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hubE:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=255msT:  Bus=00 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=  3 Spd=12  MxCh= 0D:  Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1P:  Vendor=0553 ProdID=0002 Rev= 1.00C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=400mAI:  If#= 1 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=ff Driver=cpiaE:  Ad=81(I) Atr=01(Isoc) MxPS=   0 Ivl=  1msI:  If#= 1 Alt= 1 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=ff Driver=cpiaE:  Ad=81(I) Atr=01(Isoc) MxPS= 448 Ivl=  1msI:  If#= 1 Alt= 2 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=ff Driver=cpiaE:  Ad=81(I) Atr=01(Isoc) MxPS= 704 Ivl=  1msI:  If#= 1 Alt= 3 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=ff Driver=cpiaE:  Ad=81(I) Atr=01(Isoc) MxPS= 960 Ivl=  1msT:  Bus=00 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#=  5 Spd=1.5 MxCh= 0D:  Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1P:  Vendor=046d ProdID=c001 Rev= 1.10S:  Manufacturer=LogitechS:  Product=USB-PS/2 MouseC:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr= 50mAI:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=01 Prot=02 Driver=hidE:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl= 10ms</screen></><para>The information in the <FileName>/proc/bus/usb/devices</FileName> outputis arranged in groups:<ItemizedList><ListItem><para>The line that starts with <UserInput>T:</UserInput> is the topology.<UserInput>Bus</UserInput> indicates which bus the device is on.<UserInput>Lev</UserInput> indicates the level of the device, startingat level 00 for the root hub, level 01 for any device attached to theroot hub, level 02 for devices attached to hubs at level 01, and soon. <UserInput>Prnt</UserInput> is the parent device for this device(always 00 for the root hub, and 01 for the devices attached to the roothub). <UserInput>Port</UserInput> is the port on the parent device,starting at 00 for the first port on eachdevice. <UserInput>Prnt/Port</UserInput> is unique perbus. <UserInput> Cnt</UserInput> indicates what number device this is,at this level, based on the enumeration order within that level of thetopology, starting at 01 for the firstdevice. <UserInput>Dev#</UserInput> indicates what number device thisis, irrespective of level, based on the bus enumeration order. This isunique per bus.<UserInput>Spd</UserInput> indicates what speed this device is runningat, in Mbps (either 1.5 or 12 with the current version of USB). <UserInput>MxCh</UserInput> indicates how manydevices can be connected to this device, and is 00 for anything excepta hub.  <UserInput>Driver</UserInput> indicates which device driver isbeing used for this device - an entry of <UserInput>(none)</UserInput>indicates that no driver is being used.</></ListItem><ListItem><para>The line that starts with <UserInput>D:</UserInput> is information  from the device descriptor. <UserInput>Ver</UserInput> indicates  which USB specification version the device claims to  meet. <UserInput>Cls</UserInput> indicates which device class the  device is claiming to meet, in both hexadecimal and as a string. A  <UserInput>Cls</UserInput> entry of <UserInput>00(>ifc)</UserInput>  indicates that the device class specification compliance is  interface dependent, and the interface descriptor should be read for  device class information. <UserInput>Sub</UserInput> indicates which  sub-class (within the <UserInput>Cls</UserInput> entry), the device  meets. <UserInput>Prot</UserInput> indicates which protocol withina class or sub-class the device claims to meet.<UserInput>MxPS</UserInput> indicates how big the packets  from Endpoint 0 are. <UserInput>#Cfgs</UserInput> indicates how many  configurations this device has.</></ListItem><ListItem><para>Much like <UserInput>D:</UserInput>, the line that starts with<UserInput>P:</UserInput> is information from the device descriptor,and is seperated mainly because it wouldn't all fit on oneline. <UserInput>Vendor</UserInput> indicates the VendorIdentification code for the device, and <UserInput>ProdID</UserInput>indicates the Product Identification code for thedevice. <UserInput>Rev</UserInput> indicates the product revisionnumber.</></ListItem><ListItem><para>Refer to the USB specification clause 9.7.1 for further information ondevice descriptors.</></ListItem><ListItem><para>The lines that start with <UserInput>S:</UserInput>, if any, are thevendor and product strings that the device returned.</></ListItem<ListItem><para>The line that starts with <UserInput>C:</UserInput> is information  from the configuration descriptor - the number of  <UserInput>C:</UserInput>lines per device is given by  <UserInput>#Cfgs</UserInput>, and the entry followed by an asterisk  is the current configuration. <UserInput>#If</UserInput> indicates  how many interfaces the device has. <UserInput>Cfg#</UserInput>  indicates which configuration is being  described. <UserInput>Atr</UserInput> is a hexadecimal indication of  the device attributes (0x80 for bus-powered, 0x40 for self-powered,  0x20 for remote wake-up capable). <UserInput>MxPwr</UserInput> is the  maximum power draw for this device configuration, in  milliamps. Refer to USB specification clause 9.7.2 for further  information on configuration descriptors.</></ListItem><ListItem><para>The line that starts with <UserInput>I:</UserInput>is information from the interface descriptor - the number of<UserInput>I:</UserInput> lines per <UserInput>C:</UserInput> line isgiven by the <UserInput>#Ifs</UserInput>entry. <UserInput>If#</UserInput> indicates which interface is beingdescribed within a given deviceconfiguration. <UserInput>Alt</UserInput> indicates which alternatesetting of this interface is beingdescribed. <UserInput>#EPs</UserInput> indicates how many endpointsthere are within the alternate setting for thisendpoint. <UserInput>Cls</UserInput> indicates which class thealternate setting of the interface corresponds to, in both hexadecimaland as a character string. <UserInput>Sub</UserInput> indicates whichsub-class the alternate setting of the interface belongsto. <UserInput>Prot</UserInput> indicates which interface protocol(within a class and sub-class tuple) the alternate setting of theinterface conforms to. <UserInput>Driver</UserInput> indicates whichof the various USB drivers has claimed this interface.See USB specification clause 9.7.3 for further information.</></ListItem><ListItem><para>The line that starts with <UserInput>E:</UserInput> is informationfrom the endpoint descriptor - the number of<UserInput>E:</UserInput> lines per <UserInput>I:</UserInput> line isgiven by the <UserInput>#EPs</UserInput> entry. Endpoint 0 is notdisplayed. <UserInput>Ad</UserInput> indicates the endpoint address,with a letter to indicate whether the endpoint is an In or Outendpoint. <UserInput>Atr</UserInput> indicate the attribute (transfertype) associated with the endpoint, followed by a string translatingthe transfer type. <UserInput>MxPS</UserInput> indicates the maximumpacket size this endpoint is capable of sending or receiving, asappropriate.  <UserInput>Ivl</UserInput> indicates the interval, inmilliseconds, between polling of interruptendpoints. <UserInput>Ivl</UserInput> is ignored for bulk and controltransfers, and is set to 1 for isochronous transfers. See USB specificationclause 9.7.4 for further information on endpoint descriptors.</></ListItem></ItemizedList></><para>Refer to <FileName>linux/Documentation/usb/proc_usb_info.txt</FileName> formore information on using the USB device filesystem information.</></Sect1><Sect1><title>Configuring extra keys on USB keyboards</title><para>To understand how to configure the additional keys that are provided onsome USB keyboards, it helps to understand they way in which key processingworks under Linux and X.</para><para>The most fundamental level of keyboard processing is a scancode. The USBkeyboard driver pipes scancodes into the normal kernel keyboard driver.Depending on the mode in which the keyboard is operated, these caneither be sent to the application directly (known as scancode or raw mode)or translated using a keyboard mapping table (known as the keymap)before being sent to the application (known as keycode or intepreted mode).</para><para>X uses the raw scancodes, which are known as keycodes in X documentation.These are translated inside the X server to a functional equivalent, knownas a key symbol or keysym using a mapping table, although this is not thesame format and performs a subtly different function. This means thattranslations in console mode and under X are not the same.</para>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -