2013/4/24 Alan Jhonn Aguiar Schwyn <alan...@hotmail.com>:
> Hi,
>
> I'm trying to improve the times in a code. In the 99% of the times, when you
> does the "discover" process (to check if your device is connected) you make:
>
> list = []
> for bus in usb.busses():
>     for dev in bus.devices:
>         if dev.idVendor == SOME_VENDOR and dev.idProduct == SOME_PRODUCT:
>             list.append(dev)
> return list
>
> But this function takes a lot of time! The "bus.devices" is:
>
> self.devices = [Device(d) for d in core.find(find_all=True)]
>
> I change my function to more elegant:
>
> list = usb.core.find(find_all=True, idVendor=SOME_VENDOR,
> idProduct=SOME_PRODUCT):
>
> This is more efficient, but I have one problem: why this function returns
> "devices" without the
> "interface"??
>
> If I try to get the same that in the first function, have to do:
>
> list = usb.core.find(find_all=True, idVendor=SOME_VENDOR,
> idProduct=SOME_PRODUCT):
> d = []
> for dev in list:
>     d.append(Device(dev))
> return d
>
> Why no have a function that makes it?
>

You are messing up with rather different version of PyUSB.
usb.core.find return objects of the type usb.core.Device. You can get
the interface through usb.core.Interface class. Please, take a look at
the tutorial.

-- 
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to