This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to inform USB host that data waiting to transmit

Hello!

How do I inform the USB host, that the device has data waiting to transmit? I like to do an IN transaction. I am using the control transfer for data exchange. Or do I have to use Endpoints for a data IN transaction?

Thanks for your help!

Joerg

  • As USB is host centric, there is no active way for device to inform to the host, unless the host polls the device regularly. - Up to USB 2.0. This will change on coming USB 3.0.

    What is the USB class you are working on?

    PC HID device driver polls the interrupt IN endpoint regularly.
    Also CDC driver polls the bulk IN and interrupt IN endpoints.
    For these classes, the data on the device is carried to host, just by putting data to the endpoint, at the next access from the host.

    For generic device driver, you have to do it in your host app.
    Make an asynchronous (OVERLAPPED) read call to the IN pipe.
    Then, the host controller repeats IN transactions for ever, until the device put data, or until the call fails by noise.
    When the asynchronous read call completes, the data is received by the host app.

    You may need to do this process in an another thread than main, if you use one of Wait-API, like WaitForSingleObject().

    OR

    If you do it in main thread, ReadFileEx() will work. In the completion routine, post a user-defined message, and catch it in the message handler of the main thread.

    Tsuneo