Ken, N9VV reported an error in PowerSDR 1.3.13 where opening a serial port after it had already been opened and then closed would cause an exception. The serial port will remain unavailable until PowerSDR is exited and then restarted.
Using PortMon, I immediately saw the error: I was trying to close the handle to the com port without first cancelling a WaitCommEvent(). The file handle to the com port would only be closed when PowerSDR exited.
The correction to the source code was pretty easy:
In SerialStream.cs line 1383, function FreeHandle needs to be changed to:
Calling SetCommMask() with a mask of 0 cancells the current WaitCommEvent() allowing the com port to be closed and correcting the problem.
Using PortMon, I immediately saw the error: I was trying to close the handle to the com port without first cancelling a WaitCommEvent(). The file handle to the com port would only be closed when PowerSDR exited.
The correction to the source code was pretty easy:
In SerialStream.cs line 1383, function FreeHandle needs to be changed to:
protected internal override void FreeHandle(IntPtr handle)
{
if (_ownsHandle)
{
//Important! Must cancel all events before closing file!!!
Win32API_Serial.SetCommMask(handle, 0);
//Now we can close the file handle
Win32API_Serial.CloseHandle(handle);
}
}
Calling SetCommMask() with a mask of 0 cancells the current WaitCommEvent() allowing the com port to be closed and correcting the problem.
Comments