none
"Simultaneous" Async I/O to a R/W Pipe with WinUSB ? RRS feed

  • Question

  • Hi there,

    I would like to do simultaneous async I/O to a read/write Pipe with WinUSB. I have two threads, one that performs overlapped reads to the pipe, another thread that performs overlapped writes to the same pipe. As my device does not have data for me to read until I have sent a specific amount of data to the device, the reads will time-out until then.

    Now it seems to me, that writing does not occur, while an overlapped read is in progress. In a first try I do not wait in the call to WinUsb_GetOverlappedResult(), because I do the wait before calling that function. When I wait for 1sec. before calling WinUsb_GetOverlappedResult(), a write transfer of 51200 bytes takes a little longer than 1sec. When waiting for 100ms, a write transfer of 51200 bytes takes a little longer than 100ms. The write timeout is set to 10sec.

    In a next try (read timeout = 100ms, write timeout = 10sec.) I also wait in the call to WinUsb_GetOverlappedResult(), and then the longest time for a write transfer of 51200 is around 6 seconds (!).

    When I completely disable my reading thread (without changing anything on the write thread), the writing takes place in the speed that I am expecting.

    Has anyone any idea what I could do wrong ??

    Best regards, Detlef

    Tuesday, March 12, 2013 8:23 AM

Answers

  • pipes are unidirectional at the bus level, it has nothing to do with winusb.  cypress is the same way. the only bidirectional pipe is the control pipe.  winusb is fully capable of async io, with multiple requests pending at once on each endpoint.  you need to look at your app and see if you are making sure that you have as many in flight io as you can, otherwise you will be missing your scheduled time on the bus between sending new io and the old io completing.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, March 13, 2013 4:19 PM

All replies

  • Bulk and interrupt Pipes are unidirectional . What type of pipe(s) are you issuing both reads and writes to?

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, March 12, 2013 4:24 PM
  • Hi Doron,

    It's a bulk pipe. Using the generic driver (Cypress USB driver) I can do both read and write I/Os at the same time (Using DeviceIOControl()). Is it the WinUSB driver, that restricts bulk pipes as unidirectional ones (and is there a reason for this ??)

    Thanks for your reply,

    best regards, Detlef

    Wednesday, March 13, 2013 12:09 PM
  • pipes are unidirectional at the bus level, it has nothing to do with winusb.  cypress is the same way. the only bidirectional pipe is the control pipe.  winusb is fully capable of async io, with multiple requests pending at once on each endpoint.  you need to look at your app and see if you are making sure that you have as many in flight io as you can, otherwise you will be missing your scheduled time on the bus between sending new io and the old io completing.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, March 13, 2013 4:19 PM