Author Topic: Waiting for async input report in Generic HID 6.0?  (Read 10674 times)

bmt22033

  • Member
  • ***
  • Posts: 3
Waiting for async input report in Generic HID 6.0?
« on: February 28, 2013, 04:24:47 pm »
I'm using your excellent Generic HID 6.0 code to transfer data to a device.  The data is typically ~150 bytes so I chunk it up into 64 byte pieces and sent three output reports.  After I send the last output report, the device will process the data (~ 30 seconds or so) and then respond with an input report.  Now I have three pieces of data that I need to send to the device and my pseudocode looks like this:

Code: [Select]
foreach (byte[] byteArray in listOfByteArrays)
{
    // split byteArray into 64 byte chunks

    // loop to write each chunk as an output report to device

    // try to read an input report from device; it may take the device ~30 seconds to respond so wait until we get a response before we continue the  foreach loop
}

The async/await stuff in C# 5.0 is new to me so I'm not entirely clear about how works.  As you can see, however, I need to be able to wait until I get the input report from the device before I begin processing the next byte array in listOfArrays.  Is there an easy way to wait for an async operation to complete?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Waiting for async input report in Generic HID 6.0?
« Reply #1 on: February 28, 2013, 05:42:59 pm »
In my example, RequestToGetInputReport waits for a report.

See:

http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx