Receiving data from two serial ports

You need a different non-blocking approach to receiving the data. Have a look at the examples in Serial Input Basics.

For example if you are using the second example you can have a copy of the function receiveWithEndMarker() for Serial1 and another copy for Serial2. Where the example causes the variable newData to be true you should have two separate variables newData1 and newData2 and then you can easily tell which port has received the data.

...R