1

I am using the HIDAPI with Windows 8.1 to read out an audio stream from a HID device. This stream sends ADPCM data consisting of 259 bytes, where the first 12 packages are 20 bytes large, and the 13th is 19 bytes. The problem is that HIDAPI always give me 20 bytes (+1 byte report ID) and never 19 bytes. The audio part of HID is not supported natively under Windows, but is working for linux with some third party libraries, and catching the HID data directly in Ubuntu gives the correct data length. How can I fix this?

Edit: I see that when setting up the hid_device*, the call for dev->input_report_length = caps.InputReportByteLength; is set to 21 at the very beginning, thus making it impossible to change over time. Still, my device sends only 19 (20) bytes of data every 13 packet. Can this be changed dynamically during runtime?

chwi
  • 2,752
  • 2
  • 41
  • 66
  • Can you explain what happens when you get 20 bytes instead of 19 as expected? In other words, does the 20th byte receive the value that should have been the first byte of the next package, is it `NULL`, is it garbage? – Austin Mullins Jul 07 '14 at 19:21
  • The last byte is garbage. – chwi Jul 08 '14 at 05:39
  • Then can you just ignore it? Set up your read loop so that every 13th time it only uses 19 bytes? What's preventing this? – Austin Mullins Jul 08 '14 at 13:54
  • @austin I was thinking about that, but I don't think I can be sure of where the data start, hence I won't be able to know which one is the thirteenth packet – chwi Jul 08 '14 at 17:40
  • This is a really interesting problem. Can you pre-load the data buffer before the call to `hid_get_feature_report`? I think you can set the last byte of the buffer to a dummy value and then check to see if it changed after the function returns. – Austin Mullins Jul 08 '14 at 20:52
  • Changes every time, on every packet – chwi Jul 09 '14 at 11:26

0 Answers0