2010/8/7 Poul-Henning Kamp <[email protected]>:
>
> Relative to:
> URL: http://pyusb.svn.sourceforge.net/svnroot/pyusb/trunk
> Repository Root: http://pyusb.svn.sourceforge.net/svnroot/pyusb
> Repository UUID: 3043e840-054b-0410-bc1a-858b58f158f7
> Revision: 70
>
> I am hacking around with a USBTMC device and came up with this code:
>
> import usb.core
> import usb.util
>
> def is_usbtmc(dev):
> if dev.bDeviceClass != 0:
> return False
> if dev.bDeviceSubClass != 0:
> return False
> if dev.bDeviceProtocol != 0:
> return False
> for cfg in dev:
> # XXX: help(usb.core.find) lacks "usb." pfx
> x = usb.util.find_descriptor(cfg, bInterfaceClass=0xfe)
> if x != None:
> return True
> return False
>
> for i in usb.core.find(custom_match=is_usbtmc):
You are supposed to iterator over a return value of find only when you pass
the find_all=True argument. Didn't it cause en error?
> # XXX: Returns configuration
> if isinstance(i, usb.core.Configuration):
> print("GOT CONFIG")
> print(" ")
> print(i)
>
> But I find that usb.core.find returns a Configuration instead of
> a Device in this case.
>
> The first XXX comment is fixed in this little patch, along with
> a typo in a URL.
Patches applied. Thank you.
>
> Poul-Henning
>
> Index: usb/core.py
> ===================================================================
> --- usb/core.py (revision 70)
> +++ usb/core.py (working copy)
> @@ -766,7 +766,7 @@
> if dev.bDeviceClass == 7:
> return True
> for cfg in dev:
> - if util.find_descriptor(cfg, bInterfaceClass=7) is not None:
> + if usb.util.find_descriptor(cfg, bInterfaceClass=7) is not None:
> return True
>
> printers = find(find_all=True, custom_match = is_printer)
> Index: README
> ===================================================================
> --- README (revision 70)
> +++ README (working copy)
> @@ -15,7 +15,7 @@
> As with most Python modules, PyUSB's documentation is based on Python
> doc strings and can therefore be manipulated by tools such as pydoc.
>
> -You can also find a tutorial at:
> http://pyusb.sourceforge.net/docs/1.0/tutotial.html.
> +You can also find a tutorial at:
> http://pyusb.sourceforge.net/docs/1.0/tutorial.html.
>
> PyUSB is being developed and tested in Linux and Windows, but it should work
> fine in any platform running Python >= 2.3, ctypes and at least one of the
>
>
> --
> Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
> [email protected] | TCP/IP since RFC 956
> FreeBSD committer | BSD since 4.3-tahoe
> Never attribute to malice what can adequately be explained by incompetence.
>
--
Best Regards,
Wander Lairson Costa
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
pyusb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyusb-users