Linux如何确定设备类别? [英] How does Linux determine a device class?
问题描述
Linux新手问题.
只是想知道Linux如何确定设备是哪个设备类?具体来说,当我插入条形码扫描仪时,如何知道它是ttyACM设备?我有一台可以在Linux操作系统上运行的扫描仪,但是无法识别新型号,所以我想知道是否可以更改系统中某个文件的文件,该文件告诉扫描仪将其识别为ttyACM0并使用现有的驱动程序.>
USB设备(我假设您的扫描仪是USB)由 vendorId 和 productId (两个16位)标识整数),每个驱动程序用支持的供应商/产品ID列表填充一个数组(创建一个关系供应商:产品->驱动程序),我猜在编译时,数组中的所有ID都合并到一个列表中,然后使用插入设备时进行查找搜索.
通常,插入设备后(或使用 lsusb
),您通常可以通过 dmesg
命令查看所连接设备的供应商和产品ID.
有关 ttyACM
的信息,请参见 Unix&Linux stackexchange
Linux newbie question.
Just wondering how Linux determines which device class a device is? Specifically, when I plug a barcode scanner in how does it know it is an ttyACM device? I have a scanner that works with my Linux OS but the new model isn't recognized so I'm wondering if I can alter a file somewhere in the system that tells it to recognize the scanner as ttyACM0 and use the existing drivers.
USB devices (I assume your scanner is USB) are identified by vendorId and productId (two 16bit integers), each driver fill an array with the list of supported vendor/prods id (creating a relation vendor:prod->driver), I guess at compile time all the id in the array are merged together in a list which then is used for a lookup search when a device is plugged in.
Usually you can see vendor and product id of the attached device with dmesg
command right after the device is plugged in (or with lsusb
).
For ttyACM
see acm_ids[]
in drivers/usb/class/cdc-acm.c
Careful playing around with device drivers, even being ttyACM
a terminal interface only if the interface tty->hardware is implemented poorly some command may break the hardware.
Perhaps this question should be in Unix & Linux stackexchange
这篇关于Linux如何确定设备类别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!