I have been using this code example as a basis for a GUI to communicate with an embedded device I am developing. Been using it for several months as I add capabilities to the GUI and embedded device and it has worked GREAT. Many runs have been over a solid week with no issues
A few days ago, I figured it was time to handle device removal and attachment. One thing I ran into was after reattaching and running FindTheHid and trying to read interrupt reports, I would get the following exception:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
on the following statement
fileStreamDeviceData.BeginRead(inputReportBuffer, 0, inputReportBuffer.Length, new AsyncCallback(GetInputReportData), inputReportBuffer);
So I spent way too much time trying to debug this. Finally decided to go back to the original generic_hid example and run it in the following manner.
1.) Start Generic HID GUI
2.) Enter my vendor and product ID
3.) Click on "Find Device" --- device found fine
4.) Click on "Send and Receive Data->Once" -- report read correctly
5.) Physically Disconnect/Reconnect Device
6.) Either Do "Find My Device followed by Once", or just do "Once"
Doing this recreates the problem/exception
I did spend time researching this on this forum but got the impression that the streams version was updated to include issues found earlier but was a little confused as some of the bugs seemed to imply it was stream related.
Any ideas?
Love your books Jan!
Gary