Friday 27 June 2008

Squeezebox Duet: What's in the box?

I've had my Squeezebox Duet at home for quite some time now, since I was experimenting with using a slug as a home media server. I've been waiting for my replacement for the slug for some time now and it's still not arrived so the home media server project has stalled somewhat at the moment. However, I do still have the Squeezebox set up and even though I'm not really using it right now here's what you get in the box when you buy one...

The packaging feels very nice indeed, as it should along with the rest of the stuff in the box given the price if I'm honest. Once you slide the box out of it's card sleeve you're faced with a rather sleek minimal looking flip top black box:


The next thing is to flip that lid up and you see a very neatly laid out set of Squeezebox gear which I've positioned after a little unpacking:


So in the box we have a whole array of different stuff. There is, of course, the squeezebox remote and the receiver boxes, these are powered via some reasonably small AC-DC transformers which have changeable plugs. Plugs are supplied for European, US and UK sockets so you don't have to worry about getting a localised unit for your area which is a neat trick. The remote control has a charging stand so you can return it to its cradle when you're finished using it and it will stay charged all the time. You also get a set of reasonable length RCA leads to connect the receiver to your amplifier. Last, you get a fairly minimal manual which I've hardly used as all the best documentation is on-line:


Setting up really is very trivial, it's just a case of connecting all the wires, so power to the receiver and the remote charging stand, and a connection from the receiver to the amplifier. Once you've done this, just permit access by the two wireless devices (the receiver and the remote are both wi-fi) to your access point. Both devices DHCP and you're up and running with a squeezebox duet, nice and simple. This does, however, only get you Internet provided services if you want to get the full benefit of streaming your own music collection you need the Squeeze Centre software too, and hence I'm still waiting for my media server to be delivered before I get full functionality from my Squeezebox.

Wednesday 18 June 2008

New Thinkpad T61p

Gutted! A couple of weeks ago now I had a bad Friday, the train home from London where I'd been working with a customer all day was stupidly late and I had to change twice instead of going directly home. Then I get home and fire up my laptop to send the e-mail's I'd written during the day and the darned thing didn't work, argh! Seems in spite of working all day, my T41p had died on the trip home. After reporting the problem at work the following Monday it was decided the T41p needed a new motherboard and this wasn't economical to fix, so I was issued with a shiny new T61p a few days later.


I've been pleasantly surprised by my new laptop, I wasn't expecting great things since IBM sold the Thinkpad business to Lenovo but this thing is actually quite nice. I'll spare listing the full gory details to the technical specifications page. However, it has some nice additions over my previous laptop, namely built-in firewire (not that I'm likely to use it), built-in SD card reader (used that already), an extra USB port (always handy), a DVD writer, a hardware wireless off switch (presumably for use in planes), an enormous hard disk (compared to the T41p anyway), and a lovely 15.4" widescreen capable of 1920x1200 backed by a 256MB NVidia graphics card.

Unfortunately, it came pre-installed with Vista so that (along with the stupid Vista sticker next to the keyboard) were the first things to go. I've installed Redhat Enterprise Workstation 5.2 on it which may sound like an odd choice, but IBM have a layer of software designed to sit on top of Redhat to enable us to install things like Lotus Notes, Sametime, etc. This is known as the Open Client internally and works really nicely. Clearly, there are later and greater distributions I could use but on this issue I like to support IBM and the internal community of Linux desktop users so I choose to go with the officially provided solution.

I've been up and running for a week now with no problems so far, I've been able to do all the things I could do with my old laptop and all the things I need to be able to do in order to do my job. Of course, I make some modifications to the way things work to suit my tastes (such as running KDE instead of Gnome) but all these work well too which is a great reflection on the modular nature of all things involved with Linux. I hope I continue to be surprised and pleased with the machine, and I'm definitely surprised at the ease of transition between the two machines for me.

Thursday 12 June 2008

Google Treasure Hunt Question 4

Question 4 has been out for a while now and it's taken me a while to blog the solution for a couple of reasons, I've not had much time to work out the solution recently, and this question seems a lot more difficult than the other three (for me at least).

Here's my question this time around:
Find the smallest number that can be expressed as
the sum of 25 consecutive prime numbers,
the sum of 99 consecutive prime numbers,
the sum of 189 consecutive prime numbers,
the sum of 467 consecutive prime numbers,
the sum of 535 consecutive prime numbers,
and is itself a prime number.

For example, 41 is the smallest prime number that can be expressed as
the sum of 3 consecutive primes (11 + 13 + 17 = 41) and
the sum of 6 consecutive primes (2 + 3 + 5 + 7 + 11 + 13 = 41).


