Always remember to flush

Thread Starter

mcgyvr

Joined Oct 15, 2009
5,394
I'm a geek with no one here to understand just how much of a geek I am today so I'll confess my fumble here..
Working on an Arduino project Master/Slave serial communication.
All was working great the first loop around but not working right after that..

I was using readStringUntil for the first time to get error codes from the slave Arduinos.
I wasn't aware or really didn't think about it but I forgot to clear out the serial buffers after each loop..
So the next loop around it was just reading what was left in the buffer thus messing up my program..

So now I know to "Always Flush" that buffer..
 
Last edited:

GopherT

Joined Nov 23, 2012
8,009
I'm a geek with no one here to understand just how much of a geek I am today so I'll confess my fumble here..
Working on an Arduino project Master/Slave serial communication.
All was working great the first loop around but not working right after that..

I was using readStringUntil for the first time to get error codes from the slave Arduinos.
I wasn't aware or really didn't think about it but I forgot to clear out the serial buffers after each loop..
So the next loop around it was just reading what was left in the buffer thus messing up my program..

So now I know to "Always Flush" that buffer..
I grew up with three brothers. My poor mother was trying to teach 4 boys from 3 to 9 years of age to flush. One day she threatened to sew a hook on our asses so the hook would automatically flush the toilet as we left the bathroom. I always flushed after that because the only experience I had with hooks was fishing and those fish didn't seem too comfortable with a hook in their mouths.

Now that I think back on that story... Mom was kind of an engineer herself - that Idea alone was (slightly in humane but) innovative.

Also, flush your crap or it will be there for the next loop to deal with!
 
Top