Ard. mega; uart RX1 (19200bps) +uart RX2 (19200bps) = Uart TX4 (56000bps)

Hello,
I simply need to merge two ascii characters streams into one output stream. I have Arduino Mega which has 4 uarts.
When merged I woud use PC to store output to a file.
The target is a simple datalogger.

Input would be:
1/ at uart1 rx
"xxxxxx\n"
"xxxxxx\n"
"xxxxxx\n"
.. never ending repeat
2/ at uart2 rx
"yyyyyyyyyyyyyyy\n"
"yyyyyyyyyyyyyyy\n"
... never ending repeat

The sentece "x" and "y" are variable length and can be long up 600-800 chars.

3/ I would like to get output at uart4 tx like:
"xxxxxx\n"
"xxxxxx\n"
"yyyyyyyyyyyyyyy\n"
"xxxxxx\n"
... never ending repeat, the order of sentences "x" and "y" doesn't matter.

Please would you advice me how to do it...
Thank you in advance

So are you saying..

Read and store lines of data from serial 1 and serial 2 e.g into two separate arrays

When array 1 has at least 2 lines and array 2 has at least 1 line

Output array 1 line 1. Array 1 line 2. Array 2 line 1. To serial 3

Then loop back and start again.

I can see issues if the data arriving on serial 1 and serial 2 is not synchronised in some way, as you will end up with too much data in either array 1 or array 2, e.g over a long period of time.

Is there some sort of flow control on the input data.