First of all I thought I'd write a routine (once again in Perl) to generate prime numbers. I know I'm not entering a competition to find the worlds largest primes so chose to write an optimised solution rather than a super efficient one. The difference here is computational complexity v coding complexity. I chose the simpler code but less efficient solution rather than the more complicated code but efficient solutions offered by algorithms such as the Sieve of Eratosthenes.

sub primes {
my $max = shift || 10;
my @primes = ( 2, 3, 5, 7 );
return @primes if ($max <= 9);
my $loop = 9;
while (scalar(@primes) < $max) {
my $is_prime = 1;
for (my $div = 3; $div < ($loop-1)/2; $div++) {
$is_prime = 0 if ($loop % $div == 0);
}
push (@primes,$loop) if ($is_prime);
$loop += 2;
}
return @primes;
}


Now I had a way of populating an array with prime numbers I thought about the solution a bit more carefully and decided it wasn't likely to be simple to calculate, however long the code I managed to write was. So, I decided to search around for lists of prime numbers and decided to use a list of the first million primes. I could, on reflection, just used my routine to generate 1 million primes and written them to a file instead of generating each time.

The solution I came up with is shown below. It starts by populating an array with the first million primes from the downloaded file. Then the sums of the required continuous number of primes are generated and stored in another array. At this early stage, the solution is now contained in this array (with the assumption the solution exists within the first one million primes of course) so it's just a case of searching the array to find it. In order to find the number, I numerically sort the list. Now it's a simple case of finding the first (and therefore lowest) prime in the new list that is repeated 5 times.

use strict;
use FileHandle;

sub sum_primes {
my $amount = shift;
my $start = 0;
my @sums;

while ($amount < scalar(@_)) {
my $sum = 0;
for (my $i = $start; $i < $amount; $i++) {
$sum += $_[$i];
}
push(@sums,$sum);
$start++;
$amount++;
}
return @sums;
}

sub read_primes {
my $filename = shift;
my $fh = new FileHandle;
$fh->open($filename) || die "$filename: $!\n";
my @primes;
push(@primes,split) while (<$fh>);
$fh->close();
return @primes;
}

sub is_prime {
my $num = shift;
foreach my $prime (@_) {
return 1 if ($num == $prime);
}
return 0;
}

my @primes = read_primes("1000000.txt");
my @sum_list;
push(@sum_list, sum_primes(25,@primes));
push(@sum_list, sum_primes(99,@primes));
push(@sum_list, sum_primes(189,@primes));
push(@sum_list, sum_primes(467,@primes));
push(@sum_list, sum_primes(535,@primes));
@sum_list = sort(@sum_list);
my $prev = 0;
my $same = 0;
foreach my $num (@sum_list) {
if ($num == $prev) {
$same++;
if ($same == 4) {
print "Found $num, checking... ";
if (is_prime($num,@primes)) {
print "PRIME! :-)\n";;
last;
} else {
print "not prime :-(\n";
$same = 0;
}
}
} else {
$same = 0;
}
$prev = $num;
}


This code takes a few minutes to run. I'm sure it's not the smartest solution to the problem, there must be some maths I can use to calculate a solution. Instead, this approach turns the problem into a search solution but it works pretty well and identified the correct answer of 6990493 for my question.

Tuesday 3 June 2008

Showing Off Linux

Thanks to Ian Hughes for the picture on his flickr. Yesterday, at work, the Hursley Linux Special Interest Group ran a little trade show type event for a couple of hours after lunch. The idea was to provide a bit of away from your desk time for folks around the lab to see what we Linux geeks have been getting up to. Various people interested in using Linux inside and outside work came along to demo their gadgets.

The picture shows me showing off my old Linux audio centre. But, also at the event were the main organiser of the day Jon Levell (showing Fedora 9 and an eeepc), and Nick O'Leary (showing his N800 and various arduino gadgets), Gareth Jones (showing his accelerometer based USB rocket launcher and bluetooth tweetjects), Andy Stanford-Clark (showing his NSLU2 driven house, and an OLPC), Laura Cowen (showing an OLPC), Steve Godwin (showing MythTV), and Chris law (showing Amora).

I thought it was quite a nice little selection of Linux related stuff to look through for the masses of people turning up, plenty of other things we could have shown too of course. The afternoon seemed very much a success, generating some real interest in the various demo items and lots of interesting questions too. Thanks to everyone for taking part!

Saturday 31 May 2008

