PORTS Forum

Ports and Interfaces => USB => Topic started by: vanweric on December 13, 2011, 07:31:07 pm

Title: Read Timeout?
Post by: vanweric on December 13, 2011, 07:31:07 pm
I'm looking to implement a read timeout on the host for my HID device.  Do you have any of your examples implement this?

I tried wrapping the file handle in a FileStream, but the created stream doesn't support timeouts. 

Thank You
 - Eric
Title: Re: Read Timeout?
Post by: Ray on December 13, 2011, 07:50:19 pm
Eric,

I would think that you are after the overlapped call to CreateFile, and subsequent ReadFile call and then use the WaitForSingleObject to set a timeout. Jan has an example of this here:

http://www.lvr.com/hidpage.htm#MyExampleCode (http://www.janaxelson.com/hidpage.htm#MyExampleCode)

Check the Usbhidio_vc6 link down the page.

Ray.
Title: Re: Read Timeout?
Post by: Jan Axelson on December 13, 2011, 10:27:28 pm
Yes, and my Filestream example uses a timeout as well. Both are here:

http://www.janaxelson.com/hidpage.htm#MyExampleCode

Jan