When I think of XML, I usually think of storing data, like customer orders or employee information, and transforming it from one form to another. But I recently ran into a couple of uses for XML that I would not have thought of. Both involve controlling LEDs. The first is BBXML, Darin Franklin’s XML interface for BetaBrite LED signs. These are the LED signs you see all over the place with scrolling messages; I have also heard them referred to as ticker tape signs or Times Square signs. These signs are programmed over an RS-232 connection using an arcane protocol that is not very convenient to work with. For example, if you wanted to display “THE XML ADVENTURE” on the sign, you would send it an ASCII string like this: _01Z00_02A0THE XML ADVENTURE_04 The meaning of the characters is as follows:

  • _01 – Start Of Header.
  • Z – Type of sign. “Z” means “all types”.
  • 00 – Address of sign. “00” means broadcast to all signs.
  • _02 – Start Of Text.
  • A – Write TEXT file.
  • 0 – Message area. “0” means priority text message.
  • THE XML ADVENTURE – The text of the message.
  • _04 – End Of Transmission.

Using BBXML, you can express the message in XML, like this:

   <text label="0">THE XML ADVENTURE</text>

All the processing in BBXML is done in the alphasign.xsl XML stylesheet. So if you had the above XML in a file called commands.xml, you would just issue this command to convert the XML to the protocol required by the BetaBrite sign:

xsltproc alphasign.xsl commands.xml > commands.txt

(xsltproc is the XSLT processor from the libxslt package for Unix/Linux. If you are using a different processor you would modify the command accordingly.) Once the XML is converted to the BetaBrite protocol, it can be sent to the sign with the Unix/Linix cat command:

cat commands.txt > /dev/betabrite

(On Windows, you would copy it to a COM port.)

BBXML would be particularly useful if you have data that you need to publish in several places, perhaps in a PDF file, on a website, and, in abbreviated form, on a BetaBrite sign. The information would start out as an XML file, with different XML stylesheets to tailor it to the various output media. The output of the stylesheet for BetaBrite signs would then be fed to BBXML. The BBXML website has an excellent user’s guide for BBXML, which tells you pretty much everything you need to know about using BBXML with BetaBrite RS-232-based signs.

More recent BetaBrite signs are USB-based, and I have not yet found a driver (for Unix/Linux or Windows) that allows you to copy data directly to the sign. As soon as such a driver is found, BBXML will work with USB-based signs, too.

The second application comes from Front2BackDev, one of my favorite XQuery blogs. It uses XQuery and a MarkLogic server to control Phillips Hue LED light bulbs. These light bulbs have a controller that hooks up to your network, and communicates with the bulbs over the power wiring. It makes it possible to set each light individually to a particular color and brightness. Phillips has apps for Androids and iPhones, but the controller also has a REST-based API. The example at Front2BackDev uses XQuery to call this API and step all the lights in the house through a list of colors. This could be enhanced to do all sorts of interesting things, like adjusting the lights in the house for different ambiance at different house of the day, or controlling lights being used as information radiators in Continuous Integration systems. In a later post at Front2BackDev, they used this in conjunction with geofences defined in Google maps. An app on a smartphone would send its GPS coördinates to a Marklogic server, which would figure out where in the geofences the phone was, and change the color of all the lights in the house accordingly.


Leave a Reply

Your email address will not be published. Required fields are marked *