Quantcast

Re: How do you use libusb 1.0 using, WIN32

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How do you use libusb 1.0 using, WIN32

napoleon.tan
Hello,

Thanks you Xiafan for the tip. I was able to run the sample codes already.

I have decided to use the libusb-0.1 library instead of the new one.
Based on my understanding, the libusb-1.0 uses WinUSB library as a
backend for the windows environment.
Hence, Isochronous transfer is not allowed in libusb-1.0. Is this correct?

On a second question,
I am trying to understand using isochronous async api for libusb-0.1.
I searched the internet and found several like the one you wrote on
another forum.
http://www.microchip.com/forums/m417509-print.aspx

In the example, based on the example from what I understand the call
must follow a sequence of
    usb_isochronous_setup_async (1 time)
    usb_submit_async (1 to many)
    usb_reap_async (1 to many, must match the usb_submit_async call count)
    usb_free_async (1 time)

I have several question on this logic, basically as I read on the
source, usb_reap_async is only
using WaitForSingleObject to synchronize the async call. So is it safe
to say that isochronous call
result is in FIFO sequence?

Also, I notice that the usb_submit_async has two endpoints EP_IN,
EP_OUT. what is the difference in
using either. For example I have mouse device, viewing the log of
testlibusb-win.exe it shows that the
endpoint type is EP_IN. Hence calling usb_submit_async with EP_IN is
valid but calling EP_OUT would
cause an error? (I am actually just preparing for a project to use this
API. I am still waiting for the third
party company to finish in building the hardware, but in the mean time I
am trying to read and experiment
with the libusb using the available usb devices I have like mouse, usb
harddisk, scanner, etc)

I think that testing the usb_bulk_write or async version of bulk to the
mouse does not make sense.
So I am trying to send to a USB hard drive which I found to have two
endpoints, EP_IN 0x81 and EP_OUT 0x02)
using testlibusb-win.exe. So I was trying to test the bulk transfer
after creating a filter driver. I sent some
bulk data to the EP_OUT endpoint of the device. But the device just
hangs, probably because I just sent
random data. Is there a way to watch what message a usb device sends
back and forth to the PC like a USB Spy?

Also, I was wondering what is the difference of using a filter driver
(created using install-filter-win.exe) for device
versus installing an actual usblib-driver (created using
inf-wizard.exe). For example on the mouse device, I notice
that the filter allows the existing function of the device to still
function. So does that mean one device has two drivers?

Sorry for too much question but I am just trying to start developing in
libusb from scratch.

On 2012/01/08 7:48, [hidden email] wrote:

> ------------------------------
>
> Message: 4
> Date: Fri, 6 Jan 2012 17:55:40 +0800
> From: Xiaofan Chen<[hidden email]>
> Subject: Re: [Libusb-win32-devel] How do you use libusb 1.0 using
> WIN32
> To: [hidden email]
> Message-ID:
> <CAGjSPUBGra4xsiwnaFx0yu60vTO7UqDPOuV=H5UeJCOd=[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Fri, Jan 6, 2012 at 12:59 PM,<[hidden email]>  wrote:
>> Hello,
>>
>> I am trying to start using libusb as a beginner.
>> I want to use it in an existing VC++ application
>> but when I download the libusb 1.0 (libusb-1.0.8) the file
>> does not contain a lib file for importing in a MSVC project.
> 1.0.8 release is the latest release but it is quite old
> and it does not have the Windows backend codes.
>
>> I am trying to follow a sample code at this URL.
>> http://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/
>>
>> I am not sure how to build that code in windows and to include in my
>> project.
>> There is also no instruction in the Windows Backend Page.
>>
>> Can anyone point me to the right direction here?
> It wil be easier if you go to the Windows backend page and
> download Pete Batard's binary snapshots. It includes the
> VC++ static and import library. You may also want to clone
> the git source tree to look at the examples.
>
> http://www.libusb.org/wiki/windows_backend


------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How do you use libusb 1.0 using, WIN32

Xiaofan Chen
On Thu, Jan 12, 2012 at 6:54 PM,  <[hidden email]> wrote:

> I have decided to use the libusb-0.1 library instead of the new one.
> Based on my understanding, the libusb-1.0 uses WinUSB library as a
> backend for the windows environment.
> Hence, Isochronous transfer is not allowed in libusb-1.0. Is this correct?

For the current libusb-1.0 Windows backend (WinUSB), that is correct.
Isochronous transfer should work under Linux, Mac OS X and FreeBSD
for libusb-1.0.



> On a second question,
> I am trying to understand using isochronous async api for libusb-0.1.
> I searched the internet and found several like the one you wrote on
> another forum.
> http://www.microchip.com/forums/m417509-print.aspx
>
> In the example, based on the example from what I understand the call
> must follow a sequence of
>    usb_isochronous_setup_async (1 time)
>    usb_submit_async (1 to many)
>    usb_reap_async (1 to many, must match the usb_submit_async call count)
>    usb_free_async (1 time)
>
> I have several question on this logic, basically as I read on the
> source, usb_reap_async is only
> using WaitForSingleObject to synchronize the async call. So is it safe
> to say that isochronous call result is in FIFO sequence?

I do not quite understand your question and I myself does not
understand the async API too well. My guess is that there is no
guarantee about the sequence.

Travis can probably provide more insights.

> Also, I notice that the usb_submit_async has two endpoints EP_IN,
> EP_OUT. what is the difference in
> using either. For example I have mouse device, viewing the log of
> testlibusb-win.exe it shows that the
> endpoint type is EP_IN. Hence calling usb_submit_async with EP_IN is
> valid but calling EP_OUT would
> cause an error? (I am actually just preparing for a project to use this
> API. I am still waiting for the third
> party company to finish in building the hardware, but in the mean time I
> am trying to read and experiment
> with the libusb using the available usb devices I have like mouse, usb
> harddisk, scanner, etc)

For EP_IN and EP_OUT, you have to understand the basic concepts
of USB before you embark on USB related projects.
http://www.usbmadesimple.co.uk/

Basically your mouse only have Interrupt IN endpoint (from device
to host) and no Interrupt OUT (from host to device) endpoint.

It is probably not a good idea to use mouse or usb hard disk for
the experiments. But if that is what you have, never mind. You
have to understand the communication protocol though in order
to effectively use libusb.

> I think that testing the usb_bulk_write or async version of bulk to the
> mouse does not make sense.

The mouse does not have bulk endpoints. Again you may
want to go through ABCs of USB before you embark on
the project.

> So I am trying to send to a USB hard drive which I found to have two
> endpoints, EP_IN 0x81 and EP_OUT 0x02)
> using testlibusb-win.exe. So I was trying to test the bulk transfer
> after creating a filter driver. I sent some
> bulk data to the EP_OUT endpoint of the device. But the device just
> hangs, probably because I just sent
> random data. Is there a way to watch what message a usb device sends
> back and forth to the PC like a USB Spy?

