Console Server - Revisited

I came back to this as I wanted to repurpose the system slightly. My current job involves some hardware which uses serial interfaces internally and generates debug information over additional serial ports. So wanted to be able to sniff and capture 6 connections, Tx and RX on 2 ports and Rx only on 2 more.

To make this work I changed the logfile handling to use python logging, should of done this from the start! This gives me for free a whole load of file handling, rotation etc. The standard python logging fileconfig uses a different config handling module to my side so I had to split the file into two, one called logging.ini and the other config.ini.

Another issue I found was that twisted does not use the serial inter character timeout, it performs a select, this meant that messages where getting split up across log lines. So I added some buffering before logging data, a twisted timer callback that waits for 200mS before writing the log message.

I added the ability to change the data output format, ASCII, HEX DUMP and mixed. So if you are sniffing a binary transport the data can be logged in a manner that makes sense.

I have also made the software look in a number of locations for config files, current directory, $HOME/.consoleserver /etc/consoleserver and finally the defaults in the installed package.

So out with the raspberry Pis again. For this purpose I stopped the ssh listener per serial port, you can still ssh in and connect to a port if you want to see what is happening.

I have now had a raspberry pi (old version) running for 2 weeks connected to the hardware and it still has not filled up the disk. When I spot a problem in the backend I can ssh into the relevant pi and locate the hours worth of log file I need to look at.

You can create either a log file per port or a single file for all ports or the power of python logging both a single file and separate files at the same time.

So now I should call this a serial port logger.

Again the updated version is on pypi, this great way to install it for my own use as it pulls all dependancies in for me. You will probably need python-dev as paramiko uses pycrypto.