Yes, that's possible and the connections proposed are correct.
Having them communicate to each other using software is exactly the same as if you communicated directly to the PC.
The only difference is using Serial1."command" to address the second uart of the megaboard instead of plain Serial."command".
Using the next piece of code on the mega for example would make it possible to let the PC communicate with the uno as if... the mega were transparent.
void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
// read from Uno, send to pc:
if (Serial1.available()) {
int unoByte = Serial1.read();
Serial.print(unoByte, BYTE);
}
// read from pc, send to Uno:
if(Serial.available()) {
int pcByte = Serial.read();
Serial1.print(pcByte, BYTE);
}
}
Edit.... Rx2 and tx2 as mentioned in you message on the mega are in fact the third uart of the Mega.
Serial2."Command" would be the right one in the code above.
The idea should work though as long as you choose Serial."command", Serial1."command", Serial2."Command" or Serial3."Command" using the right one(s) of the 4 ports available.