I am using SerialPort class to communicate with an external device. I start the communication at 300 Baud per second however after the initial “handshake” I have to switch to a Baud rate specified by the device (usually 9600 Bps).
I have been unsuccessful in my attempts to continue communicating after I increase Baud rate however I am not sure why. That leads me to my question: What is the proper way of changing the Baud rate? Can it be done while the connection is open, or should I close the connection first?
I have been unable to find any information about this in the documentation…
I have tried both and have been unsuccessful in both ways, which made me think that I must be missing something obvious.
It turns out you can change SerialPort.BaudRate while it is open. But the SerialPort.DiscardInBuffer that is mentioned in answer by @Groo is a good tip!