is there any way to clear send buffer?

Hello ,
I have connected my Pro-Mini to a serial device
when I read the data I'm getting from the deivce , I can see that the Pro-Mini is sending "old" data
is there any to clear the buffer or something ?

I can see that the Pro-Mini is sending "old" data

You mean like it's sending hieroglyphs?

something , and them insted of sending "hello" , he send me "%Hello"
so the device doesn't get the right command

Show your code. Whatever you did send before is gone (from the buffer in the library) so will not be send again. You might not have cleared YOUR buffer (in loop() or where-ever) in which case it will send that again.

you can call flush(). but I suspect the buffer is already clear and your program is sending that extra character.

The flush() function only clears the buffer by sending the data it contains. Its purpose is to block the rest of your code until all the data in the buffer has been sent.

If you want to clear the buffer without sending the data then flush() is not appropriate.

...R

The history of flush() function is, originally, it simply clears the send buffer without sending the data, which obviously was a bug and was fixed to force send it to clear the send buffer.

The question is if there is a way to clear the buffer, hence flush satisfies that question and hence is appropriate. lol

I don't think there is anything in the UART spec that allows recalling data you already sent to output buffer, which is what you are alluding to.

It is not likely for data to be sitting in the serial output buffer, specially just 1 character, therefore my theory is the problem is in the OPs code, that the code is actually sending that extra character rather than it be sitting there in the serial output buffer while the main loop is idle.

Flush down the toilet versus flush down the serial port :wink:

One can more than likely create a function/method in HardwareSerial that will reset some variables so the sending from the library will no longer dump data in the UART.