I have a problem with opening/closing com port - my program works perfect for some time, and than immediately stops working. Without any exception or anything like that. The only solution is disconnecting USB modem, then closing debugger (debugging won't stop if i don't disconnect modem).
Modem which i use is USB Huawei E173, program runs on Windows 10 64bit.
On my private pc (Windows 7 64bit) the same program and the same modem runs perfect, without any problem. So the problem is OS/PC settings.
Here is my simple program written in C#.
static void Main(string[] args)
{
SerialPort mySerialPort = new SerialPort("COM8");
mySerialPort.BaudRate = 230400;
mySerialPort.Parity = Parity.None;
mySerialPort.StopBits = StopBits.One;
mySerialPort.DataBits = 8;
mySerialPort.Handshake = Handshake.None;
mySerialPort.RtsEnable = true;
while (true)
{
mySerialPort.Open();
Console.WriteLine("Opened " + DateTime.Now);
mySerialPort.Close();
Console.WriteLine("Closed " + DateTime.Now);
Thread.Sleep(3000);
}
}