4

When setting baud rate of an open serial port, how long shall we wait before baud rate actually changes? I guess this depends on the driver of the port, right? (especially if it's not a real serial port).

In this case, is there any way to get an event or to query serial port to see it's actual baud rate?

I have seen so many dirty codes that set baud rate and sleep for a few seconds before continuing the job and this delay is actually random and sometimes doesn't work on some systems(Cause maybe driver needs more time on that system?!).

In some cases things are even worse, the device connected to serial port has a timeout that if the delay is too long then session fails altogether!

Is there any 'standard' way of changing port properties (like 'baud rate')?

Mike
  • 47,263
  • 29
  • 113
  • 177
Hamed
  • 279
  • 1
  • 3
  • 13
  • I would assume that most serial port driver APIs for changing baud rate are synchronous, so when the function returns, the baud rate has already changed. If this were not the case, the driver call wouldn't be able to return error status, for example if you requested an unavailable rate – TJD May 03 '12 at 07:33
  • 3
    There is no standard way. Changing the baudrate while the port is opened is a random number generator for any received data. So yes, sleeping for a while and then flushing the receive buffer can be important. – Hans Passant May 03 '12 at 10:43

0 Answers0