SqueezeCenter on the SLUG

At first glance, installing slimserver (now SqueezeCenter) on the SLUG is very straight forward as it's nicely packaged into an ipkg and made available via Optware. However, as indicated on the slimserver application page on the nslu2-linux wiki, things aren't as simple as they first appear. Unfortunately, something is very broken with slimserver and its dependency chain in Optware as things stand at this moment in time. As a result installing slimserver with a view to upgrading to squeezecenter at a later date becomes much more problematic. I need at least SqueezeCenter version 7.0 to operate with the SqueezeBox Duet.

My first target was to run slimserver 6.5.4 which is the latest version from the version 6 line and the version packaged for the SLUG in optware. I tracked the problem down to the mysql dependency for slimserver, it seems since the last update of slimserver in optware, mysql has also been updated and since that time slimserver has been reported as broken on the SLUG. Unfortunately, rolling back versions in optware is not trivial since they only make available the latest version with no access to previously packaged programs. My only option was to check out the mysql build environment from SVN at the previous level and compile up the package from source. This is reported to take in the region of 18 hours natively on the SLUG so I set up a cross-compilation environment on my Fedora 8 box at home. MySQL compiled in about 10-15 minutes and I now had a package to install. The reports were correct, slimserver 6.5.4 was now running on my SLUG, excellent!

The next challenge was to get SqueezeCenter running, and this worked in a similar way to getting slimserver going. There are a few oddities with getting all your ducks in a row while running this stuff on a SLUG, SqueezeCenter is very particular about file permissions, and the newer software introduces a whole bunch of Perl dependencies not present in the earlier slimserver versions. Fortunately, I'm very familiar with Perl as well as Linux (one of the reasons for choosing a squeezebox) and I've managed to compile up the minimum dependencies to get SqueezeCenter going. It seems Slim Devices as a company test against x86 and PPC architectures to the extent they even supply their Perl dependencies for these from CPAN. I'm running on ARM on the SLUG though which introduces a whole world of dependency problems as it seems SqueezeCenter is also pretty sensitive to the version of each Perl module used, it's not just a case of grabbing the latest and greatest from CPAN, a further bind for getting it going nicely. One other thing, CPAN doesn't seem to run at all well on the SLUG, it's far faster to download the tarred packages and compile manually!

I eventually got SqueezeCenter 7.0.1 running on the SLUG, it consumes at least twice the 32MB RAM available so runs pretty slowly while spending a lot of time paging to the USB disk. I set up an additional swap file on disk as well, thinking about it perhaps I should have used the rest of the 8MB flash as swap too! All in all, running SqueezeCenter on a machine with so little memory and on an architecture not supported by Slim Devices has equated to a slow response time and a maintenance headache.

In conclusion, it's been a good experience getting a SLUG and setting up SqueezeCenter on it. But I already need a more powerful box so less than 1 week after the SLUG arrived at my house it's time to sell already. Fortunately, I've found a buyer at work who wants something low power for some really trivial services so the SLUG is ideal for them. For me though, it's a case of getting back to scratching my head over which low power home server solution to try next. Whatever I choose will be more expensive than the SLUG, it's possible I could equal its low power usage, and I definitely now know I need more memory and ideally an x86 architecture.

Friday 30 May 2008

Google Treasure Hunt Question 3

I've been keeping up with the Google treasure hunt as a bit of fun rather than seriously going after any prizes. At least one other guy at work has been joining me, Nick O'Leary has taken up the challenge too. Question 3 was recently released, and while I thought it might possibly present the greatest challenge yet on first inspection, it turned out to be really rather trivial.

So question 3 is all about IP routing, and tracing a packet route around the network. I was expecting some hardness built in around working out subnet masks, but there was none of that at all, just a simple route to follow resulting in an 11 node path. The question then:

Below is a diagram of a computer network. The nodes are hosts on the network, and the lines between them are links. A packet is sent out from host G with a destination of 201.89.136.112. Which nodes does the packet pass through on its way to the destination? (include start and final node in your answer)



You are then shown a routing table and must trace your way through it from the start node to the end node recording the path taken along the way. This is a solution that is quickly manually traceable since no node should be visited twice (unless Google have given you some really badly designed network).

Having said about the simplicity of this one, I managed to get it wrong the first time around by starting at the wrong node. Reminds me of maths teachers constantly saying "Always Read the Question!". Once I screwed my head on the right way around I correctly answered GFIHDLOPABC for my network.

Thursday 29 May 2008

Unslinging the SLUG

