Go Down

Topic: Serial Buffer, Background, Affects timing? (Read 286 times) previous topic - next topic

kiltjim

Hello all!

I am working on a project that is recording from a GPS, a serially outputting device, and an I2C device.  I am trying to make sure that before I get too deep into this, I don't have timing issues.

I have an Arduino Mega, so I have the multiple hardware serial ports. 

Question 1:
Can I have multiple devices continuously talking continuously without missing data?

Question 2:
Now, what I am having trouble understanding is: Does the data coming in from any serial device get held in the respective buffer in the background until I handle it, or do I need to make sure I know how many bytes are coming in, do that math and make sure that everything has enough time to do what it needs?

For instance, 39 bytes coming in = about 40 milliseconds.  If I want to catch the next GPS output (1 Hz), I have 960 milliseconds to do whatever else I need to do.  Or, is it 39 bytes come in the background, Arduino keeps doing whatever it is doing, If the GPS sends something it'll grab that too.  Every so often I can check in, grab everything, parse it, and log it.

Thanks to any help anyone can provide.  Maybe I'm missing something basic.

Graynomad

Quote
Can I have multiple devices continuously talking continuously without missing data?

Yes.

Quote
Does the data coming in from any serial device get held in the respective buffer in the background until I handle it,

Yes, up to 64 bytes, after that you will lose data.

Quote
Every so often I can check in, grab everything, parse it, and log it.

Yes, as long as you process the data at an average rate >= the rate it's coming in.


_____
Rob
Rob Gray aka the GRAYnomad www.robgray.com

kiltjim

Rob,

Thank you very much for the response!  Not only does that answer my question, but now I know how many bytes I can let sit in my buffer into I need to process them.

Thank you!

Go Up