Re: OpenUSB / LibUSB on Mac OS X
Michael Lewis <milewis1 <at> gmail.com>
2012-02-01 00:19:53 GMT
On Jan 31, 2012 7:14 PM, "Nathan Hjelm" <hjelmn <at> me.com> wrote:
>
> I meant detach from the device not attach. But yes, if Seize doesn't work then the driver won't let go and you have to write a (now less) codeless kext to claim the device/interfaces.
I was afraid of that, thanks for the help.
>
> On Jan 31, 2012, at 3:43 PM, Michael Lewis wrote:
>
> > On Tue, Jan 31, 2012 at 4:29 PM, Nathan Hjelm <hjelmn <at> me.com> wrote:
> >> USBDeviceOpenSeize is needed to cause the kernel driver to attach from the device (if the driver supports the feature) so I wouldn't change it. You might be able to close after the Seize and reopen immediately with USBDeviceOpen but the kernel driver might reattach.
> >>
> >> BTW, why would two processes want to open the same device? Only one process at a time can send control messages to a device at one time on MacOS X.
> >
> > Thanks, I won't change it then. However, in my case I have a scanner
> > with a TWAIN driver on OS X 10.7 (the previous versions don't do this)
> > the os loads the TWAIN driver when the device connects and keeps it
> > open. Then when my regular application tries to connect, it can't
> > because the device is already exclusively opened. I know, it doesn't
> > make sense to me either. I believe I can prevent it by not allowing
> > the os to recognize the device (aka removing the device info from the
> > TWAIN driver). That seems sleazy, but given what you've just said it
> > might be my only option.
> >
> > Thanks for your input.
> >
> >
> >>
> >> -Nathan
> >>
> >> On Jan 31, 2012, at 5:42 AM, Michael Lewis wrote:
> >>
> >>> I ran across a bug with OpenUSB on Mac OS X 10.7 recently. Basically,
> >>> I had two processes trying to keep the device open. I looked through
> >>> the code and found this:
> >>>
> >>> /* Try to actually open the device */
> >>> #if !defined (OPENUSB_NO_SEIZE_DEVICE)
> >>> kresult = (*(hdev->priv->device))->USBDeviceOpenSeize (hdev->priv->device);
> >>> #else
> >>> /* No Seize in OS X 10.0 (Darwin 1.4) */
> >>> kresult = (*(hdev->priv->device))->USBDeviceOpen (hdev->priv->device);
> >>> #endif
> >>>
> >>> Is there any reason we can't always just use USBDeviceOpen to prevent
> >>> exclusive connections? I thought it might have to do with setting the
> >>> configuration, but my testing shows that the device will work just
> >>> fine with USBDeviceOpen.
> >>>
> >>> So, if there is a reason not to change it, please let me know and I
> >>> won't, otherwise I will probably submit the change in a few days.
> >>>
> >>>
> >>> --Mike Lewis
> >>> "Be who you are and say what you feel, because those who mind don't
> >>> matter and those who matter don't mind." --Dr. Seuss
> >>>
> >>> ------------------------------------------------------------------------------
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
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-d2d
_______________________________________________
Libusb-devel mailing list
Libusb-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-devel