Nathan Hjelm | 1 Feb 2012 01:14

Re: OpenUSB / LibUSB on Mac OS X

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.

-Nathan

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
(Continue reading)

Michael Lewis | 1 Feb 2012 01:19
Picon

Re: OpenUSB / LibUSB on Mac OS X


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
Winson Yung | 1 Feb 2012 04:53
Picon

usb_bulk_write() sending 512byte data timeout

Hi all, I recently downloaded libusb-win32-bin-1.2.6.0 so that I can
use it to build a windows application for bulk transfer testing under
Windows 7. One thing I noticed when calling usb_bulk_write(), usb
write timeout if data size is 512bytes. However if data size is
64bytes or 10 bytes, timeout error never occur. I used the bulk.c file
located under examples folder as the baseline for my test app, and I
have purposely disable using async bulk transfer.

On the USB device side, I have descriptor setup for handling max
64byte for full speed, and 512byte for high speed. So is the problem I
am seeing because host test app only setup with device in USB full
speed mode, therefore limit the max packet transfer to 64bytes? If so,
how do I choose to setup USB high speed mode with device in the test
app?

Thanks in advance for the help

/Winson

------------------------------------------------------------------------------
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
Segher Boessenkool | 1 Feb 2012 05:13

Re: OpenUSB / LibUSB on Mac OS X

> 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.

One example is when you have an FT2232 with two logically
independent serial devices attached, e.g. a JTAG and a UART.
Operating either requires you to send control messages to
the device.  OSX allows you to do that, but it does not work
with current libusb.

Segher

------------------------------------------------------------------------------
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
Xiaofan Chen | 1 Feb 2012 05:42
Picon

Re: usb_bulk_write() sending 512byte data timeout

On Wed, Feb 1, 2012 at 11:53 AM, Winson Yung <winson.yung <at> gmail.com> wrote:
> Hi all, I recently downloaded libusb-win32-bin-1.2.6.0 so that I can
> use it to build a windows application for bulk transfer testing under
> Windows 7. One thing I noticed when calling usb_bulk_write(), usb
> write timeout if data size is 512bytes. However if data size is
> 64bytes or 10 bytes, timeout error never occur. I used the bulk.c file
> located under examples folder as the baseline for my test app, and I
> have purposely disable using async bulk transfer.
>
> On the USB device side, I have descriptor setup for handling max
> 64byte for full speed, and 512byte for high speed. So is the problem I
> am seeing because host test app only setup with device in USB full
> speed mode, therefore limit the max packet transfer to 64bytes? If so,
> how do I choose to setup USB high speed mode with device in the test
> app?

You do not choose the USB high speed mode with your application.
The OS will choose the high speed mode or full speed mode.
You can use USBView to check whether the system recognizes
your device as full speed or high speed.
http://www.ftdichip.com/Support/Utilities.htm
http://www.ftdichip.com/Support/Utilities/usbview.zip

--

-- 
Xiaofan

------------------------------------------------------------------------------
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
Nathan Hjelm | 1 Feb 2012 05:56

Re: OpenUSB / LibUSB on Mac OS X

Well, the requirements for sending a control message is that the device is open. When I wrote the libusb
backend I assumed that meant the device must be opened by the current process (not some other process). I
see no reason not to change the backend implementation if that assumption is wrong.

-Nathan

On Jan 31, 2012, at 9:13 PM, Segher Boessenkool wrote:

>> 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.
> 
> One example is when you have an FT2232 with two logically
> independent serial devices attached, e.g. a JTAG and a UART.
> Operating either requires you to send control messages to
> the device.  OSX allows you to do that, but it does not work
> with current libusb.
> 
> 
> Segher
> 

------------------------------------------------------------------------------
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
Vitali Lovich | 1 Feb 2012 06:01
Picon

Re: OpenUSB / LibUSB on Mac OS X

Yeah - I would say that you should have the core driver implementation in 1 process & then use IPC to
co-ordinate amongst other processes.  I tend to think of libusb as a user-space driver API; do you ever have
2 kernel drivers active for the same device?

-Vitali

On Jan 31, 2012, at 8:56 PM, Nathan Hjelm wrote:

