Recent

Author Topic: Type of USB devices  (Read 3146 times)

badmintonfan

  • New Member
  • *
  • Posts: 47
Type of USB devices
« on: October 14, 2021, 08:51:29 am »
Is there any way to identify a USB device is a storage or a mouse, keyboard etc.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Type of USB devices
« Reply #1 on: October 19, 2021, 12:16:05 pm »
Is there any way to identify a USB device is a storage or a mouse, keyboard etc.
You can differentiate a storage from a keyboard, but not a keyboard from a mouse, as both belong to HID class.
LibUSB has the following list of device class.

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Type of USB devices
« Reply #2 on: October 19, 2021, 12:30:56 pm »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: Type of USB devices
« Reply #3 on: October 19, 2021, 12:36:19 pm »
Is there any way to identify a USB device is a storage or a mouse, keyboard etc.
You can differentiate a storage from a keyboard, but not a keyboard from a mouse, as both belong to HID class.
LibUSB has the following list of device class.

With a score of messages under his belt, OP should know enough by now to specify what OS he's interested in in the text of his message, or if in fact he's asking a general question which he'd like to apply to all OSes.

Speaking specifically for Linux, and specifically excluding other unix-derived OSes including the Mac. It is possible to get a lot of info by looking at the output from lsusb or from a command such as


# udevadm info -q all -n /dev/ttyACM0 --attribute-walk


Credit there to https://back7.co/home/scaling-octoprint-with-a-raspberry-pi which reminded me of it yesterday.

Both of these in practice work by walking the /sys tree, I'm managing to do quite a lot looking at various serial ports e.g. /dev/ttyUSBn and finding the driver name, device description and sometimes (but not always) the name of the driver module supporting the chip.

I'd note that some of the accessible stuff is post-quirk, I can't remember exactly where I've got to in the past but I think that I've found getting the /actual/ HID description emitted by e.g. a trackball to be a problem. I'd also note that getting definite confirmation that one of the generic cdc_xxx drivers is being used can be a problem.

Apologies if this is not what OP is asking, but this would by no means be the first time that somebody has tried to get a generic answer by posting in an OS-specific forum.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Type of USB devices
« Reply #4 on: October 19, 2021, 02:10:26 pm »
With a score of messages under his belt, OP should know enough by now to specify what OS he's interested in in the text of his message, or if in fact he's asking a general question which he'd like to apply to all OSes.
*snip*
MarkMLl

Mark, you do realize we're in the Windows-Subforum?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018