I kind of half remember doing this a long long time ago
The internal circular buffer of the UART gets overwritten by the new data.
You should turn on flow control on the receiving UART (if supported, should be!) using setserial with the flow_on parameter.
This will get the receiving UART to tell the sending UART to stop sending bytes if the receiving buffer is almost full and tell it to start sending again if the buffer is read and thus emptied.
If your null modem cable has the RTS and CTS lines cross wired you can go for hardware flow control, otherwise use soft control.
For the receiving side you need a receiving process that reads out the bytes that get put into the receiving buffer.
The 'solution' I came up with, having to use bash of course was something like:
- use the mkfifo command to create a local fifo file: mkfifo /tmp/myff
- run a background process to continiously read from serial and dump to fifo: tail /dev/ttyS1 -f > /tmp/myff &
- echo "1234567890123456" > /dev/ttyS3
- Wait a micro second or two...
- cat /tmp/myff
Not sure if I remembered it all correctly, but you might give it a go!