Author Topic: Hid Example Program Gives Write Exception  (Read 9841 times)

daycounter

  • Member
  • ***
  • Posts: 1
Hid Example Program Gives Write Exception
« on: August 31, 2011, 01:44:22 pm »
I've just compiled the latest GenericHid example with Visual Studio 2010, on a vista machine.

I can find and connect to my HID device, however when I try to send it data. I get the following error:

"IO Exception will not work. Most Likely the file will become too long or the handle was not opened to support synchronous IO operations"

Does anyone else have this example working with Visual Studio 2010?   What would cause this error?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Hid Example Program Gives Write Exception
« Reply #1 on: August 31, 2011, 02:12:40 pm »
No answer off the top of my head but assuming you were using the FileStream example, does the ReadFile/WriteFile example work?

http://www.lvr.com/hidpage.htm#MyExampleCode

Jan

Dave

  • Member
  • ***
  • Posts: 3
Re: Hid Example Program Gives Write Exception
« Reply #2 on: September 07, 2011, 11:16:44 am »
Hi Daycounter,

I also am getting the same error on VS2010/XP here, on the .Write line:

Code: [Select]
' If the HID has an interrupt OUT endpoint, the host uses an
' interrupt transfer to send the report.
' If not, the host uses a control transfer.

If (fileStreamdevicedata.CanWrite) Then
    fileStreamdevicedata.Write(outputReportBuffer, 0, outputReportBuffer.Length)
    success = True
Else
    CloseCommunications()
    lstResults.Items.Add("The attempt to read an Input report has failed.")
End If


I haven't figured it out yet, but I did find this: http://www.lvr.com/forum/index.php?topic=425.0

Did you have any luck?

Best regards,

Dave

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Hid Example Program Gives Write Exception
« Reply #3 on: September 07, 2011, 12:18:40 pm »
Does your HID's report descriptor include an Outport report?

Jan

Dave

  • Member
  • ***
  • Posts: 3
Re: Hid Example Program Gives Write Exception
« Reply #4 on: September 07, 2011, 12:41:17 pm »
Hi Jan,

Thanks for your response.  I'm not sure - I'm using a honeywell 4600G, if that helps.

I did, however, fix the error I mentioned earlier by changing the size of the output byte array to 0-63 (vice 64) and leaving the correct byte count in the call to the .write method (64).

Now, I'm getting the same error in GetInputReportData here:

Code: [Select]
inputReportBuffer = CType(ar.AsyncState, Byte())

fileStreamdevicedata.EndRead(ar)


Still working on it...

Best regards,

Dave

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Hid Example Program Gives Write Exception
« Reply #5 on: September 07, 2011, 01:31:18 pm »
My example application is written to work with my PIC firmware, which sends and receives 2-byte reports. If you're accessing a different device, you may need to change buffer sizes and/or comment out the sending or receiving of some report types. The HIDP_CAPS structure will tell you about the supported reports, or use a protocol analyzer to view the report descriptor.

Jan