This is Day 5 of 30 (in 30 days of Geek)…
Today’s post is about “Quick nifty hacks you’re proud of”.
I find I spend a lot of time whipping up quick little hacks, and then reuse them later in real applications if they worked well.
One great example of a quick hack I did is a Serial port sniffer, in python.
I have added code for your amusement 🙂
take 3 FTDI USB serial modules like this:
Step 2, wire up the 3 modules:
- chip 1 –> wire up to your serial device using wires like a normal rs232 app
- chip 2 –> (RX sniffer line) connect the input lines from this chip to the RX line from chip1
- chip 3 –> (TX sniffer line) connect the input lines from this chip to the TX line from chip1
Chip 1 is the main connection from your PC to the serial device. Your application should work with just this connection. Chips 2 and 3 are just “listening” to the data that is flowing through chip1
Now… plug all 3 lines into your computer, and fire up this python application.
As data passes from your serial device through chip1, the sniffer application then sees data that it hears on the RX line and TX lines, and prints it to screen (color coded) and a logfile.