I am trying to implement interrupt endpoint read from my USB device using WinUSB in Windows 7. There is no documentation on how to implement interrupt callback or reads in WinUSB. Does anyone know if any code example exist for WinUSB interrupt callbacks? Should I do WinUSB_ReadPipe on the interrupt endpoint in a timer function? What’s the best way to do this in WinUSB?
You should simply call WinUSB_ReadPipe asynchronously to the interrupt endpoint. This will pend until the device actually returns some data, at which point the IO will complete back to you. There is really no difference from the WinUSB interface point of view between interrupt and bulk endpoints.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Friday, December 17, 2010 3:05 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] WinUSB interrupt endpoint
I am trying to implement interrupt endpoint read from my USB device using WinUSB in Windows 7. There is no documentation on how to implement interrupt callback or reads in WinUSB. Does anyone know if any code example exist for WinUSB interrupt callbacks? Should I do WinUSB_ReadPipe on the interrupt endpoint in a timer function? What’s the best way to do this in WinUSB?
Thanks Randy.
So I will use WinUSB_ReadPipe with an event passed in to the overlapped structure, then WaitForSingleObject on the event. Once the event is signaled, I will call WinUsb_GetOverlappedResult to determine the final read result. Am I correct?
Thanks Randy.
So I will use WinUSB_ReadPipe with an event passed in to the overlapped structure, then WaitForSingleObject on the event. Once the event is signaled, I will call WinUsb_GetOverlappedResult to determine the final read result. Am I correct?
That’s one way. If you don’t need to do anything else while you’re
waiting, just call WinUSB_ReadPipe without an OVERLAPPED structure.
That will block until the transfer is complete.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Thanks Tim. I would like to do the interrupt asynchrnously with callback notification of the data arrival. So I guess my best bet is the WinUSB_ReadPipe with OVERLAPPED struct. And I can invoke the callback to actually deliver the final read data once I get results from WinUSB_GetOverlappedResult. Am I right?
In async mode, ReadPipe returns immediately, the data is only available when the event is signaled and GetOverlappedResult tells you how many bytes are transferred. Correct?
I want to do it in async mode.
Thanks.
async with respect to what? you could easily create a thread and just synchronously wait for the io to complete and then post a message to your main application thread. or you could probably use the thread pool? or an io completion port.