After reading previous forum topics and the page for Serial.flush(), I still do not understand how to implement it in my code. Is it really necessary? I currently have one Bluetooth module (RN42) attached to ports 19 and 18 (TX1 and RX1) and another Bluetooth module attached to ports 17 and 16 (TX2 and RX2) on the Arduino Mega board. Below is the current code that I am using.
char datafromBT;
 if (Serial1.available() > 0) {Â
  datafromBT = Serial1.read();Â
  Serial2.write(datafromBT);
  Serial2.flush();
My question is, is the Serial.flush() necessary for the code and if it is, is it correctly placed? I have another Arduino Mega which uses another Bluetooth module and it will receive the data from Serial2's Bluetooth module.
I'm sending the data from Serial1 to Serial2 just for research purposes.
And I did try putting in the Serial.flush() but it seemed to be the same result when I don't put it in. So, what really is the point of Serial.flush() when it will return me the same result? ???
Probably after the serial2.flush you could send back an acknowledge on serial1 which should have a remote that is waiting for the acknowledge. That way serial1 does not sink into a swamp while serial2 is flushing.