On Sat, Jan 21, 2012 at 9:17 PM, Peter Bigot <pabi...@users.sourceforge.net> wrote: > On Sat, Jan 21, 2012 at 6:50 AM, Xiaofan Chen <xiaof...@gmail.com> wrote: >> On Sat, Jan 21, 2012 at 2:33 AM, Peter Bigot >> <pabi...@users.sourceforge.net> wrote: >>>> Could you please post your full test codes? >>> >>> The only thing above that was "import usb". That code does assume >>> that the backend is libusb01; if the error you're getting is: >>> >>> AttributeError: '_Device' object has no attribute 'bus' >>> >>> perhaps you're using libusb10 even if you think you aren't. Try the >>> following version >> >> Thanks. The code now works for me under Ubuntu 11.04. >> >>> import usb >>> import usb.backend.libusb01 >>> >>> for d in usb.core.find(find_all=True, >>> backend=usb.backend.libusb01.get_backend()): >>> dev = d._ctx.dev >>> print type(dev) >>> print '%s: %u:%u or %s:%u' % (d, d.bus, d.address, >>> dev.bus[0].dirname, dev.devnum) >>> >>> When I do that, it appears the patch is correct even with libusb01 compat. >>> >> >> This is what I get under Ubuntu 11.04 which uses libusb-0.1 legacy, >> without your patch. >> >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fe7cc>: 5:2 or 005:2 >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fe84c>: 5:1 or 005:1 >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fe8ac>: 4:2 or 004:2 >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fe8ec>: 4:1 or 004:1 >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fe92c>: 3:3 or 003:3 >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fe96c>: 3:2 or 003:2 >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fe9ac>: 3:1 or 003:1 >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fe9ec>: 2:2 or 002:2 >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fea2c>: 2:1 or 002:1 >> <class 'usb.backend.libusb01._usb_device'> >> <usb.core.Device object at 0x85fea6c>: 1:1 or 001:1 >> >> Does this mean that your patch is not necessary, at >> least for Ubuntu 11.04 version of libusb-0.1? > > Yes. It also means the patch will work on both Ubuntu 11.04 and SUSE > 10.3, so there's no reason not to apply it. Thanks for confirming > this.
I see. So under Suse 10.3, you see different results of d.bus and dev.bus[0].dirname without your patch, right? In my case, the values are the same. So it will still match with your patch. On the other hand, the code does not print out anything under my Mac Mini which runs Mac OS X Lion, but that is probably a separate issue. -- Xiaofan ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users