# serial snoop



## brockwil (Apr 1, 2019)

Hi,
I'm trying to troubleshoot a serial device and would like to be able snoop on the data on the serial line.  I have had some success using the 'watch' command against /dev/cuaU0, but I only get what is getting sent to the serial device and not what is received.  Does anyone know if there is a way to snoop on the serial line in the other direction?  I haven't had any luck reading the man pages or searching...
Thanks!
Brock


----------



## aragats (Apr 3, 2019)

I believe it should be possible to do with socat(1), I haven't tried though.
I used to use a simple program interceptty (there is no port, you'll have to compile yourself, but it's straight forward), the command:
	
	



```
# interceptty -s 'ispeed 115200 ospeed 115200' /dev/cuaU0 /tmp/serlal
```
creates /tmp/serlal virtual serial port that you use for the actual communication. It prints the serial data to _stdout_.
Just tested it with a serial port I use to access a BeagleBone Black's serial console: perfectly catches two-way data.


----------



## Datapanic (Apr 3, 2019)

I wrote something to do that years ago, but the person who wanted it was not wanting it for sincere reasons, so I never released it.


----------



## brockwil (Apr 3, 2019)

Thanks for the tip aragats!  I'll give it a try, sounds like just what I'm looking for.


----------



## unitrunker (Apr 4, 2019)

Another option would be to intercept the C runtime calls to open/read/write/close (much like Super Capsicumizer 9000) to log the bytes inbound and outbound using LD path shenanigans. The appeal is no need to run under the higher privs need to load an ad-hoc device driver.


----------

