in reply to Setting baudrate automatically?

Detecting the incoming baudrate is difficult. There are RS232 analyzers that can do this but the RS232 interfaces in most PCs don't support automatic baud rate detection.

You might be able to cycle through the baud rates until valid data is received. This assumes there is some way to validate the received data.

The "getty" program that provides for login to *nix systems from serial ports typically supports a configurable selection of baud rates and switches the baud rate every time an RS232 "break" is received. The remote equipment (a dumb terminal with a human operator was common) must send the "break" to cause a baud rate switch. This depended on the human operator validating the data sent to the terminal (i.e. recognizing a login prompt) and pressing the "break" key until the login prompt appeared.