Skip to content

Flush function #18

Description

@jeuhmeuh

Hello,
Since the newer version of Arduino IDE It appears that the Serial.flush method doesn't clear the rx buffer but the TX Buffer:

"Waits for the transmission of outgoing serial data to complete. (Prior to Arduino 1.0, this instead removed any buffered incoming serial data.)"
(Source arduino.cc )

I use the following function with success :
static void flush(void)

{
int i = 0;//Wait 3 Char lenght after last incomming byte
while (i <= _MODBUS_3_C_TIMEOUT) {
if (Serial.available()) {
Serial.read();
i = 0;
}
else {
i++;
}
delayMicroseconds(1);
}
}
thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions