1

I am very new to using PyUSB. I have some USB devices connected to my machine and am trying to get some of their properties. Based on what I have learnt from other examples using PyUSB, I have produced a short program in Linux. Here is a snip of the program:

busses = usb.busses()
   for bus in busses:
       devices = bus.devices
       for dev in devices:
          print dev.filename
          print bus.dirname
          print dev.idProduct

When I checked the output, both dev.filename and bus.dirname are empty string for all the devices. The dev.idProduct is correct.

Can someone help with these questions please? (1) What is dev.filename? (2) What is bus.dirname? (3) Can both of these properties empty?

Thanks.

YvonneH
  • 75
  • 6
  • 1
    I guess you should ask this question on `PyUSB` github page. Quickly going over its code shows that `device.filename` is initiated to an empty string and is never assigned to anything else. Same is true for `bus.dirname` (https://github.com/walac/pyusb/blob/9094c9b1ec2ac761dddce3c7d050fc4cd02e063d/usb/legacy.py#L321). – DeepSpace Jul 25 '16 at 14:55
  • Try access to `/dev` ? are you `root` ? – dsgdfg Jul 25 '16 at 20:12

1 Answers1

1

The device number is in devnum:

busses = usb.busses()
   for bus in busses:
       devices = bus.devices
       for dev in devices:
          print dev.devnum #filename is empty!!
          print bus.dirname
          print dev.idProduct
  • It is a bit short on explanation... Could you elaborate? – Benoît Latinier Mar 20 '18 at 20:38
  • So if you look into the code for pyusb in legacy.py the device class has all the fields populated. filename is left blank but devnum is populated with the device address: self.devnum = dev.address – Deepak Mital Mar 22 '18 at 01:01