If I understand correctly, you want to connect 2 serial devices on the same Rx/Tx pair of terminals.
Your concern is about how you detect when one of the 2 devices want to talk to you unexpectedly.
Here is a bit of more elaboration, hardware and software, on the mux/demux idea I mentioned in the earlier post.
- use a 2:1 bus mux/demux, like FST3257 (fast, cheap, easy to find);
- connect the select to an arduino output (say pin 4);
- connect Tx0 and Tx1 to arduino pins 2 and 3 and define ISRs for each of them (attachInterrupt);
- select the device that triggered the interrupt (device that "wants to talk to you") by setting arduino pin 4 accordingly;
- read the input from the selected device;
- when you want to send to the one of the devices, select it with pin 4 as well.
The schematics would look something like this:
to Arduino Tx 1A --+ +------ 1B1 to Tx0; also to Arduino digital 2;
| | Device 0
| +------ 1B2 to Tx1; also to Arduino digital 3;
| FST3257 |
to Arduino Rx 2A --+ (or +------ 2B1 to Rx0
| equivalent) | Device 1
| +------ 2B2 to Rx1
S (select) to Arduino digital output pin 4
(RS232 signals must be converted to TTL, obviously).