0
votes

I need to take an already opened serial port connection (for example, COM1 connected to a device) and ask its baudrate, parity bit, stop bit, etc.

So, is there a way to take all the opened serial connections of the OS and instantiate them, like:

SerialPort myTestSP = "Windows.SerialPorts[1]";
int myTestBR = myTestSP.BaudRate;

Thanks for your time!

1

1 Answers

2
votes

There isn't a supported way to do this. You can't open a device that's already open (serial ports do not allow sharing).

Programs such as Portmon work by injecting a device driver in the serial port's stack, and even then I'm pretty sure it has to do it while the port is closed.

It's not possible to write such a driver in C#.