PyUSB: Why are bus.dirname and dev.filename empty string?

允我心安 提交于 2021-02-10 23:19:42

问题


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.


回答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


来源:https://stackoverflow.com/questions/38570959/pyusb-why-are-bus-dirname-and-dev-filename-empty-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!