Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Linux determine a device class?

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.

like image 276
Luke Allison Avatar asked Mar 05 '26 02:03

Luke Allison


1 Answers

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

like image 171
Alex Avatar answered Mar 06 '26 15:03

Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!