I find the difference in the implementation of SerialPort.Open () between Windows and Mono on Ubuntu. Here is my current implementation:
if (serPort.IsOpen)
{
serPort.Close();
}
serPort.BaudRate = Convert.ToInt32(baudRateCmbBox.Text);
serPort.PortName = serPortCmbBox.Text;
try
{
serPort.Open();
}
catch
{
return false;
}
return true;
On Windows, if I have another program with the same open port, an exception is thrown and the function returns false. However, in Mono, the serial port still opens, regardless of whether another program has a serial port open. It even reads and writes to the serial port at the same time as another program.
So the question is, is there a way that will work on both Windows and Mono, which will let me check if the serial port is open in another program?
source
share