You need to use two different UARTs on your mega: one for communicating with your uno and the other for communicating with your PC for debugging. Use uart-0 (usb cable connnection) for communicating with your PC. Choose uart-1 (tx 18, rx 19), uart-2 (tx 16, rx 17) or uart-3 (tx 14, rx 15) for communicating with the uno.