Information Radiation in the Linux Team

LED sign

Almost exacly one year ago, a day when I was working late here in our Helsinki headquarters, I suddenly took the subway downtown to Clas Ohlson, a store for “DIY products for house and home, technology and hobbies” as they present themselves. There I picked up a LED sign and promptly carried it back to the office. The only thing I knew about it was that it was “computer controllable” somehow - the product specs at the store didn’t say exactly how you could interface with it. Turns out it comes with a Windows program which you can use to program it, and the control commands are then sent over a serial wire to the sign. I didn’t quite know why I wanted it, but I had this feeling that it could be a really neat information radiator for our team. Of course, being a Linux team, we couldn’t depend on a Windows computer to run the display, so I started to observe how the Windows program worked. I configured my VMware virtual machine to redirect the serial I/O to a regular file, and then started the bundled Windows program and used it to send messages and watched the bytes come into the file instead of being sent through the wire to the LED sign. I could then attempt to change a couple of bytes and pass it on to the actual serial port and see what happened. When I entered the string “Text message entered” into the Windows application, what it sent down the serial wire was:

<ID00><L1><PA><FE><MA><WC><FE>Text message entered4B<E>

You eagle-eyed people have no doubt already spotted the last two characters appended to the string I wrote - 4B - and figured out that it’s a simple checksum of some sorts. So I went on sending some more messages to try to make some sense out of how that checksum was calculated.

The string “A” gave 35, while “AA” gave 74. “AAA” -> 35 again. Now we’re spotting a pattern. Around this time my colleague Juha had started peering over my shoulder and joined in on the thinking. He soon figured out that it was a simple XOR of the ASCII values of each character in the string, but with a starting value of 0×74. Later we would also learn the meaning of some, but not all, of the different command tags seen in the message packets too - for example, the device has several “memory pages” where you can store different messages in each page and then use a command to switch between pages. I wrote a small Perl script to construct the basic variant of these messages; something along this way:

sub toled {
    my $page = shift;
    my $str = shift;

    # calculate checksum
    my $checksum = 0x74;
    for (0..length($str)-1) {
        my $c = ord(substr($str,$_));
        $checksum = $checksum ^ $c;
    }
    # construct basic "display this on page $page" message
    my $ledcode = sprintf("<ID00><L1><P%s><FE><MA><WC><FE>%s%02X<E>",
                          uc($page), $str, $checksum);
    # send to serial device /dev/ttyS0
    open SERIAL, ">/dev/ttyS0";
    print SERIAL $ledcode;
    close SERIAL;
}

And suddenly I could control our gadget from Perl, which of course was awesome. This spawned a flurry of activity, and soon enough I had written a simple RSS parser that could feed titles from an RSS feed to the LED sign. We have an internal blog with announcements from our automatic build system, so I hooked my Perl script to our “build blog”’s RSS feed and voilĂ  - the LED sign now served a useful purpose of always displaying the latest build information, including letting us now if any of the build had failed.

The next few days we scrambled to find a place to hang it where it would be visible not just to us but also to people walking by our team room, and a computer that could run it more or less permanently. We had an old 100 MHz Pentium II laptop that did an excellent job of running our little LED sign control script silently and surprisingly reliably, running a minimal Slackware installation. As an extra perk, we connected external loudspeakers to the laptop, and I modified the script to play a sound sample each time the word “failed” was mentioned by the LED sign. This results in a crashing sound being played whenever any of our continuous builds fail, immediately bringing it to the team’s attention.

Of course, I couldn’t stop there. I wanted to build generic interfaces so that the other people in the team could send their own messages the LED sign. I started out with an IRC interface - I made the script into a simplistic IRC bot that could receive commands from our internal IRC network. In the process, I also made it send all messages it displayed to its own IRC channel, so that people that didn’t have the sign in clear view could see the messages on IRC instead. Furthermore, I created a “drop directory” on an NFS server where people could drop files that would be read by the script and displayed. Now, one year later, quite many parts of our development and testing environment hooks into this little script: we get notification of tests currently in progress, test results, when builds are started and completed (or failed), test system load and so on.

In conclusion, while it may not be the end-all-be-all information radiator equipment - only being able to display some 250 characters per message being just one of many limiting factors here - this has anyway been one of the most fun applications of “information radiation” that I’ve seen. :-)