Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Is there any port monitoring tool to watch the packets written on the port? I especially want to check if my program written in Java works so I need some kind of tool to see if my little application is writing the messages to the port. How do I do this?

share|improve this question
Packets aren't written on the port. Characters are. It's not like Ethernet at all. – LawrenceC Apr 30 '11 at 18:33
Wouldn't the serial port show up in /dev? Would you be able to just read that file or is that not possible? – n0pe Nov 8 '11 at 17:59
Similar questions from sibling SE sites: and – Cristian Ciupitu Feb 4 at 8:12

6 Answers 6

up vote 12 down vote accepted

I found projects called Linux Serial Sniffer, jpnevulator, and Moni. The first two look like they do exactly what you want. The last one calls itself a monitor, but it actually looks like a standard serial communication program.

share|improve this answer
thanks for that !! i will give it a try. by the way i solved the issue from my java side. i was missing a \r, so that prevented my message from writing on to the port. thanks for that anyways!! – Deepak Apr 30 '11 at 18:24
The «LInux Serial Sniffer» is buggy, it absolutely takes out incoming data, thus another application which is actually listen to serial see nothing. But, at least, the data that goes outside seems to go without problem. – Hi-Angel Mar 31 at 11:12

I don't think the serial driver has any tracing functionality that would allow you to watch packets. You can use strace to observe all the reads and writes from your application:

strace -s9999 -o myapp.strace -eread,write,ioctl ./myapp
share|improve this answer
can is send packets to the port if nothign is connected ? – Deepak Apr 30 '11 at 12:53

When I debug interaction of my application with a serial port, I use moserial.

share|improve this answer
What're you talking about, in the docs written it's just a terminal. – Hi-Angel Mar 31 at 10:53

Have a look at ttyUSBSpy. It is on alpha stage, but it works.

share|improve this answer
It doesn't. It is written in python, and the code does import some import pcopy, which is even Google gave up to find. – Hi-Angel Mar 31 at 10:43

Try this:

screen /dev/tty.usbserial-blahblah 9600

works for me.

share|improve this answer
This opens the port and assumes control over it, so nothing else can use it. This does not "monitor" or "sniff" the traffic. – Ian M Jan 23 at 7:12

socat is a tool to connect (nearly) everything to (nearly) everything. In your usecase you could connect your serial port /dev/ttyS0 to a PTY /tmp/ttyV0, then point your application to the PTY, and have socat tee out Input and Output somewhere for you to observe.

Googling "socat serial port pty tee debug" will point you to several examples, one being:

$ socat /dev/ttyS0,raw,echo=0 SYSTEM:'tee input.txt | socat - "PTY,link=/tmp/ttyV0,raw,echo=0,waitslave" | tee output.txt'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.