interceptty looks like what you want.
I found that from this Ubuntu page
interceptty - Intercept traffic to and from a serial port.
If you want to use interceptty as an external serial monitor
[connected to two serial ports on your machine and relaying between
them, while recording the output]
you can use one device as the backend, and use the -p option to tell
the frontend not to create it's own tty, but just use the one you tell
interceptty -s 'ispeed 19200 ospeed 19200' /dev/ttyS0 -p /dev/ttyS1 -
interceptty prints its output in a fairly unattractive, painful to
look at format. However, it is very easy for other programs to parse.
For an example of how to post-process this output into something
appropriate to whatever you are intercepting, see the included Perl
Output lines are in this general format:
< 0x54 (T)
0x4b (K) ^ Direction ^^^^ Hex code (to real device)
^^^ ASCII character (to real device)
^^^^ Hex code (from real device)
^^^ ASCII character (from real device) The direction marker is a '<' if this character was sent to the backend device, and
'>' if it was received from the backend device. It is always followed
by a single space. If the character was received from the real device,
a tab will appear next (this makes the output easier to follow). After
that is the hex code for the character, and the ASCII representation
of the character if it is an ASCII character.