Serial Com between Arduinos - One not always running.

Hi guys,

I have a serial connection between two arduinos. One is the "master" -A and always on the other one (B) turns on and off as needed.

The communication is bidirectional: A send some bytes to B and B sends some bytes to A.

The problem is when B goes offline how do i ensure that A doesnt run into a "outgoing buffer overflow".

I am coding in simulink not the traditional IDE so i really cant post any code. I am just looking for a methodology or code snippet that allows me to either detect when B goes offline so i can stop sending data and/or clear the buffer so its empty when B comes back online.

B may be sending or not sending data so using received data as an indicator whether its on or off wont work.

any help is appreciated!
-phil

On A-side:
if (Serial.available()>0){ // got some data from B to process

On B-side, send an “I’m online” message when ready receive data,
“going offline” when not.

I don't think it matters to the Arduino that nothing reads the data in the buffer. I have an app running for months using Serial.println() to output stuff that is never read. If I connect my FTDI cable to it I can read the data in the Serial Monitor anytime I want - which is not very often.

...R

CrossRoads:
On A-side:
if (Serial.available()>0){ // got some data from B to process

On B-side, send an "I'm online" message when ready receive data,
"going offline" when not.

btw got the mega screw-shields today :slight_smile:

pleasure doing business with you. they look great.