You can use USB software sniffers. Here is the link to a Microchip
forum post which lists some software sniffers.
http://www.microchip.com/forums/tm.aspx?m=493704

>
> Also, I was wondering what is the difference of using a filter driver
> (created using install-filter-win.exe) for device
> versus installing an actual libusb-driver (created using
> inf-wizard.exe). For example on the mouse device, I notice
> that the filter allows the existing function of the device to still
> function. So does that mean one device has two drivers?

The filter acts as a upper filter driver to the mouse function
driver.

For more information, you may want to read the libusb-win32
wiki.
http://sourceforge.net/apps/trac/libusb-win32/wiki

Some more advanced links about device driver stack.
http://msdn.microsoft.com/en-us/library/windows/hardware/hh406256(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/hardware/hh439632(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/hardware/ff554721(v=vs.85).aspx

> Sorry for too much question but I am just trying to start developing in
> libusb from scratch.

No problem.


--
Xiaofan

------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How do you use libusb 1.0 using, WIN32

Travis
In reply to this post by napoleon.tan
On 1/12/2012 2:54 AM, [hidden email] wrote:

> On a second question,
> I am trying to understand using isochronous async api for libusb-0.1.
> I searched the internet and found several like the one you wrote on
> another forum.
> http://www.microchip.com/forums/m417509-print.aspx
>
> In the example, based on the example from what I understand the call
> must follow a sequence of
>      usb_isochronous_setup_async (1 time)
>      usb_submit_async (1 to many)
>      usb_reap_async (1 to many, must match the usb_submit_async call count)
>      usb_free_async (1 time)
>
> I have several question on this logic, basically as I read on the
> source, usb_reap_async is only
> using WaitForSingleObject to synchronize the async call. So is it safe
> to say that isochronous call
> result is in FIFO sequence?
>

Yes.

Generally you want to keep at-least 2 transfers pending at all times.  
For example:
1) Setup 3 async transfers and submit them.
2) Reap the oldest transfer, when it completes quickly process the data
and resubmit this transfer.
3) Keep repeating step 2 to process data.
4) When your all done, free the 3 async transfers.

> Also, I notice that the usb_submit_async has two endpoints EP_IN,
> EP_OUT. what is the difference in
> using either. For example I have mouse device, viewing the log of
> testlibusb-win.exe it shows that the
> endpoint type is EP_IN. Hence calling usb_submit_async with EP_IN is
> valid but calling EP_OUT would
> cause an error?

That's because endpoints are uni-directional (except the control pipe).
;)  If the most significant bit is set (ie. 0x80) then it is
DeviceToHost (PC Read, IN).

> Also, I was wondering what is the difference of using a filter driver
> (created using install-filter-win.exe) for device
> versus installing an actual usblib-driver (created using
> inf-wizard.exe). For example on the mouse device, I notice
> that the filter allows the existing function of the device to still
> function. So does that mean one device has two drivers?
>

Yes. It installs libusb-win32 as an upper filter driver and attempts to
work in conjunction with the original driver.

Regards,
Travis


------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Libusb-win32-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
Loading...