Multiple connected Arduino and Serial Communication - data under presure

Hello, i have theoretical question.

I join three Arduino together via Serial Communication.
Arduino Mega is Master (receiver) and two other Arduinos will be connected to TX1/RX1 and TX2/RX2 as transmitters.

Mega is also connected to the PC via USB.

I read the data like this:

loop () 
{
  String a = Serial.readString();
  String b = Serial1.readString();
  String c = Serial2.readString();

The two transmitter arduino are sending data all the time in loop without pause. What that means is, that there is some "data presure".

Arduino Mega reads the data all the time.

But what happend? Will be the data ok or they will be mixed up?

Because I don't know if there are separated buffers for Serial1, Serial2, etc. or all data comes into one pool.

Thank you for clarification.

I would not use the function Serial.readString() because it blocks the Arduino until it gets the full string. The examples in Serial Input Basics are simple, reliable and non blocking. The 3rd example would be the most reliable - assuming you can program the transmitting Arduinos to use that format.

Create a separate receive function for each of the Mega Serial ports that you are using for input.

As a separate issue, it will be up to you to manage the ordering of the data as it is sent out by the Mega.

And, of course, if too much data is coming in the Mega won't be able to send it all. That will require proper planning of data quantities and baud rates.

...R

The two transmitter arduino are sending data all the time in loop without pause.

Well, that's pretty dumb. Why?

PaulS:
Well, that's pretty dumb. Why?

Right!

You just give me an idea. I don't have to actually. :slight_smile: Thank you for nudge!

Robin2:
Create a separate receive function for each of the Mega Serial ports that you are using for input.

Thank you Robin2 for examples.