> Well, the requirements for sending a control message is that the device is open. When I wrote the libusb
backend I assumed that meant the device must be opened by the current process (not some other process). I
see no reason not to change the backend implementation if that assumption is wrong.
> 
> -Nathan
> 
> On Jan 31, 2012, at 9:13 PM, Segher Boessenkool wrote:
> 
>>> 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.
>> 
>> One example is when you have an FT2232 with two logically
>> independent serial devices attached, e.g. a JTAG and a UART.
>> Operating either requires you to send control messages to
>> the device.  OSX allows you to do that, but it does not work
>> with current libusb.
>> 
>> 
>> Segher
>> 
> 
> 
> ------------------------------------------------------------------------------
> 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

------------------------------------------------------------------------------
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
Xiaofan Chen | 1 Feb 2012 06:05
Picon

Re: OpenUSB / LibUSB on Mac OS X

On Wed, Feb 1, 2012 at 12:56 PM, Nathan Hjelm <hjelmn <at> me.com> wrote:
> On Jan 31, 2012, at 9:13 PM, Segher Boessenkool wrote:
>>> 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.
>>
>> One example is when you have an FT2232 with two logically
>> independent serial devices attached, e.g. a JTAG and a UART.
>> Operating either requires you to send control messages to
>> the device.  OSX allows you to do that, but it does not work
>> with current libusb.
>
> Well, the requirements for sending a control message is that the
> device is open. When I wrote the libusb backend I assumed that
> meant the device must be opened by the current process (not
> some other process). I see no reason not to change the backend
> implementation if that assumption is wrong.

So this is different issues with the past discussion (in 2009) where
it talks about multiple open with the same process space (different
threads). That problem has been solved, right?
http://libusb.6.n5.nabble.com/MacOSX-Accessing-multiple-interfaces-of-the-same-device-at-once-td8710.html

> USBDeviceOpenSeize is needed to cause the kernel driver to detach
> 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.

Just wondering what kind of driver will allow the detach feature? Apparent
Apple HID driver does not have this feature.
http://stackoverflow.com/questions/3368008/reading-and-writing-to-usb-hid-interrupt-endpoints-on-mac

--

-- 
Xiaofan

------------------------------------------------------------------------------
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
Xiaofan Chen | 1 Feb 2012 06:08
Picon

Re: OpenUSB / LibUSB on Mac OS X

On Wed, Feb 1, 2012 at 1:01 PM, Vitali Lovich <vlovich <at> gmail.com> wrote:
> Yeah - I would say that you should have the core driver implementation in
> 1 process & then use IPC to co-ordinate amongst other processes.  I tend to
>  think of libusb as a user-space driver API; do you ever have 2 kernel
> drivers active for the same device?

Just remember that those are USB composite device and they will be
multiple kernel drivers active for the same device.

For FT2232D which has one JTAG interface and one UART interface,
under Windows, three drivers will be active: composite parent,
D2XX and the the VCP driver.

Under Linux, there will be two drivers, one ftdi_sio (for the UART)
and one usbfs (for the JTAG).

--

-- 
Xiaofan

------------------------------------------------------------------------------
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
Nathan Hjelm | 1 Feb 2012 06:10

Re: OpenUSB / LibUSB on Mac OS X


On Jan 31, 2012, at 10:05 PM, Xiaofan Chen wrote:

So this is different issues with the past discussion (in 2009) where
it talks about multiple open with the same process space (different
threads). That problem has been solved, right?
http://libusb.6.n5.nabble.com/MacOSX-Accessing-multiple-interfaces-of-the-same-device-at-once-td8710.html

Yes, multiple access from the same process space should be working.

USBDeviceOpenSeize is needed to cause the kernel driver to detach
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.

Just wondering what kind of driver will allow the detach feature? Apparent
Apple HID driver does not have this feature.
http://stackoverflow.com/questions/3368008/reading-and-writing-to-usb-hid-interrupt-endpoints-on-mac

Drivers that respond to the kIOServiceRequestingClose message support the feature. One example: http://www.opensource.apple.com/source/IOUSBFamily/IOUSBFamily-453.4.2/IOUSBCompositeDriver/Classes/IOUSBCompositeDriver.cpp

-Nathan
------------------------------------------------------------------------------
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

Gmane