May 06, 2013

Controlling LED on front of Pogoplug V2

I've recently been looking for some sort of network storage solution. My requirements were that it should be very flexible, both in terms of what it can be made to do and storage expandability, be easy to backup to something I can take off site, low power usage, low set up cost. I ended up buying a couple of Western Digital 2TB USB drives and attaching them to Pogoplug V2 that I found for sale on Amazon from a third party which I then made run Arch Linux ARM The V2 is a bit old now, the Pogoplug devices are currently on the fourth generation, but everything I read (e.g. http://fortysomethinggeek.blogspot.co.uk/2013/03/pogoplug-series-4-archlinux-review.html) indicated that the V2 is actually better for my purposes. The V4 has USB 3 ports compare to the USB 2 ports on the V2, but it negates the advantage by having a weaker CPU and fewer ports.

Anyway, the Pogoplug V2 (mine is actually black) has an LED illuminated logo on the front and it's possible to control that from within the Arch install. So I wrote I couple of scripts to do that.

One of them can be used to set or save the current colour and restore a saved colour.

#!/bin/bash

# /usr/local/bin/ledcolour

# n.b. blue is actually orange
trigger_green=/sys/class/leds/status\:green\:health/trigger
trigger_orange=/sys/class/leds/status\:blue\:health/trigger

save_green="/tmp/$(basename $0)_save_green"
save_orange="/tmp/$(basename $0)_save_orange"

if [ ! -w "${trigger_green}" ];then
echo "trigger files are not writable or do not exist. try as root"
exit 1
fi

if [ -z "${1}" ];then
echo "Usage: $(basename $0) colour|save|restore"
echo "Examples:"
echo "$(basename $0) green"
echo "$(basename $0) yellow"
echo "$(basename $0) orange"
echo "$(basename $0) off"
echo
echo "Save current led state with"
echo "$(basename $0) save"
echo "and restore it later with"
echo "$(basename $0) restore"
exit 1;
fi

case $1 in
"green" )
echo default-on > "${trigger_green}";
echo none > "${trigger_orange}";
;;
"orange" )
echo none > "${trigger_green}";
echo default-on > "${trigger_orange}";
;;
"yellow" )
echo default-on > "${trigger_green}";
echo default-on > "${trigger_orange}";
;;
"off" )
echo none > "${trigger_green}";
echo none > "${trigger_orange}";
;;
"save" )
grep -o '\[.*\]' "${trigger_orange}" | sed 's/\[//;s/\]//' > "${save_orange}";
grep -o '\[.*\]' "${trigger_green}" | sed 's/\[//;s/\]//' > "${save_green}";
;;
"restore" )
cat "${save_green}" > "${trigger_green}";
cat "${save_orange}" > "${trigger_orange}";
;;
esac


The other can be used to flash between off and a specified colour or cycle through a sequence of colours. It allows specifying the duration for each colour and the number of iterations.

#!/bin/bash

# /usr/local/bin/ledflash

# save current led state
ledcolour save

# restore that state on script exit
trap "ledcolour restore" EXIT

if [ -z "${1}" ];then
echo "Usage: $(basename $0) colour[,colour[,colour]] [interval] [iterations]"
echo "Examples:"
echo "Flash green for ever with default interval:"
echo "$(basename $0) green"
echo "Flash green for ever with interval of 0.5 seconds:"
echo "$(basename $0) green 0.5"
echo "Flash green and yellow for ever with interval of 0.5 seconds:"
echo "$(basename $0) green,yellow 0.5"
echo "Flash green yellow orange five times with interval of 5 seconds:"
echo "$(basename $0) green,yellow,orange 5 5"
exit 1;
fi

p=1;
test -n "${2}" && p=$2

iterations=0
test -n "${3}" && iterations=$3

OIFS=$IFS
IFS=,
colourarray=($1)
IFS=$OIFS

