JTrotta/MonoSerialPort

open port prolem

chenjeff622 opened this issue · 6 comments

below is my code
SerialPortInput _serialPort = new SerialPortInput();
_serialPort.SetPort("COM3", 9600);
_serialPort.ConnectionStatusChanged += SerialPortLib2_ConnectionStatusChanged;
_serialPort.MessageReceived += SerialPortLib2_MessageReceived;

        if (!_serialPort.IsConnected) {
            _serialPort.Connect();
        }

after open COM3 success it close self and open again on loop(close and open). could you help me? it's a bug or something wrong?
my environment is Windows 64bit and usb serial port.

Experiencing the same problem. I have console writes in ConnectionStatusChanged for debugging:

Console.WriteLine("Connection Status Changed");
Console.WriteLine(args.Connected.ToString());

And I see this in the console output:

Connection Status Changed
true
Connection Status Changed
False
Connection Status Changed
True
Connection Status Changed
False
Connection Status Changed
True
Connection Status Changed
False
Connection Status Changed
True
Connection Status Changed
False
Connection Status Changed
True

I tried both virtual option & "real" COM connections. I would go on and rewrite my code using different lib, this one appears to be dead. Still would like to see this one updated.

Hello guys,
the aim of this project was to use the native .NET library on Linux, with USB virtual devices. I'm successfully using it in a big project with no problem. I do not test it on Windows, even though it should work as well.
If you need a serial library for windows, I suggest you to use this very powerful one.
[https://github.com/jcurl/SerialPortStream]
JJ

I had the same problem. It doesn't seem to work on Windows. I swapped in serialport-lib-dotnet and that worked fine.

I have the same issue - the same issue happens on serialport-lib-dotnet, makes these nice libraries unusable :/.

@chenjeff622 @TimofeyBiryukov @kbandrew @Memhave @pashcovich ,
After some months, I updated the project correcting some bugs and added one more feature.
Bugs affected only the library on Windows, now it should work correctly on Windows just like Mono/Linux.
I also added the possibility (Windows only affected) to use COM ports with two digits (i.e COM10, COM11, etc.).
Hope you can use it now. Nuget updated to 1.0.5.
JJ

@JTrotta thanks for the fixes. I'll make sure to check it when have time.