0. Table of Contents |
![]() |
1. 3 fundamental Questions
The Planetlabber is a nifty little piece of Hardware that can remotely control the power switch of other PCs.
Because we wanted a way to be able to operate our Planetlab nodes without having to go there, say for example because we happened to put them in the last dark corner of our wine cellar.
Thou shalt listen to our commands on the parallel port and command your slave machines accordingly
2. What am I made of?
To build the Planetlabber you will need the following parts:
Description | Jameco Part Number | Jameco Price /$ | Jameco Link |
---|---|---|---|
Connector D-SUB, 25P, M | #15114 | 0.99 | link |
Prototype Builder, 1.6"x2.7" | #105099 | 5.25 | link |
Case, ABS Speedy, 3.125"x2.875" | #18921 | 3.15 | link |
Power Supply TRANS,WALL,REG,9VDC/250MA F2 | #190529CJ | 7.15 | link |
You will need on set of the following for each Node controlled | |||
@TRANSISTOR,PN2222A,NPN,SIL,GP,TO-92(10),40Vceo,100@.15A | #178511 | 0.129 | link |
@ RESISTOR,1/4W 5%,2.0K OHM, | #30277 | Bag of 100@0.99 | link |
Relay, DIP, SPST, 5VDC, 1A Cont | #106462 | 2.15 | link |
3. How was I made?
The circuit layout is very easy and looks like this:
4. How do I communicate?
Following standard linux practice we use a very small setuid c-Program to write to the DATA Port and a shell
script to wrap everything else.
The C program looks like this:
Code Listing 4.1: Setuid C-Program "ParPort.c" |
#include <stdio.h> int main(int argc, char **argv){ int fd = fopen("/dev/port",2); fseek(fd,0x378,0); fwrite(fd,1,1,&argc[1]); } |
Code Listing 4.2: compile and set setuid 'root' of "ParPort.c" |
$ gcc -o ParPort ParPort.c $ chown root ParPort $ chmod +s ParPort |
Code Listing 4.3: Shell script "Planetlabber.sh" |
#! /bin/bash # script to trigger the 'Planetlabber' # makes use of ParPort.c # --var section-- # #short timeout (for on) SHORT_TO=1 #long timeout (for off) LONG_TO=4 #set number of remote triggers here NUM=3 #set offset=1 if you skipped the first data-line OFS=0 # ---end var section--- # #set the mask to appropiate dec. value MASK=$(echo "(2^$NUM)-1" | bc) #and now set the byte to the ones we actually want to trigger if given arg2=$2 #second arg zero || greater 8 => set to 255 [[ -z "$arg2" || "$arg2" > 8 ]] && arg2=255 #second arg < 9 => shift bit into right place [[ "$arg2" < 9 ]] && arg2=$((1<<($arg2-1))) #apply mask and shift with offset BYTE=$(( (arg2&MASK) << OFS )) #function that handles both starting and stopping with diff. TO starp() { #pull down all the bits first ./ParPort 0 #then set them ./ParPort $BYTE #wait a while sleep $1 #and pull down again ./ParPort 0 } case "$1" in start) starp $SHORT_TO ;; stop) starp $LONG_TO ;; "" | restart) starp $LONG_TO ;; starp $SHORT_TO ;; *) echo "Usage: ${0##*/} [start|stop|restart] [<num>]"; exit $E_PARAM;; # everything else. esac |
Code Listing 4.4: Save and make Planetlabber.sh executable as follows: |
$ chmod +x Planetlabber.sh |
Code Listing 4.5: Using dd to write 0x1 to par1 |
echo -e '\001' | dd seek=888 of=/dev/port ibs=1 obs=1 count=1 |
Code Listing 4.6: Planetlabber.php |
<html> <head> </html> </head> |
5. What do I look like?