-1

how to handle serial port connection /disconnection and reconnection in C#?

I am using a null modem, from COM3 and null modem i am sending some command to simulated device in COM4 which accepts those commands.

How to handle scenario in my application connected to COM3 , if my simulated device has been closed in Com4 and again reopened at the same port?

AKX
  • 152,115
  • 15
  • 115
  • 172
TsunamiCoder
  • 120
  • 1
  • 12
  • https://stackoverflow.com/questions/13408476/detecting-when-a-serialport-gets-disconnected – Maxime C. Aug 24 '21 at 12:23
  • Does this answer your question? [How to autodetect connection of serial COM port](https://stackoverflow.com/questions/19567324/) and [Serial Port Check if Device is Connected](https://stackoverflow.com/questions/17595992/) and [Detecting when a SerialPort gets disconnected](https://stackoverflow.com/questions/13408476/) and [SerialPort.IsOpen returns true when physically disconnected](https://stackoverflow.com/questions/24957037/) and [Detect serial port insertion/removal](https://stackoverflow.com/questions/4199083/) and [UWP check serial device](https://stackoverflow.com/questions/58399964/) –  Aug 24 '21 at 12:52

1 Answers1

-2

I haven't worked with serialports on c#, I have worked with serialports in Angular.

I had an object that stored all my serialports objects. When a port was beign disconnected or connected this would trigger an event to modify my Serialports object. This post might be able to help you to see when something gets disconneted : detecting disconnected c#.

This post : autodetect serialport, might help you to create events when serialport connections are detected.

Maxime C.
  • 37
  • 11
  • Nothing in your links to writing a good code says my awnser is a comment. I gave my approach to how you could do it with events, you just make a comment with the same links i use and without any advice but links. It clearly says in your link you should give context to the link. – Maxime C. Aug 24 '21 at 13:27