2011/9/17 Peter Bigot <pabi...@users.sourceforge.net>:
> Thanks for providing pyusb: its support for libusb-1.0 is making my life
> much easier by letting me work around the cdc_acm limitations in Linux.
>
> For your consideration: In my application, the Linux kernel driver for
> cdc_acm will be loaded automatically when a device is inserted.  I don't
> want to break that, because other devices need and work with that
> interface.  So my script needs to detach the kernel driver.  However, if
> that's already been done, the underlying libusb call returns
> LIBUSB_ERROR_NOT_FOUND.  I want to ignore that error, but not others that
> might arise in the same call.
>
> Under the current handling of usb.core.USBError, the numeric error code is
> translated to a backend-specific error string.  This makes it inconvenient
> to programmatically identify the problem.
>
> In my case, I know I'm using libusb10, so I'd like to be able to write:
>
>  try:
>    rf2500.detach_kernel_driver(0)
>  except usb.USBError, e:
>    if e.backend_errno != e.ERROR_NOT_FOUND:
>      raise
>
> The attached patch allows this.  I've only provided it for the libusb10
> backend; cursory inspection suggests it's equally trivial for the others.
>
> Some interface choices you might want to revisit if you like this enough to
> adopt it:
>
> * I'm not using IOError's existing errno field because the values are not
>  errno values, so there's a new backend_errno field.
>
> * I've chosen to name the backend-specific class USBError because it's
>  disambiguated by the module it belongs to.
>
> * Similarly I left the LIBUSB_ prefix off the error codes since they're
>  contextualized by the class.
>
> * I placed the error codes as class constants rather than module constants
>  so they're easily to hand for comparisons.  If other back ends happen to
>  use the same name, the user code doesn't need to check which back end was
>  used.
>
> Peter
>

Hi Peter,

Thanks for your patch. As I will have to propagate this patch to the
other backends, and I don't know when I really can do that, could you
please open a ticket in Trac?

-- 
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to