if [ ${#colourarray[@]} = 1 ];then
colourarray[${#colourarray[*]}]='off';
fi

flipon=${#colourarray[@]}
flipcount=0;

loopcount=0;
while true;do
ledcolour ${colourarray[flipcount]};
sleep $p;
((flipcount++))
if [ $flipcount -eq $flipon ];then
flipcount=0
((loopcount++))
test $loopcount -eq $iterations && exit;
fi
done

Edit: forgot to say, there is a file called brightness in the directory along with the trigger file and a max_brightness file that suggests the brightness file takes a value up to 255. Sadly no matter what value I put in the brightness file, the brightness of the LED(s) did not change. I couldn't find any information about controlling the brightness. Which is a shame. I was hoping to write a script to mimic the pulsing power LED of a sleeping Mac.


April 23, 2013

Sticks will still not detect bombs

Follow-up to A stick will not detect a bomb. from Mike's blag

James McCormick guilty of selling fake bomb detectors:

http://www.bbc.co.uk/news/uk-22266051


March 09, 2013

Webcam timelapse – January 2013 and February 2013

Follow-up to Webcam timelapse – Monday 10th December 2012 – Sunday 16th December 2012 from Mike's blag

This time, entire months. As before, images grabbed from webcam once per minute. Videos are made at 48 images per second.


January 2013. If you want to see snow skip to 6:00. There's several instances of snow. You can also see the snow hangs around for ages on the roof on the far right.



February 2013.



February 14, 2013

B–em

Follow-up to BBC Computer 32K, Acorn DFS, BASIC from Mike's blag

So I found a better BBC Emulator than BeebEm. It's called B-em. Why is it better?

  • It was last updated about a year ago rather than about 5 years ago. Newer is better, right? Sure it is.
  • It allows easy modification of the keyboard layout, including a menu option to remap A/S to Caps Lock/Ctrl which makes playing Arcadians practical. This is nicer than mucking around with setting an environment variable for SDL to make Caps Lock work like a regular key and using xmodmap to remap keys, which is how I made Arcadians playable with BeebEM.
  • It makes disk-drive like noises when you run disks.
  • Probably other... things... maybe...

I run it on SLED 11 SP2. If you want to do likewise, here's how.

If you don't already have it, get the SLE-SDK from http://download.novell.com/Download?buildid=NgW3ToaagDQ~ and use YaST to add it as an Add on Product.

Install the following packages: cmake zlib-devel libpng-devel libjpeg-devel xorg-x11-libX11-devel libogg-devel freetype2-devel libpulse-devel alsa-devel flac-devel libvorbis-devel alsa-oss automake gcc make gcc-c++

Then, as a regular user, run these commands:

$ cd
$ mkdir b-em
$ cd b-em
$ export PKG_CONFIG_PATH=${PWD}/lib/pkgconfig/
$ export PATH=$PATH:${PWD}/bin
$ export LD_LIBRARY_PATH=${PWD}/lib
$ export LIBS="-L${PWD}/lib"
$ export CPPFLAGS="-I${PWD}/include"
$ curl -L http://sourceforge.net/projects/alleg/files/allegro/4.4.2/allegro-4.4.2.tar.gz/download | tar zxvf -
$ cd allegro-4.4.2/
$ mkdir build
$ cd build
$ cmake -DWANT_LINUX_CONSOLE=on -DCMAKE_INSTALL_PREFIX:PATH=$(dirname $(dirname $PWD)) ..
$ make install
$ cd ../..
$ curl http://kcat.strangesoft.net/openal-releases/openal-soft-1.15.1.tar.bz2 | tar jxvf -
$ cd openal-soft-1.15.1/build
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=$(dirname $(dirname $PWD)) ..
$ make install
$ cd ../..
$ curl http://connect.creativelabs.com/openal/Downloads/ALUT/freealut-1.1.0.tar.gz | tar xzvf -
$ cd freealut-1.1.0/
$ ./configure --prefix=$(dirname "${PWD}") && make && make install
$ cd ..
$ curl -L http://b-em.bbcmicro.com/B-emv2.2Linux.tar.gz | tar xvfz -
$ for i in INSTALL depcomp COPYING compile;do unlink $i; ln -s /usr/share/automake-1.10/$i;done
$ ./configure --prefix=${PWD} && make
$ mv b-em b-em.real
$ cat > b-em << EOF
#!/bin/bash
dir="$( cd "$( dirname "$0" )" && pwd )";
export LD_LIBRARY_PATH="${dir}/lib";
cd "${dir}"
./b-em.real
EOF
$ chmod u+x b-em


Grab the images for your favourite games from somewhere such as Stairway to Hell and run the b-em executable

$ ~/b-em/b-em

F11 shows/hides the menu. Once you've loaded a disk you need to hide the menu again and press Shift-F12 to run it.

Obligatory screenshot:

Arcadians running on B-em

The trick to maximum points in Arcadians is to only shoot the aliens whilst they're swooping down. You get double the points for picking them off whilst they're in motion.


January 28, 2013

(=75D96–O9&4`

M8V]N9W)A='5L871I;VYS+"!Y;W4@87)E(&]L9"!E;F]U9V@@=&\@<F5M96UB
M97(@=VAE;B!U=65N8V]D:6YG(&%N9"!U=61E8V]D:6YG(&9I;&5S('=A<R!A
2('1H:6YG('!E;W!L92!D:60*
`


January 24, 2013

Intriguing square pattern in snow

This is what the snow on the paving slabs in my garden looked like yesterday morning (click to embiggen):

Snow squares on paving slabs.

I figure it's caused either by aliens or physics. Are you an alien? Are you a physicist or other type of scientist? Can you explain why how this pattern comes about?


January 13, 2013

Useless visualisation of data – logins.

Sometimes I like to see if I turn a bunch of data in to some sort of image. Not an image that's in any way useful for comprehending the data though. Just because.

Each square is one of 100000 instances of someone logging in to a computer (click to embiggen):

100000 logins

The position on the x axis represents the hour and minute at which the login occurred. Position on y axis is the seconds. The colour of each square is a function of the date, month and the IP address of the computer.

Each square is added to the image individually, placed over the top of whatever is already there. The opacity of each square is 50% and the blending method is Imagemagick's ModulusAdd. (The very first run I used 'Plus' and was briefly puzzled by the result being all white :) )


January 03, 2013

Handbrake on SLED 11 SP2 revisited

Follow-up to Handbrake on SLED 11 SP2 from Mike's blag

I decided to figure out what needed to be done to build the currently current version of Handbrake, 0.9.8, on SLED 11 SP2.

If you don't already have it, get the SLE-SDK from http://download.novell.com/Download?buildid=NgW3ToaagDQ~ and use YaST to add it as an Add on Product.

Install these packages: doxygen yasm patch autoconf automake libbz2-devel libwebkit-devel libnotify-devel libgudev-1_0-devel gstreamer-0_10-plugins-base-devel dbus-1-glib-devel libtool gcc gcc-c++ intltool gtk2-devel glib2-devel zlib-devel libogg-devel

Then run the following commands. hbinstdir is where Handbrake gets installed to, change the value if you want. You can omit the lines relating to libdvdcss if you already have that installed somewhere Handbrake will find it, or if you don't want to be able to rip any DVDs that use CSS.

$ hbinstdir=/local/myapps/handbrake/
$ mkdir handbrakebuild
$ cd handbrakebuild
$ curl http://ftp.gnu.org/gnu/automake/automake-1.12.tar.gz | tar xvfz -
$ cd automake-1.12/
$ ./configure --prefix="${hbinstdir}" && make && make install
$ cd "${hbinstdir}"share/aclocal
$ for i in /usr/share/aclocal/*;do ln -s $i;done
$ cd -
$ cd ..
$ curl http://fribidi.org/download/fribidi-0.19.5.tar.bz2 | tar xvfj -
$ cd fribidi-0.19.5/
$ ./configure --prefix="${hbinstdir}" && make && make install
$ cd ..
$ curl http://download.videolan.org/pub/libdvdcss/1.2.12/libdvdcss-1.2.12.tar.bz2 | tar xvfj -
$ cd libdvdcss-1.2.12/
$ ./configure --prefix="${hbinstdir}" && make && make install
$ cd ..
$ export PATH="${hbinstdir}bin:${PATH}"
$ export FRIBIDI_LIBS="-L${hbinstdir}lib/ -lfribidi"
$ export FRIBIDI_CFLAGS="-I${hbinstdir}include/"
$ export LDFLAGS="-L${hbinstdir}lib/ -lfribidi"
$ curl -L "http://downloads.sourceforge.net/project/handbrake/0.9.8/HandBrake-0.9.8.tar.bz2?r=http%3A%2F%2Fhandbrake.fr%2Fdownloads.php&ts=1356991772&use_mirror=garr" | tar xvfj -
$ cd HandBrake-0.9.8
$ sed -i 's/autoreconf -I m4 -fiv/sh autogen.sh/' contrib/libvorbis/module.defs
$ ./configure --prefix="${hbinstdir}" --launch --launch-jobs=0 --verbose

Assuming the build process finishes without errors then install

$ cd build && make install

The binaries have been compiled against fribidi-0.19.5 but they're dynamically linked. So if you have the version of fribidi that's included with SLED installed the binaries will find and use that by default. If you don't have fribidi installed, they'll be looking for something that doesn't exist. So to make the binaries look at the right version of fribidi they need to be run in a wrapper

$ cd "${hbinstdir}/bin"
$ mv ghb ghb.real
$ mv HandBrakeCLI HandBrakeCLI.real
$ cat > ghb << EOF
#!/bin/bash
dir="\$(dirname "\$( cd "\$( dirname "\$0" )" && pwd )")"
PATH="\${dir}/bin:\${PATH}"
LD_LIBRARY_PATH="\${dir}/lib"
ghb.real
EOF
$ chmod u+x ghb
$ cat > HandBrakeCLI << EOF
#!/bin/bash
dir="\$(dirname "\$( cd "\$( dirname "\$0" )" && pwd )")"
PATH="\${dir}/bin:\${PATH}"
LD_LIBRARY_PATH="\${dir}/lib"
HandBrakeCLI.real
EOF
$ chmod u+x HandBrakeCLI

Run Handbrake with

$ /replace_with_whatever_you_set_hbinstdir_to/bin/ghb

The tweak to libvorbis/module.defs comes from http://benjisimon.blogspot.co.uk/2012/04/gotcha-of-day-building-handbrake-on.html

Initially I used LIBRARY_PATH=${hbinstdir}lib/ instead of LDFLAGS but system locations are searched before anything specified in LIBRARY_PATH and if you have fribidi-devel installed that's found first and the Handbrake build fails.

I also initially used export PKG_CONFIG_PATH="${hbinstdir}/lib/pkgconfig/" instead of FRIBIDI_CFLAGS and FRIBIDI_LIBS but the Handbrake build process was still finding the system version. I eventually realised the Handbrake build process sets it's own value for PKG_CONFIG_PATH which overwrites anything you've set.



December 31, 2012

Converting FLAC to AAC/M4A

I found myself wanting to convert some audio files that were encoded with FLAC to AAC/M4A that iTunes can understand. Conversion using ffmpeg is easy enough but I couldn't find a way to make ffmpeg copy the artwork that's embedded in the FLAC files. So I ended up using atomicparsley as well.

$ for i in *flac;do of="${i/.flac/.m4a}";af=foo.jpg;ffmpeg -i "${i}" -y "${af}"; ffmpeg -i "${i}" -vn -acodec libfaac -aq 320k -f mp4 -y "${of}";atomicparsley "${of}" --artwork "${af}" --overWrite;rm -f "${af}";done

I had to tell ffmpeg to force the mp4 container otherwise atomicparsley wouldn't process the resulting file.


December 20, 2012

Webcam timelapse – Monday 10th December 2012 – Sunday 16th December 2012

Follow-up to Webcam timelapse – Friday 7th December 2012. from Mike's blag

Same deal as before but this time it's of an entire week and they've been optimised for streaming, so they'll start playing back straight away rather than you having to wait for your web browser to download the whole thing. Depending on your patience there's three versions, presented here in decreasing duration.

10 images per second, duration approx 16:38


24 images per second, duration approx 6:56


48 images per second (y'know, like Peter Jackson did for The Hobbit. Only without being anything like that at all), duration approx 3:28


I've just realised these videos don't play in Firefox on my Linux machine. I can play the videos on my Linux machine, (I made them on my Linux machine), just not in Firefox. Lack of H264 decoding capability I guess, which I would guess means they won't work on Firefox on Windows either. I'm not curious enough to boot Windows and find out. The day long video was made on and posted from my Mac, on which Firefox happily plays back the videos, but my Mac is old and ffmpeg only manages to encode the videos at about 2fps. So I built ffmpeg with libx264 support on my not-as-old Linux machine to encode the week long ones in a sensible time. I guess I could upload an flv fallback video. But that would mean making such a thing and I can't be bothered, at least not right now.

Edit: They do play on another Linux machine of mine with Firefox and Totem plugin. Totem uses gstreamer and on the machine in question there's a gstreamer plugin that supports H264.


Search this blog

Tags

RSS2.0 Atom
Not signed in
Sign in

Powered by BlogBuilder
© MMXVII