Having recently purchased the Linksys NSLU2 (commonly called a SLUG) for use in a hacked form as a low power home server, I've been playing around with it a little to customise it towards my needs. The eventual aim is to run SqueezeCenter on it to power my new SqueezeBox Duet. The most commonly used hacked version of Linux provided by the SLUG hacking community is known as uSLUnG, hence hacking the SLUG with this being called unslinging.

The process of unslinging is made very simple, thanks to the great instructions developed over the years by the community, and with such a large community the amount of testing on these instructions is pretty complete too. First step is to download the firmware binaries as described on the SLUG Firmware site. I used firware version 6.10 Beta which is considered the latest stable version in spite of having a beta tag. Then simply followed the instructions in this README file and I was done. The whole process takes no more than 10 minutes or so.

Now I have a nice little low power Linux box sitting on my network raring to run some services for me. Pretty much anything you can think of has been done on the SLUG, Apache, MySQL, etc, etc, etc. So the list and choice of what to do is very complete. For now though, I've just installed a few basic utilities (coreutils), Perl (I know I'll need that later), GCC, and SSH for remote access.

I'll quickly mention the SLUG specs in passing too. It has a 266Mhz ARM based Intel XScale processor, some of the early models were under clocked at 133Mhz but all the recent editions run at full speed; 8MB flash; 32MB RAM; 2 USB 2.0; 10/100 Ethernet; runs from 5V DC power and measures just 2 x 9 x 13cm. With one USB disk attached my Current Cost meter reads it at about 5 watts power usage which I guess may rise a watt or two under load.

Wednesday 28 May 2008

Choosing the media server

The decision of which media server to go with has easily been the longest and most agonising while putting together new audio solution at home. I'm not the only one at work having recently been looking in this area either, James Taylor has also been looking at home servers with similar requirements in mind to myself. Namely, cheap and low power (low electrical power for always-on as opposed to a slow processor).

In no particular order, options on the list for me were:
EDIT (suggestions from comments, with my thanks):END EDIT

All have clear advantages and weaknesses I wont go into in detail for each box. However, they can roughly be grouped into cheaper solutions as provided by a hacked NAS box, or more expensive PC style systems. Some go straight out of the list on price alone, such as the relatively expensive Mac (I don't understand the Mac fad, single vendor lock-in, haven't we seen that somewhere before?).


I decided to plump for the cheapest of all the options, the SLUG. I figure that even though it has a slow processor and only 32MB memory it does have a fighting chance of running SqueezeCenter to power the Squeezebox Duet based on the reports of other users running SlimServer on it. If all else fails, there are plenty of people at work looking for low power solutions who may be willing to buy a 2nd hand SLUG should I want to upgrade anyway.

The SLUG is a very well-known device in the land of hackery. It can easily be modified to run any one of several different versions of Linux that maintain different levels of compatibility with the original Linksys firmware and interface. It's purpose in life when released (back in 2004 I think) was as a cheap NAS box that simply provides a USB to Ethernet interface. The idea being you plug a cheap USB hard disk into it, configure via the simple web interface, and you have storage you can access from anywhere on your home network. Because Linksys made the device cheap, naturally their choice of operating system was a free one, Linux. The Linux license dictates Linksys had to make their source code available, hence it's easy to modify the original software for your own purposes. The rest follows from there really!

Saturday 24 May 2008

Choosing the stereo and speakers

While working out how to string together my new audio solution I decided to replace my faithful old Aiwa NSX-S505 stereo system. The Aiwa has been a good servant over the years and seen a lot of action, but with the volume knob broken and one of the two tape players knackered, when the CD player refused to play a CD enough was enough.

I've always loved Denon kit as being simple yet very good quality, stylish and innovative at the same time, so I was immediately drawn to them for a new stereo. I was looking at the Denon D-M35DAB system as my choice item but before I purchased it used it as the bar for a quick shop-around.


While reading reviews I discovered Onkyo which was a company I'd heard of before but never really heard anyone buying their kit. I came across their direct competitor to the Denon model I was looking at, the CS-515 which has pretty much the exact same feature set. I'm no audiophile so I take great note of what the professional reviewers have to say, and with What Hi-Fi product of the year award, and Best Hi-Fi under £500 awarded to it I had to look much more seriously at the Onkyo. It was, eventually, to be the model I decided on based purely on Internet shopping having never touched or listened to either the Onkyo or the Denon before.

