none
"Simultaneous" sync I/O to R/W Pipes with WinUSB ? RRS feed

  • Question

  • Almost identical question to "Simultaneous" Async I/O to a R/W Pipe with WinUSB ?but for synchronous I/O.

    Basically, I have two threads: a "reader" thread and a "writer" thread. The reader thread calls WinUsb_ReadPipe() in a loop with OVERLAPPED = NULL, and whenever it gets input, relays it to the main thread. Likewise, the writer thread receives data from the main thread and calls WinUsb_WritePipe().

    Will this work? Will WinUSB fall over if there are simultaneous requests on two different pipes?

    I'm also guessing that I don't need (mustn't use?) FILE_FLAG_OVERLAPPED when I call CreateFile()


    • Edited by Edward Falk Wednesday, January 11, 2017 3:53 AM fixed link
    Wednesday, January 11, 2017 3:50 AM

Answers

  • winusb will be find with two blocked sync io calls on two different pipes. You MUST call CreateFile with FILE_FLAG_OVERLAPPED, the docs for WinUsb_Initialize clearly state this

    DeviceHandle [in]

    The handle to the device that CreateFile returned. WinUSB uses overlapped I/O, so FILE_FLAG_OVERLAPPED must be specified in the dwFlagsAndAttributes parameter of CreateFile call for DeviceHandle to have the characteristics necessary for WinUsb_Initialize to function properly.

    https://msdn.microsoft.com/en-us/library/windows/hardware/ff540277(v=vs.85).aspx


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

    Wednesday, January 11, 2017 6:47 PM

All replies

  • winusb will be find with two blocked sync io calls on two different pipes. You MUST call CreateFile with FILE_FLAG_OVERLAPPED, the docs for WinUsb_Initialize clearly state this

    DeviceHandle [in]

    The handle to the device that CreateFile returned. WinUSB uses overlapped I/O, so FILE_FLAG_OVERLAPPED must be specified in the dwFlagsAndAttributes parameter of CreateFile call for DeviceHandle to have the characteristics necessary for WinUsb_Initialize to function properly.

    https://msdn.microsoft.com/en-us/library/windows/hardware/ff540277(v=vs.85).aspx


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

    Wednesday, January 11, 2017 6:47 PM
  • Excellent, thank you. My tests also indicate this works perfectly.
    Thursday, January 12, 2017 10:48 PM