A Tool For Spying On Serial Data

[Piotr] was working on a recent Arduino project when he ran into a problem. He was having trouble getting his Arduino Pro Mini to communicate with an ESP8266 module. He needed a way to snoop on the back and forth serial communications. Since he didn’t have a specialized tool for this task, [Piotr] ended up building his own.

spying-on-serial-thumbThe setup is pretty simple. You start with a standard serial cable containing the TX, RX, DTR, and GND wires. This cable connects the Arduino to the ESP8266 WiFi module. The TX and RX lines are then tapped into. Each wire is routed to the RX pin of two different serial to USB adapters. This way, the data being sent from the Arduino shows up on one COM port and the data being transmitted from the module shows up on the other.

The next piece of the puzzle was coming up with a way to see the data more clearly. [Piotr] could have opened two serial terminals simultaneously, but this wasn’t ideal because it would be difficult to compare the timing of the data. Instead, [Piotr] spent less than an hour writing his own simple serial terminal. This one connects to two COM ports at the same time and prints the data on the same screen. The data from each COM port is displayed in a separate color to make it easy to differentiate. The schematic and source code to this project can be found on [Piotr’s] website.

35 thoughts on “A Tool For Spying On Serial Data

  1. This is a great idea for troubleshooting simple communications and half duplex or command/reply message, but the twin USB host nature of the design will not preserve accurate character timing between the two USB ports at high speeds with full duplex communications. If this matters to a particular application, it will make debugging difficult.

    1. yup, I’d like a dual serial sniffer that does preserve exact timing.

      the hp (etc) proto analysers put timestamps on all data streams, iirc. been a long time since I last used one but they were neat little (big) machines.

  2. OP is lucky. It gets very hard to correlate the timing info over 2 USB devices if there is a very high rate of traffic and volume between the two. Serial data only get buffered and transferred either when the FIFO is full or a time out happens on the USB to serial chip. (The timeout could be in the order of 1ms.) One way to handle it for such tricky cases might actually go back to motherboards that still have dual serial ports or a UC with USB and multiple serial ports.

          1. The hardware’s pretty straightforward, yes. The software’s rather a lot more involved, though, and the clones make use of that.

          2. Let me pay for great software then, not for hardware.
            Either design something super nice and dificult to copy or sell great service.
            because of service I would like to pay IDA pro and Winrar, because those are great and when I earn money from work, ill go legal for that. As a student, nope… books are expensive and teachers arent giving legal software aswell (hoped to get vxworks legaly, got a hack version.)

            So, those Right to Copy chinese people do what they want, ill buy their crap and use it. If i realy like the tools, I might consider buying or supporting the real guys.

            I dunno, should I crab popcorn?

    1. Perfect! I need to snoop on a USB serial adapter to reverse engineer a fan controller’s software protocol so I can use it under Linux (Windows software only,) and I was struggling to find a way to do that.

  3. I did something similar to get access to various routers and a Definity PBX. Setup serial snoop fire up two terminals call support and wait for them to login. Its annoying owning the equipment and having someone say nope you can’t do that with it.

  4. I’ve tried to do something similar before, but I don’t understand why you can’t just OR the Rx and Tx signals with diodes. When I tried, I got Rx but not Tx on the terminal. I ended up using a logic analyzer, but realtime monitoring would have been a hell of a lot easier. I tried some MITM software, but I couldn’t get it to work for some reason and just gave up.

      1. Yes, to some extent you can do that with diodes. But then, you will not see which data is from which direction. You will also have a problem when two channels will be active at the same time.

  5. I did this exact same thing – a serial cable with 4 ends – back in 2007 for reverse engineering the selector unit on a “multi electrode array neural stimulator” (MEA) and wrote a piece of linux code that mimicked the windows software.

  6. I know that I’m just speculating here, but why not use an arduino mega r3 style board and hook up the two tx lines to be read to the microcontroller, and then just spit the resultant data out the ‘main’ serial port on the mega r3. The mega r3 should have enough processing power and I/o where you could add timestamps (from an attached RTC) or add prefix-headers to each line stating where it was coming from and going to…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s