I have pretty simple requirements for a stereo. It has to have enough inputs for me to connect my various devices (Media Centre, possibly TV, etc), I wanted something quite small in terms of height so it would sit in my TV cabinet, and something of a better sound quality than the Aiwa (which really was an excellent buy for what I paid for it many years ago). Feature wise, I wasn't bothered about a tape player any more (we ditched our tapes a while ago), so just a simple CD player and digital radio would be good enough. Conveniently, both of the systems I found fitted these.


When I purchased the Onkyo I didn't go for the CS-515, but rather the CR-515 which is exactly the same unit minus the speakers. The Onkyo speakers are reviewed as being an excellent set, particularly for ones that are shipped as a standard set of speakers with a hi-fi system. However, I decided to go with the professional opinion once again and opted for the current set of award-winning small-sized speakers, the Tannoy Mercury F1 bookshelf speaker set. They're slightly larger than the Denon SCM-50 bookshelf speaker set I have in the kitchen, which are fantastic so the Tannoy's had a lot to live up to. I'm pleased to report they sound really quite nice when attached to the Onkyo, although my first sound test was somewhat inhibited by Beth vacuuming the rest of the house at the time!

Wednesday 21 May 2008

Choosing the media streamer

Having recently upgraded my home audio system, the choice of which media streamer to go for was not a hard decision. There are a few different manufacturers out there producing different types of hardware that would result in completely different solutions. These seem to be categorised into roughly three areas.

First, you have the traditional hi-fi system manufacturers who are adding more modern media methods to their kit. Sony have the gigajuke systems with built-in hard disks, while phillips have the streamium systems. I discounted these fairly early on as being rather expensive and full of gimicks I wouldn't really care about or use, while not providing the full functionality that I really wanted at a price I was happy with.

Next there are the traditional NAS manufacturers who are upgrading their firmware to include media streaming functionality. This was slightly more tempting in some ways than a stereo system with this functionality built in. However, the lack of remote control or feedback without a PC switched on was very off-putting here.

What I really wanted was something to stream music from a PC to an existing stereo system that provided good feedback to the user with a remote control too. Enter the third set of devices, the dedicated media streamers designed to work with various media servers such as Firefly, SlimServer, iTunes, etc. When looking at these, my choices were quickly narrowed to a set of 3 possible candidates, in descending order of price:

  1. A collection of various Sonos hardware
  2. A SqueezeBox Duet from Slim Devices (now owned by Logitech
  3. A Pinnacle Soundbridge


I would have dearly liked to get my hands on the market leading Sonos which tops all the reviews while having the reviewer salivate over their nicely designed hardware, excellent interface and crystal sound quality. However, coming in at £700 sterling it seemed a bit expensive, especially as I would be spending more on another hi-fi system too, so it was reluctantly ruled out quite early on.

The next rejection waas the Pinnacle Sound Bridge, rejected for many reasons. It's easily the cheapest of the three on the list at under £100 though. I found it very difficult to find a dealer in the UK who had these things in stock so that was one rather off-putting factor - if there's no demand, then how good could the product be? The killer for me was when I compared to the Roku Soundbridge though. I found out Pinnacle license the soundbridge technology from an American firm, Roku, for marketing in Europe. That's all very well, except the European Soundbridge is inferior (much smaller and less usable display). This annoyed me to such an extent I felt I couldn't buy the European model and there are no American models for sale over here, except possibly some second hand ones on eBay.

Squeezebox Duet
The option I went for is the Slim Devices SqueezeBox Duet which seems like a really nice bit of kit, although not exactly cheap to buy either. It comes in two parts, the receiver box you hook up to your stereo system, and the remote control you use to browse and control the music.

The receiver is a pretty simple box, it has an Ethernet port, built-in wireless, RCA analogue audio output, and a digital output too. It sits on your network waiting for commands from the squeezebox controller and outputting any media streams it receives to a stereo (or powered speakers).

The controller is a little more interesting. It's also a wireless device, and has a jog wheel and LCD screen. Wireless means you don't have to have line of sight to the receiver, so you can hide the receiver away somewhere out of sight near your stereo. The interface is quite polished and very easy to understand. It's firmware upgradeable too so it'll only get better over time.

One of the things I really love about the SqueezeBox stuff is their openness. They use open source development to produce the SqueezeCentre (formerly slimserver) media streamer and as such it's got a nice little community of people outside the main company producing plugins to do all sorts of stuff as you can imagine. They adopt a similar approach for their firmware as well, while I've not come across the source code yet (I've not looked to see if it's available), the controller has some nice open type touches to it such as the ability to use your flickr pictures as the screensaver on the LCD screen when it's not in use. Overall I hope, and I think, I've made a good choice.