Use calculated delays
Created by: grigorig
Some serial drivers don't handle draining the transmit buffer correctly. This has been handled with a long delay so far, which might be problematic. There's a race condition with some protocol versions.
Until STC15, the baud rate switch is initiated with a command sent by stcgal, which is replied to by the MCU with the new baud rate. So the switch of the baud rate has to be done after the command has finished transmission, but before the MCU has started to transmit the response.
This change calculates the minimum delay needed (with some tolerance added) so that it's unlikely that the baud rate switch will happen too late.