Pogoplug

Playing with the Pogoplug’s LED

The Pogoplug has a LED on the front of the device, which the stock Pogoplug software uses to signify it’s connection status to the Pogoplug service. This post details how to control the colour of the LED!

A reader of this blog, Rick D, left a comment on one of my blog posts a few days ago:

Has anyone found how to control the LEDs? I have Samba running and all is good however when I kill off hbwd ( web connected tunnel to Pogoplug site ) I am left with a flashing LED orange/yellow in color. If you boot to Arch Linux you can see how to control the LEDs …

I didn’t know the answer to this question, but after a little bit of investigative work by Rick D and Brandon H, a solution was found. Awesome!

1. CONTROLLING THE LED

Run the following from the command-line on your Pogoplug to change the colour of the LED.

Set the LED to green:

echo "led=con" > /dev/xce

Set the LED to red:

echo "led=dis" > /dev/xce

Set the LED to orange:

echo "led=err" > /dev/xce

Set the LED to flash:

echo "led=msg" > /dev/xce

2. A BIT OF BACKGROUND

Rick found that the kernel driver responsible for controlling the Pogoplug’s LED is available as an open source package, titled “XCE Linux Kernel Support Driver” and available for download from: http://pogoplug.com/opensource

After a bit of digging around, the “xce_dev.c” file looked like it contained the logic to manipulate the LED.

Brandon found (and documented in this comment) the memory address of the LED, and using devmem2 (a package available via IPKG). This meant that the LED state could be changed by writing values to a particular location in memory, e.g.

devmem2 0xf1010100 w 0x01b18400

will turn the LED green.

Rick then found a way to modify the LED state via the XCE driver. The clue came from “/etc/init.d/hbmgr.sh”, a script responsible for starting the various Pogoplug services, in particular, these lines:

# Make sure watchdog is off…
echowdog=off” > /dev/xce

“wdog=off” appears in the “xce_dev.c” driver file, and looks similar to another block of code in the same file:

    if(strncmp(ploc, "led=", 4)==0) {
      sz-=4;
      ploc+=4;
      if(sz>=3 && strncmp(ploc, "msg", 3)==0) {
        xce_dev_led(LED_MESSAGE);
      } else if(sz>=3 && strncmp(ploc, "con", 3)==0) {
        xce_dev_led(LED_CONNECTED);
      } else if(sz>=3 && strncmp(ploc, "dis", 3)==0) {
        xce_dev_led(LED_DISCONNECTED);
      } else if(sz>=3 && strncmp(ploc, "err", 3)==0) {
        xce_dev_led(LED_ERROR);
      }
    }

And that was it. Echoing “led=” values into the XCE driver changes the state of the LED. Very geeky, and very interesting!

9 Comments

  1. Brandon H

    Now that we have some control over the LED, let’s put it to use!

    Adapted from iostat-based LED blink on ArchLinux at http://obihoernchen.net/wordpress/770/plug_computer_arch_linux/

    Requires: dstat (which also requires Python, but ipkg will install that for on dstat install if necessary)

    This will leave the LED solid green normally and toggle it to solid yellow when there is drive activity, updating every second
    dstat -d 1 | sed -n -e ‘s/.*0.*0.*/@/’ -e ‘s/.*[^@].*/led=err/’ -e ‘s/@/led=con/’ -e ‘w /dev/xce’ &

    This will leave the LED solid green normally and toggle it to solid yellow when there is network activity, updating every second
    dstat -n 1 | sed -n -e ‘s/.*0.*0.*/@/’ -e ‘s/.*[^@].*/led=err/’ -e ‘s/@/led=con/’ -e ‘w /dev/xce’ &

    This will leave the LED solid green normally and toggle it to solid yellow when there is disk or network activity, updating every second
    dstat -dn 1 | sed -n -e ‘s/.*0.*0.*0.*0.*/@/’ -e ‘s/.*[^@].*/led=err/’ -e ‘s/@/led=con/’ -e ‘w /dev/xce’ &

    Note that because dstat uses Python, you’ll need to kill the python process to get it to stop.

    To change the states, change led=con and led=err to something else, as described above.

    To change the update interval, change the 1 before | sed to however many seconds between updates you want to use. Remember that the LED will only be updated on the interval, so if you set it to say, 5 seconds, the LED will hold its previous state for at least 5 seconds.

  2. Pieter

    So do you think it’d be possible to make a script that checks active transmission downloads? If torrents are still downloading => orange blinking, if finished => green?

  3. Brandon H

    Assuming transmission has some method to report its status, you just need to write a cron job or looping script that checks the status and echoes the appropriate led=___ message to /dev/xce

    I don’t use transmission so I don’t know what kind of reporting it provides.

    You could grep for a status then echo “led=msg” to /dev/xce if there’s something downloading, or echo “led=con” to /dev/xce if nothing is happening (sed does this via the -e ‘w /dev/xce’ command at the end).
    Put the above check into a recurring cron job or have it loop (with an appropriate sleep added to control load) and that ought to do it..

    The dstat example I posted is a bit overcomplicated as I replace the zero-activity string with @ as a flag then search for anything not the flag – that’s why there are two expressions (-e ___) fed to sed. My gut still feels like my regex is faulty and the logic is backward, but that was what ended up working. Also dstat provides intermittent output hence the need to have everything piped through sed and sed writing the result on its own. I could have run a single dstat query in a recurring cron job and used simpler logic to test the result too…

  4. Varkey

    Stop playing with the LED’s and start a new project on pogoplug man!

  5. notneeded

    Arch Linux installed on Pogoplug 4-A3.
    I have a issue with the leds. I have the tar.bz2 file for XCE from pogoplug site but have no idea how to install that.
    Can you help me out?