Logo

Boxee Logo

The Boxee Box uses a PIC MCU (PIC24FJ64GA004-I/PT) attached to /dev/ttyS1 to control the light-up Boxee logo on the front of the device.

Except for error sequences, it seems the majority of the commands are sent by a program, 'dtool' (/opt/local/bin/dtool), to a daemon called 'sysd' (/bin/sysd) via '/tmp/sysdsock'.

Changing the LED Color and Brightness

Using dtool

The Boxee Box comes pre-installed with a program called <tt>dtool</tt>, which, among other things, can control the LED lights behind the front logo.

To use dtool, first connect to the Boxee Box using [[TelnetD|Telnet]] or [[Dropbear|Dropbear SSH]]. Once you're connected, try the <tt>dtool</tt> command by itself to see its instructions.

dtool

As you will see, dtool has 6 commands you can pass to it, and the one used to control the LED lights is #6.

dtool 6 <LED number> <step or jump flag> <brightness percentage>

The red LED is LED #1, and the green LED is LED #2.

If the step or jump flag is set to 1, the setting you choose will fade gradually. If set to 0, the change will be instantaneous.

Here are some examples:

dtool 6 1 0 0      # Turn off the red LED instantly.
 dtool 6 2 0 0      # Turn off the green LED instantly.
 dtool 6 1 1 100    # Turn up the red LED all the way, gradually.
 dtool 6 2 1 100    # Turn up the green LED all the way, gradually. Now you have yellow!
 dtool 6 2 1 50     # Turn down the green LED halfway, gradually. Now you have orange!
 dtool 6 1 1 0      # Turn off the red LED, gradually. Now you have a soft green!

Using printf

Here are a few raw commands (some taken from /sbin/init in initrd):

  • Turn logo off:
 printf "\xAA\x06\x35\x30\x30\x33\x30\x30\x35\x33" > /dev/ttyS1
  • Turn logo red:
 printf "\xAA\x06\x35\x30\x30\x33\x30\x30\x35\x33" > /dev/ttyS1
 printf "\xAA\x06\x35\x30\x30\x31\x36\x34\x42\x35" > /dev/ttyS1
  • Turn logo green:
 printf "\xAA\x06\x35\x30\x30\x33\x30\x30\x35\x33" > /dev/ttyS1
 printf "\xAA\x06\x35\x30\x30\x32\x36\x34\x42\x36" > /dev/ttyS1
  • Turn logo yellow:
 printf "\xAA\x06\x35\x30\x30\x33\x30\x30\x35\x33" > /dev/ttyS1
 printf "\xAA\x06\x35\x30\x30\x31\x36\x34\x42\x35" > /dev/ttyS1
 printf "\xAA\x06\x35\x30\x30\x32\x36\x34\x42\x36" > /dev/ttyS1
  • Turn logo yellow (Alternate method):
 printf "\xAA\x06\x35\x30\x30\x33\x30\x30\x35\x33" > /dev/ttyS1
 printf "\xAA\x06\x35\x30\x30\x33\x36\x34\x42\x37" > /dev/ttyS1
  • Dim green led
 printf "\xaa\x08\x35\x30\x30\x32\x34\x42\x30\x33\x41\x30" > /dev/ttyS1
  • Brighten green led
 printf "\xaa\x08\x35\x30\x30\x32\x30\x33\x34\x42\x41\x30" > /dev/ttyS1
  • Fun example (may void warranty):
while true; do
    aplay /opt/boxee/skin/boxee/sounds/nav.wav
    aplay /opt/boxee/skin/boxee/sounds/nav.wav
    printf "\xAA\x06\x35\x30\x30\x33\x30\x30\x35\x33" > /dev/ttyS1
    printf "\xAA\x06\x35\x30\x30\x31\x36\x34\x42\x35" > /dev/ttyS1
    usleep 250000
    printf "\xAA\x06\x35\x30\x30\x33\x30\x30\x35\x33" > /dev/ttyS1
    printf "\xAA\x06\x35\x30\x30\x32\x36\x34\x42\x36" > /dev/ttyS1
    aplay /opt/boxee/skin/boxee/sounds/select.wav
    usleep 250000
    printf "\xAA\x06\x35\x30\x30\x31\x36\x34\x42\x35" > /dev/ttyS1
    usleep 250000
done

Serial Protocol

This is approximately how the serial commands are generated (for LED):

Command hierarchy:

/opt/local/bin/dtool -> 'plaintext' -> /tmp/dsock -> /bin/sysd -> 'encoded' -> /tmp/ttyS1

Command structure:

(1byte) header     -> 'AA'
(1byte) length     -> '08' or '06', number of following bytes (excluding 2byte checksum)
(2byte) command    -> '80', for led
(2byte) led        -> '3031', '3032', or '3033', for green, red, or both
(2byte) orig value -> '3030' through '3634', for 0-100
(2byte) new value  -> '3030' through '3634', for 0-100
(2byte) checksum   -> derived by adding numerical values of command, led, orig, and new

Using this as a basis, here is how to turn both leds to 100% on at once (which dtool won't do):

printf "\xAA\x06\x35\x30\x30\x33\x36\x34\x42\x37" > /dev/ttyS1

header | length |  cmd |  led | orig |  new | csum
    AA |     06 | 3530 | 3033 |      | 3634 | 4237 (encoded in ascii)
       |        |   50 |   03 |      |   64 |   B7 (encoded in hex)
       |        |   80 +    3 +         100 =  183 (decimal)

More examples:

/opt/local/bin/dtool 6 2 1 0 100 -> 'Set LED1 True 0 100'

header | length |  cmd |  led | orig |  new | csum
    AA |     08 | 3530 | 3031 | 3634 | 3030 | 4235 (encoded in ascii)
       |        |   50 |   01 |   64 |   00 |   B5 (encoded in hex)
       |        |   80 +    1 +  100 +    0 =  181 (decimal)
/opt/local/bin/dtool 6 1 1 50 0 -> 'Set LED2 True 50 0'

header | length |  cmd |  led | orig |  new | csum
    AA |     08 | 3530 | 3032 | 3030 | 3332 | 3834 (encoded in ascii)
       |        |   50 |   02 |   00 |   32 |   84 (encoded in hex)
       |        |   80 +    2 +    0 +   50 =  132 (decimal)
/opt/local/bin/dtool 6 1 1 75 3 -> 'Set LED2 True 75 3'

header | length |  cmd |  led | orig |  new | csum
    AA |     08 | 3530 | 3032 | 3033 | 3442 | 4130 (encoded in ascii)
       |        |   50 |   02 |   03 |   4B |   A0 (encoded in hex)
       |        |   80 +    2 +    3 +   75 =  160 (decimal)

XBMC4XBOX status LED behavior

For the programmers out there: XBMC4XBOX has the ability to cycle the status LED on the front of the machine (and intelligently disable it entirely during media playback). When XBMC Media Center gets ported to Boxee Box, it would be awesome to incorporate this functionality!

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License