Author Topic: HID - Losing Interrupt Input Reports on Windows XP  (Read 17440 times)

swt2c

  • Member
  • ***
  • Posts: 7
HID - Losing Interrupt Input Reports on Windows XP
« on: January 19, 2014, 05:09:07 pm »
Hi,

I have an HID device from which I'm reading data (256KB) via Interrupt reports.  My receiving application is using Signal11's HIDAPI on Windows XP.  Sometimes (but not all of the time) the receiving application does not receive all of the packets - there is a sequence number in the packets, so I can tell that there is a missing packet.  I have put a USB analyzer inline and it sees the missing packets - and there does not appear to be anything wrong with them.  I don't think this is a case of the HID driver's report buffer being overrun - I used HidD_SetNumInputBuffers to set the buffer size to 512, and I still see the problem with about the same frequency.

Are there any other possibilities for why I am losing packets?  I do not see any problems with lost packets when running the same application under Linux.

Thanks,
Scott

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #1 on: January 19, 2014, 07:37:19 pm »
Retrieve multiple reports at once.

See

How can I keep my application from losing reports?

here

http://www.lvr.com/hidfaq.htm

swt2c

  • Member
  • ***
  • Posts: 7
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #2 on: January 19, 2014, 08:03:06 pm »
Thanks - but the need to retrieve multiple packets at once would still suggest that I'm overrunning the HID driver report buffer, which I don't *think* that I am.

My device is sending 1 64-byte report every 1 ms.  So, with the number of buffers set to 512, that would mean I'm behind by over half a second.  That doesn't seem likely to me.

Thanks,
Scott

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #3 on: January 19, 2014, 08:28:24 pm »
Every call to ReadFile has overhead.

If you're making 4000 calls to retrieve 256k (256,000/64), there is plenty of opportunity for a 512-report HID buffer to fill.

Try a larger ReadFile buffer and see what happens.

Increasing the report size will also help.

swt2c

  • Member
  • ***
  • Posts: 7
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #4 on: January 20, 2014, 09:47:19 am »
I suppose it is possible.

I can't change the report size - the device I'm using is a commercial device for which I cannot change the firmware.

Increasing the ReadFile buffer will be challenging, but I'll see if I can try that.  Thanks.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #5 on: January 20, 2014, 10:50:37 am »
Make lpBuffer large enough to hold multiple reports.

swt2c

  • Member
  • ***
  • Posts: 7
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #6 on: January 26, 2014, 09:35:36 pm »
The other thing that I forgot to mention is that my device will only send 50 reports before waiting for an "ACK" response back from the host.  On a Windows 7 box, I was losing reports too, but once I set the HID driver buffer to > 50 (and thus it can hold a complete 50 packets from the device), the loss went away.

On my one problematic Windows XP box, I am still seeing occasional report loss even with the HID driver buffer > 50.  The best I can come up with here is some sort of driver bug.  When I use a software USB packet capture tool on the XP box, it sees the missing packet but it is malformed.  The hardware USB capture tool sees the packet fine.  So that's why I'm leaning toward driver bug, or maybe bad hardware.  (However, the same hardware works fine when booted with Linux).

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #7 on: January 27, 2014, 09:50:45 am »
Malformed in what way?

swt2c

  • Member
  • ***
  • Posts: 7
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #8 on: January 27, 2014, 09:56:31 am »
It was missing the data portion of the report.  As in, the normal reports I'm getting have 64 bytes of data.  This one had zero bytes.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #9 on: January 27, 2014, 06:28:10 pm »
You still could try retrieving multiple reports at once with ReadFile. A call to ReadFile every millisecond may be more than the PC can manage. If you use a larger buffer and find you're getting multiple reports, that's a sign that the PC application wasn't keeping up when doing one report at a time.

swt2c

  • Member
  • ***
  • Posts: 7
Re: HID - Losing Interrupt Input Reports on Windows XP
« Reply #10 on: January 27, 2014, 06:40:56 pm »
Yes, but unfortunately, that's easier said than done.  :-)  HIDAPI, as well as my application, are completely focused on handling one report at a time.  Making changes to retrieve multiple is not a trivial task.