Click here to Skip to main content
15,888,454 members

Comments by Greggo (Top 2 by date)

Greggo 24-Nov-20 14:07pm View    
This made a difference, but 2 problems remain:

The CreateFileW function call consistently results in an exception with this message:
"An unhandled exception of type 'System.AccessViolationException' occurred in WorkingCodeCS.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

The other problem is that the call to ClearCommError (hSerial, out dwErrorFlags, out comstat) always returns a comstat.cbInQue value of 0, while in the C++ code this call worked properly and always returned a non-zero value when there was data to be retrieved.
Greggo 14-Nov-20 19:41pm View    
Because I've tried and haven't been able to get it to work. Also because I already have C++ code that has been proven to be reliable and see no reason why I shouldn't be able to port it to C# using P/Invoke, and because after that porting everything works EXCEPT for ReadFile. That's why not.