|
From: Robin A. <rob...@te...> - 2007-04-24 17:33:47
|
In order to do so I need to understand first what's going on exactly...
I'll show an example:
/**------------------------------------------------------------------------**/
USB_Boolean USB_SubmitReceive( USB_Handle hUsb, void *pBuf, int32
nWordsCnt )
{
// Submit an asynchronous read
if ( usb_submit_async( hUsb->pReadContext, (char *)pBuf, (nWordsCnt
* 2) ) < 0 ) return USB_FALSE;
else return USB_TRUE;
}
/**------------------------------------------------------------------------**/
int32 USB_ReapReceive( USB_Handle hUsb, int32 nTimeout )
{
// The number of received bytes in the receive buffer
int32 nUsedBytesCnt;
// Check whether the timeout is negative
if ( nTimeout < 0 )
{
// Get the read context
USB_UsbContext *pContext = (USB_UsbContext *)hUsb->pReadContext;
// Check whether the overlap IO is completed
if ( WaitForSingleObject(pContext->ol.hEvent, 0) !=
WAIT_OBJECT_0 ) return -1;
// Reap the context
nUsedBytesCnt = usb_reap_async( hUsb->pReadContext, 0 );
}
else
{
// Reap the context
nUsedBytesCnt = usb_reap_async( hUsb->pReadContext, nTimeout );
}
if ( nUsedBytesCnt == LIBUSB_REAP_ASYNC_TIMEOUT_ERR )
{
return 0;
}
else if ( nUsedBytesCnt < 0 )
{
char *pszError = usb_strerror();
return nUsedBytesCnt;
}
else
{
return (nUsedBytesCnt / 2);
}
}
Those are 2 functions in the API I'm porting, the documentation on these
functions isn't very clear tho, so I'm figuring out what every function
does in order to get it to work with my driver. Hence I need to know
the behaviour of the usb_XXX functions.
But I got a reply from the author of the code, he explained me how the
functions behave, and yes indeed like you said, Windows CE doesn't
support asynchronous reads or writes like that. So I'll have to write
some thread to get the same behaviour.
Thanx for your reply.
Robin
Stephan Meyer wrote:
>> I do need to replace it with a suitable alternative, in order to do so,
>> I need to know how this function behaves.
>>
>> Kind regards
>> Robin
>>
>
> I think you are taking the wrong approach. If you just want to create
> a libusb compatible layer that sits in between your application and your
> special driver then you should not care about the internals of the current
> Windows implementation.
>
> All you have to do is to implement the API functions specified by usb.h.
> If I had to do the job I would use windows.c as a starting point, remove
> all platform dependent code, and reimplement this code from scratch.
> I think this is much easier than trying to adapt the existing code to your
> driver.
>
> Stephan
>
>
>
>> Stephan Meyer wrote:
>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: lib...@li...
>>>>
>>>>
>>> usb_reap_async() is part of the DLL's undocumented
>>> asynchronous API.
>>> You can just ignore it and all other usb_xxx_async() functions,
>>> since WinCE doesn't support asynchronous (overlapped) IO.
>>>
>>> Stephan
>>>
>>>
>>>
>>>> Hello,
>>>>
>>>> I'm porting an application developed for windows xp to windows mobile.
>>>> This application uses libusb to communicate with a USB-device.
>>>> I developed a USB driver myself for windows CE. Now I'm at the point to
>>>> port the layer between the libusb to the application to a layer between
>>>> my driver and the application. I found a call to the following function:
>>>> int usb_reap_async(void *context, int timeout);
>>>> However, I can't find any documentation on this function. What does it
>>>> do exactly?
>>>>
>>>> Kind Regards
>>>> Robin Astle
>>>>
>>>> -------------------------------------------------------------------------
>>>> This SF.net email is sponsored by DB2 Express
>>>> Download DB2 Express C - the FREE version of DB2 express and take
>>>> control of your XML. No limits. Just data. Click to get it now.
>>>> http://sourceforge.net/powerbar/db2/
>>>> _______________________________________________
>>>> Libusb-win32-devel mailing list
>>>> Lib...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>>>>
>>>>
>>>>
>>> _______________________________________________________________
>>> SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
>>> kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192
>>>
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by DB2 Express
>>> Download DB2 Express C - the FREE version of DB2 express and take
>>> control of your XML. No limits. Just data. Click to get it now.
>>> http://sourceforge.net/powerbar/db2/
>>> _______________________________________________
>>> Libusb-win32-devel mailing list
>>> Lib...@li...
>>> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>>>
>>>
>>>
>>>
>>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Libusb-win32-devel mailing list
>> Lib...@li...
>> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>>
>>
>
>
> _______________________________________________________________
> SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
> kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Libusb-win32-devel mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel
>
>
>
>
|