0

Is there a command to enumerate the USB device (HID) programmatically or through some commands?

In Windows we can do the same using Device Manager or devcon. I tried doing rmmod and insmoding the device driver, but it didn't enumerate the device.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Raulp
  • 7,758
  • 20
  • 93
  • 155
  • 1
    I think some details are needed to answer this question. What do you need to do exactly? You need to work with some USB device in your program, or you need to work with it from console? What actions you want to perform with this USB device? What result do you expect? – Sam Protsenko Mar 03 '15 at 16:41
  • 1
    I have a USB hid device connected to a Linux Host which I need to reset or re-enumerate from the host.Either via some command or via some c program via console. – Raulp Mar 04 '15 at 03:25

2 Answers2

0

Generally, USB devices are 'enumerated' internally in the kernel driver. Any time you list them with lsusb, this will show the actual devices present at that time. If you want a detailed listing of each devices, add -v (or --verbose) to the command.

Is that the information you are looking for?

jcoppens
  • 5,306
  • 6
  • 27
  • 47
0

To see all USB devices' data:

#!/usr/bin/env python
import sys
import usb.core

# find USB devices
devices = usb.core.find(find_all=True)
# loop through devices, printing vendor and product ids in decimal and hex
for cfg in devices:
  sys.stdout.write('Decimal VendorID=' + str(cfg.idVendor) + ' & ProductID=' + str(cfg.idProduct) + '\n')
  sys.stdout.write('Hexadecimal VendorID=' + hex(cfg.idVendor) + ' & ProductID=' + hex(cfg.idProduct) + '\n\n')

(Source: enter link description here)

boardrider
  • 5,882
  • 7
  • 49
  • 86
  • Ahh, the pleasure of having one's answer downgraded without as much as a whiff of explanation{.} Hell of a way to motivate... – boardrider Feb 06 '17 at 17:58