HidLibrary icon indicating copy to clipboard operation
HidLibrary copied to clipboard

reading HID reports

Open ClimbTheWorld opened this issue 13 years ago • 2 comments

Hi mike, I do need your library. Thanks for the work. I'm already able to send send reports and this works fine. But if I want to read reports from the device, I'm implementing an CM119A from C-Media, then the problem starts. Sometimes the program is running through and I get the input report; and sometimes not. I'm using ReadReport and WriteReport. As I need async-read (ReadReport) I wouldn't expect an error. Some code:

HidDeviceList = HidDevices.Enumerate(0x0D8C, 0x000E);

            report_get = new HidReport(4);
            if (HidDeviceList.Count<HidDevice>() > 0)
            {
                // Grab the first device
                HidDevice = HidDeviceList.First<HidDevice>();
                OutData[0] = 0x00;
                OutData[1] = 0x00;
                OutData[2] = 0x00;
                OutData[3] = 0x40;
                report_post.Data = OutData;
                HidDevice.WriteReport(report_post);
                report_get = HidDevice.ReadReport(); // here the program hangs
                ...

Do you have any idea?

ClimbTheWorld avatar May 14 '12 09:05 ClimbTheWorld

Solved the problem!

I do have to write a dummy report to trigger an interrupt, because I do need an interrupt endpoint, and I can only read if a interrupt was registered. By writing a report I do manually trigger an interrupt.

But -

After reading 8-times in a row, the software hangs up by calling NativeMethods.ReadFile(ReadHandle, buffer, (uint)buffer.Length, out bytesRead, ref overlapped); from HidDevice.cs (row 414). Why do I get that one I don't know yet.

ClimbTheWorld avatar May 16 '12 13:05 ClimbTheWorld

That call is blocking so it will wait for the device to send a report. You can use the following non blocking calls:

https://github.com/mikeobrien/HidLibrary/blob/master/src/HidLibrary/HidDevice.cs#L132 https://github.com/mikeobrien/HidLibrary/blob/master/src/HidLibrary/HidDevice.cs#L157

HTH,

m

On Mon, May 14, 2012 at 5:18 AM, ClimbTheWorld < [email protected]

wrote:

Hi mike, I do need your library. Thanks for the work. I'm already able to send send reports and this works fine. But if I want to read reports from the device, I'm implementing an CM119A from C-Media, then the problem starts. Sometimes the program is running through and I get the input report; and sometimes not. I'm using ReadReport and WriteReport. As I need async-read (ReadReport) I wouldn't expect an error. Some code:

HidDeviceList = HidDevices.Enumerate(0x0D8C, 0x000E);

           report_get = new HidReport(4);
           if (HidDeviceList.Count<HidDevice>() > 0)
           {
               // Grab the first device
               HidDevice = HidDeviceList.First<HidDevice>();
               OutData[0] = 0x00;
               OutData[1] = 0x00;
               OutData[2] = 0x00;
               OutData[3] = 0x40;
               report_post.Data = OutData;
               HidDevice.WriteReport(report_post);
               report_get = HidDevice.ReadReport(); // here the program
hangs
               ...

Do you have any idea?


Reply to this email directly or view it on GitHub: https://github.com/mikeobrien/HidLibrary/issues/19

mikeobrien avatar May 20 '12 16:05 mikeobrien