Under The Microscope

Hijacking The RadioSHARK’s lights

For awhile now, I’ve wanted a USB-controllable light, to connect into an automated build system for our projects. The setup would be fairly simple: whenever a change is checked into the source code repository, an automated build (and test) would be triggered. All the projects would be automatically built, and their unit tests would run. If everything was ok, the light would stay off, but if something failed it would turn on. Once something like this is set, knowing the status of the source tree is a simple matter of glancing at the light. This setup isn’t a new idea. In fact, it’s been done many times before, and for things other than software projects.

The hang-up I always ran into with this was finding a USB-controllable light. They make USB toothbrushes, but not USB lights. But then while working on RadioSHARK support for Audio Hijack Pro 2.5, it hit me. The RadioSHARK is a USB-controllable light! It’s a bit expensive to use just as a light bulb, but if you already have one, why not? It even supports does two colors, blue and red. You can get a third color, a weird shade of purple, if you turn both blue and red lights on at once.

So with that problem tackled I moved on to the next one, actually controlling the RadioSHARK’s lights programmatically. For this I just wanted a simple command-line tool that could be invoked from a shell script. And after ripping the USB HID code out of Audio Hijack Pro, that’s what I built. The result is “rslight”, which you can download here. It comes with both the source code, and a pre-compiled binary.

Here’s an examble usage of it:

[proton:~/Desktop/rslight] qdc% ./rslight
Usage: rslight [-b <0-128>] [-r <0 or 128>]
-b Set the blue light brightness, value range is 0 to 128.
-r Set the red light brightness, values are 0 and 128.

rslight controls a radioSHARK's lights

#Turn blue on and red off
rslight -b 128 -r 0
#Turn blue off, and red on
rslight -b 0 -r 128
#Turn blue halfway on, and red on, gives a nice purple
rslight -b 64 -r 128

You’ll note that the Blue light has a fader, so you can set its brightness to anything between 128 (fully on) and 0 (fully off). The Red light only supports on and off. The blue light also supports a “pulse” mode, but it’s kind of useless, so I didn’t bother providing any way of turning it on. Also as stated above, you can turn both lights on at once to get purple.

As for me hooking it up into an automated build system…I never got around to it. One of these days…

Comments for this post have been closed. Thanks for reading!


Our Software