I know that Serial.flush() waits until the transmit circular buffer is empty, but as far as I am aware, that will return at the point that the last character gets moved from the transmit circular buffer into the transmit hardware buffer. That means that Serial.flush() actually returns at the start of the transmission of the last character.
What is the best way of waiting until the end of the transmission of the last character?
I am guessing it will involve first running Serial.flush() to get to the last character, then inspecting the SFRs for the serial port to know if transmission has finished.
Is there a more "Arduino" way of doing it that isn't going to be so hardware specific? Is some flag set somewhere by a transmit interrupt to say that the transmission has finished and a new character can be loaded into the buffer?