LowPower.h and serial transmission completion: conflict?

On Arduino Uno using the
LowPower.h,
RTClibExtended.h and
Wire.h libraries,
during a wake-up, if a function calls for a serial hardware transmission to be performed, is it required to include a delay (enough to cover the time needed for the data to be transmitted) to prevent the Arduino to go back to sleep (using LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); command) before the transmission is finished?

Or is the serial transmission fully handled before a power down is executed?

brice3010:
Or is the serial transmission fully handled before a power down is executed?

It is if you use Serial.flush();

srnet:
It is if you use Serial.flush();

Great!!
Just to be sure: this flushes the UART, if there is some HC12 radio receiving from the UART then this radio needs to get some time to clear its buffer too. Say some 50ms?

brice3010:
Great!!
Just to be sure: this flushes the UART, if there is some HC12 radio receiving from the UART then this radio needs to get some time to clear its buffer too. Say some 50ms?

It ensures that serial output pending in the buffer is sent before continuing, which is the answer to the question you asked.

As for stuff that may arrive in the receive buffer, that could presumably happen at any time, so your application needs to decide if you want to process that data or not, before going to sleep.

srnet:
It ensures that serial output pending in the buffer is sent before continuing, which is the answer to the question you asked.

As for stuff that may arrive in the receive buffer, that could presumably happen at any time, so your application needs to decide if you want to process that data or not, before going to sleep.

Thanks. The issue is a bit more complex then I had envisioned. I will indeed have to find out how long it takes the HC12 to send whatever was in the uart buffer after the flush.

srnet:
It is if you use Serial.flush();

I thougth serial.flush(); belongs in the loop function right after an actial serial.print() or serial.write(), but now and then I see examples where this function is included in the setup.
What is right?

brice3010:
I thougth serial.flush(); belongs in the loop function right after an actial serial.print() or serial.write(), but now and then I see examples where this function is included in the setup.
What is right?

Both ?

srnet:
Both ?

Ok; so it depends on where the serial write needs to be flushed?

brice3010:
Ok; so it depends on where the serial write needs to be flushed?

You use it in your program when you want to wait till all pending serial output has been sent before continuing.