Tuesday 26 August 2008

When is open source not open source?

I've been having a pretty major headache trying to get my SqueezeBox Duet to do media streaming ever since I bought it many months ago. The SqueezeBox is also the primary reason for buying a low power home server that I've been blogging plentifully about too. I'll save the post about my trials with the SqueezeBox itself for the day when I resolve the issue; either with a fix or by sending the darned thing back for a refund. However, it's got me thinking about some other things along the way while I've been trying to solve the various problems.

We're all familiar with open source. It can have a pretty simple definition i.e. where source code for a piece of software is made available publicly. Dealing with Slim Devices which are now a Logitech company has sparked thoughts about just how many different types of open source there are and when open source crosses the line to no longer feel like open source even if I can still download the source code.

I'm very used to working with what I think of as standard open source projects. These are the ones that generally started with one person writing something small to solve a problem they had or because they didn't like other versions of software trying to do the same thing. The more mature of these are generally run by a person or small group of individuals who control the project for the benefit of the community of users in a not-for-profit fashion. Numerous examples spring to mind, not least the Linux kernel itself, but huge amounts of different software some of which get grouped e.g. those from the Apache Foundation, KDE, Gnome, Mozilla; and those that stand alone e.g. Pidgin, X-Chat, Samba, rsync; to name just a few that pop into my head.

I think where I'm going with this post is to look at what happens when open source stops being not-for-profit and these projects tread the line between this standard type of open source project and become something else. This is where I've got to in my experience with SqueezeCenter, but clearly this isn't the first for-profit open source software. I have no idea what the first is/was but there are definitely some prominent examples out there such as MySQL. Slim Devices employ developers to write and maintain SqueezeCenter which is central (although billed as optional) to the hardware they sell. In their case, the software is free to use and completely open source, it's written in Perl. The way this model changes the community is quite interesting.

In my experience so far, instead of having lots of developers donating their time to the project to learn, fix, maintain and progress the code base, developers are paid to do this. In the case of SqueezeCenter this seems to cut down the community to just those developers paid to do so. Why would other people contribute to something for which they could be paid, or for which other people are paid? Plenty of people get paid to write code for the Linux kernel but in this and other examples there is a distributed interest for that code rather than the single point of interest of one company. In spite of the fact I don't feel compelled to contribute to SqueezeCenter directly though, I still take great comfort from knowing it's open source and I think that's where the benefit to Slim Devices comes from. If I did have a problem, I could fix it myself, maybe sending a patch or possibly maintain my own personal patch set if I got that deeply involved.

So how many types of open source are there and when does open source no longer feel like open source? A good philosophical point for debate for which I think there is no real answer. There are so many reasons for using the open source methodology that it can bring benefits in so many different ways whether you're a developer, employee, company or simply a user. Each open source project tends to have a different feel to it, in my experience so far this has generally been governed by those who run or contribute to the project. However, there are clearly some other factors that might determine what it feels like to be part of a project that releases its source code. I'm sure the reasons for these are as numerous as the benefits they bring.

Tuesday 12 August 2008

Byebye Ubuntu, Hello Fedora

My recent experiments with installing Ubuntu on my little home server came to an end this weekend. I'm working hard to debug problems with my media streamer software, SqueezeCenter. After finding tons of forum posts and various problems with installing SqueezeCenter on Hardy Heron I decided to try another approach so I'm now running Fedora 9 at home instead. Both Hardy and Fedora 9 are supposed to be supported by Slim Devices for their Squeeze-stuff. However, it appears neither of these work but I'll save that rant for another day once I've worked out what's wrong (I have my suspicions about Slim Devices testing against Perl 5.10).

I'm actually quite relieved to be back in my comfort zone with Fedora at home again. I really enjoyed the experience of playing with Ubuntu but it's just not for me for various reasons...

I've met quite a few Canonical guys in my professional role and they've all been great; helpful, very approachable and in the case of some, such as Jono Bacon very decent techies too. That's not my experience with non-Canonical Ubuntu contributors though. I found if the Ubuntu documentation (which is excellent for pretty much everything before Hardy Heron right now) failed me, then talking to the community was not a good experience. I found I was met with an abrupt RTFM attitude in most instances, where the assumption of the community is that people asking questions are dumb. Personally, I blame this on the typical Ubuntu user being non-technical where Linux is concerned so I guess the community receive lots of silly questions which must get annoying at times. All that said, I still believe Ubuntu is really important and plays an extremely valuable role in trying to bring Linux to a more mass audience.

I also found Hardy to be down level in various instances compared with the packages available in Fedora 9. The big one for me here, on my little server, is the OpenChrome drivers for the graphics chipset. Fedora have the version that supports my chipset, but when I asked about inclusion in Ubuntu there was no interest in updating the down level version in their repositories. I also enquired about the broken Via proprietary driver in Ubuntu which resulted in the Via driver being marked for removal! So rather than update the open drivers or fix the package for the proprietary drivers, the response was to remove the proprietary one and not update the open driver which left me in a position of manually maintaining my own graphics driver until the next major Ubuntu release.

I've used RPM and yum way more than I have deb and apt so I sway towards the former simply through familiarity. Having the chance to play with debs again recently has been great too, there's some nice additional touches you don't get with RPM such as the suggested packages and the ability to remove dependencies installed with a certain package, etc. Ubuntu have done a nice job of packaging this all up with Synaptic too. Aside from those few nice-to-haves I don't really see any other advantages to the Ubuntu system, yum and RPM would do exactly the same job when fronted by Synaptic but as ever in the world of open source having choice and competition is good.

Hiding root from the general user is a decent idea too, no need for that confusion in a simple desktop environment, and makes it feel a little closer to what people expect from a Windows box.

Gnome is the desktop of choice for both mainstream Ubuntu and for Fedora so I've been going with that recently instead of my usual choice of KDE. I've been really impressed with Gnome too, for a simple desktop environment it's fantastic but I know if I were to use it every day there would be some features and tools I use regularly under KDE that I would dearly miss. However, I think I've been converted for home use over to Gnome, particularly as KDE is going through turbulent times with their version 4 releases right now. Having everything written in one toolkit is really nice, you can't avoid running GTK and QT apps under KDE but at least under Gnome you have the option of not running QT and sticking with the same look and feel everywhere.

I hope I managed to stabalise on one distribution soon so SqueezeCenter actually works, I get the feeling that will likely be Fedora 8 in the short term until Slim Devices get their act together for Perl 5.10 if my current thoughts are correct. So for now at least it's goodbye to Ubuntu until the next time I give it a run somewhere.

Friday 8 August 2008

Mobile Internet over Bluetooth Part 2

Following on from configuring your mobile phone for Internet over bluetooth...

Once you have your device configured, the next thing you need is to connect over bluetooth to some machine to route your traffic for you. I have a laptop with built-in bluetooth and I'm running Redhat Enterprise Linux version 5. You need to configure and setup bluetooth, a ppp bluetooth daemon, and some simple routing to get your phone on the Internet. First off you need to pair your laptop with your phone, there's plenty of info on how to do this around the web and it's simple enough I'll assume you now have a GnuBox configured phone paired with your laptop.

First off you need to set up Internet Connection Sharing (in windows speak) or IP Masquerading (to anybody who know's what they're talking about), on Linux this is done with iptables. Insert the following rules:
  • iptables -A FORWARD -i ppp0 -j ACCEPT
  • iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
  • iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
The last rule for the postrouting chain should point to the interface on your laptop where you have an outgoing Internet connection enabled. In my case this can be either eth0 (the first Ethernet device) or wlan0 (my wireless device, could also be ath0, eth1, etc), so I insert two rules to cover both devices, even though I only show one of these above.

Enable IP forwarding:
  • echo 1 > /proc/sys/net/ipv4/ip_forward
With your bluetooth device turned on, and previously paired with your phone, now all you need to do is set up a ppp daemon listening for incoming bluetooth "serial" type connections. This can be done in a couple of easy commands, first to add the serial protocol to your bluetooth SDP server, then to set up the listening daemon:
  • sdptool add SP
  • dund -n --listen --msdun noauth 192.168.1.1:192.168.1.2 crtscts 115200 ms-dns lock
The second command will start a dun daemon on the command line that doesn't background itself so you can debug your connection if necssary. It will set up a point to point connection between your laptop and the bluetooth connecting device with IP addresses 192.168.1.1 and 192.168.1.2, you can replace these with any addresses you like. It will also ensure the connection is operating at a sensible speed and you should provide a DNS server that will be passed to the device to resolve Internet server names - you can see this from the contents of your current /etc/resolv.conf file.

Start your web browser on your phone and tell it to connect using the Bt access point you have already configured. On the command line on your laptop you should see something similar to:
    Using interface ppp0
Connect: ppp0 <--> /dev/rfcomm1
local IP address 192.168.1.1
remote IP address 192.168.1.2
This shows your phone and your laptop are now connected through a ppp serial type connection over bluetooth using the /dev/rfcomm1 device, your phone will have the IP address 192.168.1.2 and your laptop ppp0 device will have the ipaddress 192.168.1.1. Your phone should have 192.168.1.1 set as the gateway automatically by GnuBox and the DNS address will be passed when dund sets up the ppp connection as per your command line options. Once connected, you should be able to browse the web on your phone for free through your laptop!

As I said, I run Red Hat, which provides for several handy interfaces to help with the setup of Internet over bluetooth from my phone. Here are some further instructions specific, but not limited to, how I've done things on my machine so I everything happens neatly during boot and I don't need to run any commands to set up the connection...
  • You'll want your iptables rules in place when you boot, you can append rules to /etc/iptables.d/ to do this:
    • Add the following lines to a file in /etc/iptables.d/filter/FORWARD/
      • -A FORWARD -i ppp0 -j ACCEPT
      • -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
    • Add the following lines to a file in /etc/iptables.d/nat/POSTROUTING/
      • -A POSTROUTING -o eth0 -j MASQUERADE
      • -A POSTROUTING -o ath0 -j MASQUERADE
  • Use sysctl to configure IP forwarding at boot time
    • Add (or change) the following definition in /etc/sysctl.conf
      • net.ipv4.ip_forward = 1
  • Register the serial protocol at boot time for your SDP server
    • Add the following line to the start definition after SDP is started in /etc/init.d/bluetooth
      • sdptool add SP
  • Start the dund daemon at boot time with the correct configuration options
    • chkconfig dund on (to start the service at boot time)
    • Create a file called /etc/ppp/peers/dun with the following contents
      • noauth
      • 192.168.1.1:192.168.1.2
      • crtscts 115200
      • ms-dns
      • lock
    • Edit the file /etc/sysconfig/dund so you have the following configuration
      • DUNDARGS='--listen --msdun call dun'
These settings should be enough that you can connect your phone to your laptop without having to modify any settings or start any services every time you boot. Once all the services are configured and started, and your phone is paired with the laptop, you will be able to connect to the phone's Bt access point to access the Internet any time you're in range of your laptop.

Tuesday 5 August 2008

Mobile Internet over Bluetooth Part 1

I'm one of these "mobile phones are for calls and texts" types, but last year I bought a new phone, shoved in my PAYG SIM, and set about working out how I could connect it to the Internet. I have a Nokia N73 so it doesn't do wifi but I still wanted to be able to synchronise to my Google Calendar. For me this doesn't involve using the Nokia tool set as they're all Windows based. I found out it's possible to do IP over bluetooth on the N73 so I got it going that way. This is great for cheap data connection, I can maintain a PAYG SIM and get as much data as I like for free, but obviously only when I'm in bluetooth range of my laptop. That's absolutely fine for something like calendar synchronisation, which is all I need.

What's sparked off this post is I've just got a new laptop and so I looked out my notes on how to do IP over bluetooth once again and have now got it going on my new machine too. For the benefit of anyone else who might want this type of setup, here's what I did for the phone (how to set up the data connection on the laptop will be coming in Part 2)...

My N73 runs Symbian S60 version 3. This type of phone has all the required software and hardware built in to do what I want. All you need to do is alter the communications database to set yourself up a bluetooth access point and you're done. The problem here is, the mobile network operators don't want this option exposed on your phone so you have to pay them for a data connection. With a little research you can discover third party open source apps to make the necessary modifications to your database to enable these options, I found and am using one called GnuBox.

GnuBox works nicely enough, but getting it going on S60v3 can be tricky. The developer makes the app available for S60v2, hence it doesn't need to be signed in order to access the features locked down on your S60v3 phone. GnuBox requires write access to your comms DB which requires the app to be signed on S60v3, you can't download a signed version, so we're into the realms of self-signing in order to get this working on S60v3. So for S60v3 you need to get hold of a tweaked version of GnuBox, sign it for your phone, install and configure.

Grab the S60v3 version (search for gnubox_s60v3.sis) which must then be signed for your phone (since writing the instructions below, it's become possible to sign symbian apps online at symbiansigned.com):
  • sign up for an ID at http://symbiansigned.com
  • download their certificate request application
    • sadly this is a windows only app, but find yourself a windows box and install+start the app
    • Select an output file for your *.csr file (say gnubox.csr)
    • If you don't have an ACS pub ID, select No. Then select your key output filename *.key (say gnubox.key) and pick a password
    • Fill out the personal info and your IMEI number, find your IMEI by typing *#06# on your phone
    • Add all the capabilities to your certificate request, from the left box to the right
    • Log into symbiansigned.com, click the "My Symbian Signed" tab and upload your gnubox.csr file.
    • You will automatically be taken to the dev cert page. You can download your certificate file (*.cer) to your machine.
  • now you need the signsis files package to sign your app for your phone with your developer certificate
    • run the signsis program, signsis.exe -o -s -v gnubox.sis gnuboxs.sis gnubox.cer gnubox.key [ENTER]
    • This will use your certificate file and key to sign the gnubox.sis file and output gnuboxs.sis for your phone.
    • You can copy gnuboxs.sis to your phone and install it. You will get a warning about it being signed with a developer certificate!

You now have the software in place to configure Internet over bluetooth on your phone, so lets do just that:
  • On the phone go to, Tools -> Settings -> Connection -> Access points, to set up a new access point
    • Options -> New acces point -> use default settings
    • Name the access point, Bt, GnuBox uses this name internally so make sure it is called Bt case sensitive (it stands for bluetooth, duh!).
    • Change the data bearer to "Data call"
    • Set any old dial up number, say 321, this is not at important as it will be nulled by GnuBox later anyway
    • Set a username/password combination with prompt password set to No. Say abc/xyz for username/password, also not important.
    • You should be able to leave the rest of the settings, including, options -> advanced settings, alone!
  • Now start GnuBox, it's installed and located in your applications folder.
    • The phone number you just entered is printed on the screen, but the ModemBearer should still show nothing
    • Go to Options -> Install -> Create records
    • Exit GnuBox with Options -> Exit
    • Start GnuBox again, the ModemBearer should now be set (the exit of GnuBox was just a sanity check to show you this)
    • Select Install -> Set RAS login script
    • Then select 2box bluetooth -> Serial Port, which will tell GnuBox to set a point to point connection between 2 machines when you "dial" your Bt connection later

Thats it, you now have Internet over Bluetooth capability on your phone. The next step is to connect to another machine to act as your router to the Internet, but that's for my next post.

Friday 1 August 2008

What Ubuntu Thinks of a TinyTuxbox

I've been meaning to log some, I think I'll call it... Linux type stuff, to do with the TinyTuxbox for a while. Here's my attempt to look at what Ubuntu makes of this little box.

First, the CPU (from /proc/cpuinfo):
processor : 0
vendor_id : CentaurHauls
cpu family : 6
model : 13
model name : VIA Eden Processor 500MHz
stepping : 0
cpu MHz : 498.706
cache size : 128 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge cmov pat clflush acpi mmx fxsr sse sse2 tm nx up pni est tm2 xtpr rng rng_en ace ace_en ace2 ace2_en phe phe_en pmm pmm_en
bogomips : 998.77
clflush size : 64


The interestingness here comes from the fact we have a 500MHz Via Eden with 128k cache and just under 1000 bogomips which (although it shouldn't be) is often used as a trivial performance metric of a processor. Next, lets have a look at what's on the PCI bus (courtesy of lspci):
00:00.0 Host bridge: VIA Technologies, Inc. CX700 Host Bridge (rev 03)
00:00.1 Host bridge: VIA Technologies, Inc. CX700 Host Bridge
00:00.2 Host bridge: VIA Technologies, Inc. CX700 Host Bridge
00:00.3 Host bridge: VIA Technologies, Inc. CX700 Host Bridge
00:00.4 Host bridge: VIA Technologies, Inc. CX700 Host Bridge
00:00.7 Host bridge: VIA Technologies, Inc. CX700 Host Bridge
00:01.0 PCI bridge: VIA Technologies, Inc. VT8237 PCI Bridge
00:08.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)
00:0f.0 IDE interface: VIA Technologies, Inc. CX700M2 IDE
00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 90)
00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 90)
00:10.4 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 90)
00:11.0 ISA bridge: VIA Technologies, Inc. CX700 PCI to ISA Bridge
00:11.7 Host bridge: VIA Technologies, Inc. CX700 Internal Module Bus
00:13.0 PCI bridge: VIA Technologies, Inc. CX700 Host Bridge
01:00.0 VGA compatible controller: VIA Technologies, Inc. CX700M2 UniChrome PRO II Graphics (rev 03)
02:01.0 Audio device: VIA Technologies, Inc. VIA High Definition Audio Controller (rev 10)


Highlights here come from the Realtek Ethernet which is well catered for out of the box by pretty much any major Linux these days. There are also two IDE controllers, USB controllers and an audio controller that are all well supported. It's interesting that most of the PCI devices are provided by the single CX700M2 chipset which I believe is built onto the processor board for the Via Eden's. The one thing from this list that has been a pain in the back side is the graphics controller. It works out of the box both in frame buffer mode and via the open source via unichrome driver called Openchrome. However, Openchrome don't support the CX700M2 board yet (not officially anyway, the code is still in SVN according to the guys I spoke to on their IRC channel) so graphics processing was eating lots of CPU. Fortunately, I found a link to later via drivers at linux.via.com.tw than are available through the official Via driver site where they're still only supporting Ubuntu 7.04 and 7.10. Seems I'm caught in the middle for now, the Via drivers work nicely but will be a pain to maintain until the Openchrome drivers find their way into Ubuntu and I switch back over to them.

Then there's the memory. For a small box this one has a relatively generous helping of 512MB RAM, some of which is stolen by the CX700M2 for graphical shared memory. Free is currently showing 439MB total memory, 390MB used and 49MB available; swap is 100% free. That's not bad at all considering I'm running Xorg with Gnome, SSH, SqueezeCenter, 2 instances of MySQL (SqueezeCenter starts its own instance), and a Nanobroker with some Perl code to log my Current Cost data. It'll be running Apache soon too as I move towards writing some more web based Current Cost facilities.

Just in case anyone is interested, here's the list of modules currently loaded into Ubuntu's 2.6.24-19-generic kernel: drm af_packet ipv6 cpufreq_powersave cpufreq_conservative cpufreq_ondemand cpufreq_stats freq_table cpufreq_userspace sbs container sbshc video output dock battery iptable_filter ip_tables x_tables ac parport_pc lp parport loop snd_hda_intel snd_pcm_oss snd_mixer_oss snd_pcm snd_page_alloc snd_hwdep snd_seq_dummy snd_seq_oss snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer snd_seq_device snd soundcore serio_raw evdev psmouse pl2303 usbserial pcspkr button i2c_viapro i2c_core shpchp pci_hotplug via_agp agpgart ext3 jbd mbcache sg sd_mod pata_acpi pata_via ata_generic 8139cp ehci_hcd uhci_hcd libata usbcore 8139too mii scsi_mod thermal processor fan fbcon tileblit font bitblit softcursor fuse

I'll spare the full dmidecode output but from this information I can determine it has an AMI Bios version 8.14 released on 03/28/2008. The CPU is listed with, amusingly, Family "out of spec" and 128K L1 parity cache and 128K L2 ECC cache. A single soldered 512MB Dimm.

I'm still surprised at just how well it matches up to being a standard x86 box, providing all the interfaces you would expect of such a box given its size. Clearly it's never going to be the fastest or have the most memory, but it really does stack up nicely for all but the most intense home serving tasks or gaming. It certainly shows me we can fill most of our computing needs with such a small box and only 8 watts of power. Ubuntu seems no problem for it and it's reported to run Windows XP too. I'll definitely be bearing it in mind next time someone asks me to recommend a box simply for browsing the web, e-mail or a bit of word processing!

<Edit>
Memtest86+ shows the processor as a Via C3 Samuel 2 clocked at 498.7MHz, 128K L1 cache @ 2035MB/s, it doesn't detect L2 cache, and shows 447MB RAM @ 367MB/s.
</Edit>

Tuesday 29 July 2008

Graphing Current Cost

After hooking up my Current Cost Meter to a database recently I've been logging my power usage so the next step is to look at what I can do with the data. As I mentioned when I introduced my meter lots of other people have been looking into this as well.

I like Dale's idea for creating a daily energy bill so I've decided to aim towards that but include a graph of the days usage and possibly a link to a web page where I can look at more details of that days use.

With the web page idea in mind I decided to look into what I could do graph wise in PHP since that's my web language of choice. After looking through a few options I plumped for the obvious library, that of PHP Image Graph as it's part of PEAR so should be fairly decent, complete, well used and flexible. Here's where I'm at so far:
That's just a small snipped of 1 days power usage when I was cooking dinner. You can see I turned on my steamer (approx 800 watts) at about 5:30pm then went on to turn on the oven which heated up then cut in and out while it was cooking before I turned it and the steamer off just before 6pm.

As you can see, I'm pretty much there with the graphing side of things. The only issue left is to sort out the X axis. While it might appear to be a bit crazy, the current cost meter only samples approximately every 6 seconds. Because of the different number of samples in each hour and with a few rounding errors, the X axis appears not to be linear. Hopefully, I'll solve this by ensuring a consistent number of samples in each time slot.

Overall, PHP Image Graph seems very powerful. You can graph pretty much anything with it in all sorts of formats and have relatively complete control over the way the graph looks. I'm not at all artistic so mine looks very plane! There is, however, a reasonable barrier to entry. Documentation for the API is relatively complete if you know where to start, but documentation in general seems really rather thin on the ground and very sketchy. But, thankfully someone produced a great set of demos for a PHP conference that really show off a lot of the features. The source is available too so it's easier to work out what to do with your own graphing and how to get started. I'll probably blog my source code at some point, it's not very long, but definitely requires some tidying before it's ready for a public outing.

What I want to do next is take the graph and produce some sort of daily "bill" e-mail. That will have a link back to a private area on my web site that would allow closer inspection of certain areas of the graph. This is just the next step in education for how to save electricity by learning how much different combinations of devices use together. For example, is it better to steam fish in a steamer, grill, oven cook, etc. Hopefully, I'll be able to apply those sorts of questions all around the house to work out how to be as green as possible.

Wednesday 23 July 2008

Next Generation Linux

The folk following me on Twitter are probably sick of hearing about identity management, the main stay of my work this year. So I was glad to get out of the office last week to present at an IBM conference in London called "Next Generation Linux". A thank you note I received reminded me I should blog about it, always nice to receive those! Next Generation Linux is an event IBM are running in various worldwide locations this year looking at what comes next for Linux for businesses.

Being a Linux geek working in a software services organisation called Emerging Technology Services and with my contacts I like to think I was the natural choice for the pitch titled "Emerging Linux Technologies". I only had a short amount of time to present a vast field of topics so I narrowed it down to just five topics compelling for business and talked about the following:
  1. Virtualisation
    OK, not strictly an emerging technology as many businesses have already adopted it. But, it was a good opener setting the scene for some of my other topics and allowed the opportunity for me to briefly run through a few virtualisation technologies for Linux.
  2. Cloud Computing
    An exciting name and concept for what is essentially some very well thought out system administration. This technology has always been feasible but it's being made possible now with commodity hardware capable of remote management and some neat software ideas holding it all together. The really novel thing is the way applications can be deployed to run in the cloud environment and the fact we can actually package this up as a solution now. It's the realisation of "On Demand" computing.
  3. Project Big Green
    Green computing is becoming much more of a concern as business starts to run out of room in data centers, power requirements head skywards and running costs steadily increase. Last year IBM announced a re-investment of $1 billion into research towards green computing which gives business the opportunity to cut running costs and jump on the green band wagon at the same time. Green computing is essentially about consolidation of services, allowing spare compute power to be utilised elsewhere, and making sure equipment is environmentally produced and disposed of. It's those three words we hear in all good green campaigns, reduce-reuse-recycle, do it!
  4. Security Enhanced Linux (SELinux)
    One of my specialisms and a topic I could ramble on about for a long time, I'll try to keep it brief. In this short pitch I indicated security is still an issue in 2008 and it can cost you big time if your security is breached. Enter SELinux, an overview of what SELinux is and where it comes from and a comparison with other technologies such as AppArmour is a good start. To get to the crunch of SELinux though, I explain the differences between Discretionary Access Control (DAC) and Mandatory Access Control (MAC) and the ultimate advantages SELinux brings for security.
  5. Real Time Linux
    Real time really is an emerging area with both of IBMs current Linux partners, Red Hat and SUSE, bringing out offerings recently. Real time is built from the hardware up through the OS and in the case of hard real time into the applications too. IBM have certified some particular System X hardware to be real time capable and provide firmware and support for this now. Next comes the Linux piece where some of the firmware functionality removed from hardware must now be implemented in the kernel, there's loads of ways of doing this but to get support for it SUSE and Red Hat take care of that. IBM have also built some enhancements to Java, by introducing a modified garbage collector (Metronome) and providing ahead of time (AOT) compilation while complying with RTSJ, all of which add up to the ability to write real time Java apps - interesting! Now we can offer a full real time system on non-specialised hardware, using a commercially available operating system and a language loads of people can program, backed by IBM through Websphere Real Time. Boy that sounds like an advert, sorry about that, but it is a great idea, very cool!

This is all very much in brief, if you want to know more then get in touch or leave a comment.

Tuesday 22 July 2008

Current Cost Monitor

A couple of guys at work have managed to lay their hands on a funky new device called a Current Cost meter. It's pretty simple to understand, it measures your household electricity usage and displays it on the screen (left). To do this it comes in two parts, you hook a plastic loop around the live feed going into your fuse box (mine is in the garage) which is connected to some electrical wizardry I don't understand to measure the current without interfering with the wire, and a wireless transmitter device to send the data to the unit you just plug in somewhere in your house.

I jumped at the chance to get one of these things and was one of the first batch to get them at work and a little community of current cost users has built up pretty quickly. That said, pretty much everyone else has beaten me to blogging about it with some very cool results. So here's the list (that I know of) right now, in no particular order we have...As an aside, Dale's just joined my department at work (horay), and Roo is leaving IBM (boo and much sobbing).

There's lots of other people looking into these things too, but those are just the blogs I know about. This type of device isn't exactly new, but what makes this one exciting is the data port and connectivity to a computer. With such a community there's been some cool work done such as graph power usage and send yourself a daily electricity bill. The device itself can't really save you money and definitely doesn't save energy (you have to plug it in) but what it does do a great job of is educating you about exactly what all your household devices like to eat for breakfast.

I'm just starting out at home having had the screen in the kitchen for a couple of months already with looking at what I can do with it while connected to a computer. I'm now logging all the data to a database so I guess one of the first things I'll be doing is graphing my own data. From that I hope to learn even more about what my house does with its power. For now though, the only graph I have (above) is that produced by sending my data via a Nanobroker to Andy Standford-Clark's server. This should hopefully be another fruitful little project for my new (and now you know why it's low power) home server.

Thursday 17 July 2008

Installing Ubuntu On A TinyTuxbox

With my new toy now in hand the time soon came to get it installed with Linux. At first glance it might appear to be tricky to install given the lack of CD or Floppy drives. However, it boots from just about anything you attach to it whether that's USB, Compact Flash or Network Boot. Setting up a one-time PXE server seemed a little over the top so I was planning to boot from a USB stick until I found someone at work with a USB CDROM.

Ubuntu IconUsually I like to run Fedora at home, it's the thing I'm most comfortable with having spent my career tinkering with Red Hat and SUSE based distributions so one of the things I wanted to do with this box was install the much hyped Ubuntu distribution. This wasn't to see what all the fuss is about (I'm familiar with Ubuntu having tried it a couple of times before but always gone back to Fedora) but really just so I can get to know it even better. This machine is going to be part desktop and part server so Ubuntu kind of makes sense too.

I installed the hard disk into the box myself and once I got over some initial hardware niggles (that I caused I should add) the installation was simple. Boot from USB CDROM with the Hardy Heron CD in it and the rest is history. It's amazing how such a small box can run a full whack desktop operating system and do all that on just 8 watts.

In these early days, I have three things in mind for the box. The primary use will be to serve my music collection to my stereo; next is to connect my current cost meter to allow some more in-depth analysis of our power usage at home; then there's simply using it as a desktop for the simpler day-to-day computer usage i.e. browsing the web.

Setting up the music streaming was pretty easy after transferring my collection to the hard disk. I added the apt sources for the SqueezeCenter software that operates with my SqueezeBox Duet, did an apt-get update and an apt-get install squeezecenter and job done. The TinyTuxbox can much better cope with running the MySQL server this is based on along with the web front end and the music collection scanning services associated with the software than the SLUG I tried previously. All in all, couldn't have been much easier.

I've not tried hooking up my current cost meter yet, ironically I've run out of power sockets near the computer with only a six-way adapter and plugs for the PC, TinyTuxbox, Printer, Monitor, ADSL Modem Router, and speakers although it shouldn't be a hard problem to rectify.

Last of all, one of the additional benefits of this low-power box is every day usage. It can easily run a web browser so instead of starting up a large PC just for this, we can switch to the TinyTuxbox desktop and browse there. This should add to our power saving, even though it's likely the TinyTuxbox will be run all the time soon to serve the current cost data. That reminds me, I really should discuss batch-uploading of current cost data so I can save even the 8 watts the TinyTuxbox uses most of the time too.

Sunday 13 July 2008

Introducing the TinyTuxbox

My second choice of home media server arrived on my doorstep last week after my unwillingness to maintain the painfully slow and awkward slug. This time around I've plumped for a TinyTuxbox Series 8 which seems to be a UK resold version of the e-Box 4300. It fits the extra requirements I made after parting with the SLUG, that is it's an x86 based machine and has lots more memory. I'm not the only one at work with one of these types of boxes either, James Taylor has the Netvoyager re-badged version of the previous box to my one, the e-Box 2300.

It is, in fact, a fully functional x86 PC but just a really small one, even smaller than the pretty tiny Fit-PC which I was also seriously considering and probably would have gone for were it not for the excellent pre-sales support of one of the TinyTuxbox staff over e-mail. That said, the excellent pre-sales was balanced with painfully slow delivery. It took 28 days to get it to my door which for a delivery cost of nearly £20 I consider poor. I've been left with a upward feeling though, post-sales support has been promising too as I initially had some problems installing the box, which it turned out were my fault and I solved quickly enough anyway. I'm not going to talk software here though, that's a story for another day. So how does my TinyTuxbox look and spec up....?

The workhorse of the TinyTuxbox is the 500MHz Via Eden ULV processor which provides a 32-bit x86 processor along with a built-in graphics processor with hardware MPEG decoding. The processor is an impressive bit of kit, it runs all that from just 1 watt of power, see the link for the full specs! Away from the processor we have 512MB RAM (some of which is shared for the video output), on-board Ethernet, 3 USB ports, VGA output, a PS/2 connector (supplied with PS/2 Y-Splitter cable to connect both keyboard and mouse), a compact flash slot, sound in and out, power button, and hard disk and power LEDs. The box is also fitted with an IDE connector and can house a 2½" laptop type hard disk in it. I ordered it without the hard disk and fitted my own as the supplied ones were not good value for money probably due to the services incurred from the fitting itself.

The TinyTuxbox site advertises the unit as consuming a maximum of 8 watts and I'm pleased to report that was absolutely accurate. According to my current cost meter, it uses 8 watts with the hard disk spinning so once I get it to spin down on idle it should use very little juice. Click the various images for a link to my Flickr page and some more notes.

Friday 11 July 2008

Introducing Home Easy

One of the things I've been giving consideration to while choosing my media server is home automation. I don't want to go crazy about it and have everything in the house hooked up to a computer so curtains open when alarm clocks go off, or alarm clocks go off earlier if it's freezing outside (to give more time to scrape ice), etc. I'm more interested in a few subtle things to help be more green at home, and possibly to help with security, anything I can get that adds convenience is a bonus but not necessary for me.

The first simple step I've taken along this road is to get some stand-by power savers that are getting ever more popular these days. The one I went for was the introductory pack from the Home Easy range which are manufactured by Byron and retailed exclusively through B&Q.

The pack gives you three radio controlled sockets into which you can plug your devices at home, and a remote control to turn on/off the sockets. So, by plugging in my TV, DVD, Wii, and other devices to one of these via their 4-way extension lead I can turn off a whole bunch of stand-by with the click of a remote control button anywhere in the house.

The Home Easy range is relatively complete for a UK home automation solution not based on X10. The kit is reasonably priced too with the 3 sockets and remote costing £20, unlike X10 end points. One of the reasons for choosing Home Easy over another popular standy-by saver is that the range is more complete, but also the protocol is well known so third parties are starting to produce devices compatible with Home Easy too. For example, rfxcom have certified their transceiver to work with Home Easy so it's now possible to computer control Home Easy devices - nice!

The next tentative steps I'll be looking to take on this road are having a home on/off switch. It's annoying having a single remote control, it's small, you have to find it, and it might be upstairs/downstairs and probably not where you are. I want to take advantage of the home easy grouping facility to have a switch that basically turns my house on or off. We should be able to leave the house (or go to bed) and turn all the stuff we're not using off, and turn back on again when we get home (or wake up).

Just this one purchase can save me anywhere between 20 and 50 watts in stand-by power. At 10 pence per kilowatt hour (typical rate) I'll get my £20 back with just 6 months usage. So it's green and saves you some dosh too, bonus!

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.

Tuesday 20 May 2008

Google Treasure Hunt Question 2

After solving question 1 successfully I decided to plod on and answer question 2 as well. It was, for me at least, far less challenging than the first question.

This time, you are generated a set of files with random directories and file names that you are asked to download and process. Once I got passed the immediate suspicion of downloading a zip file (for fear of viruses) it took no time at all to whip up a solution. My question was:

Here is a random zip archive for you to download:
GoogleTreasureHunt08_15866755520722619948.zip

Unzip the archive, then process the resulting files to obtain a numeric result. You'll be taking the sum of lines from files matching a certain description, and multiplying those sums together to obtain a final result. Note that files have many different extensions, like '.pdf' and '.js', but all are plain text files containing a small number of lines of text.

Sum of line 4 for all files with path or name containing BCD and ending in .pdf
Sum of line 5 for all files with path or name containing mno and ending in .rtf
Hint: If the requested line does not exist, do not increment the sum.

Multiply all the above sums together and enter the product below.
(Note: Answer must be an exact, decimal representation of the number.)


Again, my solution was Perl based and generated a correct answer of 364264342 for my particular zip file:
#!/usr/bin/perl -w
use strict;
use File::Find;
use FileHandle;
my $total1 = 0;
my $total2 = 0;
find(\&wanted, ("/home/gwhite/GoogleTreasureHunt08_15866755520722619948"));
print $total1*$total2."\n";
sub wanted {
return if (-d $File::Find::name);
if (($File::Find::name=~m!BCD!i) && ($File::Find::name=~m!\.pdf$!i)) {
my $fh = new FileHandle;
$fh->open($File::Find::name) || die ($File::Find::name." Oops: $!\n");
while (<$fh>) {
last if ($fh->input_line_number>4);
chomp($_);
$total1+=$_ if ($fh->input_line_number==4);
}
$fh->close();
}
elsif (($File::Find::name=~m!mno!i) && ($File::Find::name=~m!\.rtf$!i)) {
my $fh = new FileHandle;
$fh->open($File::Find::name) || die ($File::Find::name." Oops: $!\n");
while (<$fh>) {
last if ($fh->input_line_number>5);
chomp($_);
$total2+=$_ if ($fh->input_line_number==5);
}
$fh->close();
}
}

Monday 19 May 2008

Google Treasure Hunt

I've just discovered today (rather late I know) that Google have released a treasure hunt which is quite interesting. It's not what you might think. Given the name, I would have guessed it involved using the google search engine to find things on the Internet. However, it's actually a problem solving challenge where they pose questions and you submit your answer. I think question 2 is due out today (they obfuscate when the next question will be released), nobody seems to know how many questions there are, exactly how long this will go on for, etc. But there is a prize for "the first person to answer all the questions correctly" whatever that means.

A word of warning, don't read the rest of this if you want to work out the answer yourself!!!

My question number 1:
Google Treasure Hunt Q1
A robot is located at the top-left corner of a 65 x 61 grid (marked 'Start' in the diagram above)*.

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the not to scale diagram below).

How many possible unique paths are there?
(Note: Answer must be an exact, decimal representation of the number.)


The problem here is the vast number of different routes that can be taken, which would overflow 32 bit computers for numbers this size. My (correct) answer was 1426507627253102510231886503468838531 which I calculated using the formula (x+y-2)! / ((x-1)! (y-1)!)

A few simple lines of Perl later and I had the answer:
#!/usr/bin/perl -w
use strict;
use Math::BigInt;
# change these to match your X & Y grid size
my $xgrid = 61;
my $ygrid = 65;
my $x = Math::BigInt->new($xgrid-1)->bfac();
my $y = Math::BigInt->new($ygrid-1)->bfac();
my $z = Math::BigInt->new($xgrid+$ygrid-2)->bfac();
print $z->bdiv($x->bmul($y))."\n";

Friday 16 May 2008

In with the new

Related to my previous post "Out with the old" I have been thinking about what's next for me in terms of a home media solution. I've also been spurred on by my recent purchase of a Current Cost meter which I can hook up to a computer, but more about that another time. Similar to my old system, I'm not bothered about video so this is purely an audio solution.

There are some things I took into consideration when building the old system that I don't consider to be so important this time around. I'm not bothered about browsing the Internet on my TV and I'm prepared to spend a bit more cash, for example. But rather than concentrate on those points, here's a list of things I would like to include in the new system:

  • Switchable speakers in different rooms (kitchen and living room)
  • Connection to my stereo amplifier
  • Access to my mp3 collection without leaving my PC powered on
  • Access to Internet music (podcasts, radio, etc)
  • Remotely controlled
  • Separate screen (from the TV)


After much research, here's what I've come up with:
Setup Diagram Click to enlarge.

I'm going to use a Linksys NSLU2 (a.k.a. a SLUG) which can be modified to run Linux so I can hack it into submission to be my low powered music server. The SLUG will provide my music collection over my wireless network to a Slim Devices Squeezebox Duet system. The Squeezebox is also able to access all the Internet services I want and similar to the SLUG runs open source software so has a fantastic community of users. The Duet comes with a wifi remote control with built-in LCD screen so I can interact with the system from anywhere in the house. From the Squeezebox is an audio connection to the amplifier which, similarly to my old system, is connected to a speaker switcher box.

That little lot should keep me busy for a while and give me all I want from music at home. As I mentioned, a lot of research went into deciding which components to choose. The weak link here will likely be the SLUG because it's such a small box with only 32Mb RAM and a relatively slow processor (just 264 bogomips) but it should do for the time being. Here's my component list:

Tuesday 13 May 2008

Out with the old

I moved house pretty much spot on 6 months ago now and we're still settling into the new house. Aside from decorating, emptying boxes and all the other things you have to do at the time, it's also an opportunity for re-thinking some of the technology used in our previous house. To that end, one of the things I want to update is my audio solution. I shy away from saying media centre as that seems to brew up ideas of full on PVR systems for most people which would include recording television; something I don't care about as I have a commercial hard disk recorder I'm very happy with.

My current solution was documented at the time on Eight Bar as a description using an IBM Thinkpad built as a media centre with more details of the process, also on Eight Bar. This solution worked extremely well while having its problems at the same time. My requirements for putting the solution together were cost (it was experimental and needed a good wife acceptance factor so price was all important), fast start-up, easy and remotely controllable, and integrated with my current home stereo and speaker arrangement. I think I achieved this, it cost about 20 quid for the cables and keyboard, the Thinkpad was borrowed from work, I used the Amarok music player which made things very easy, hooked up my stereo remote control to the Thinkpad and integrated it nicely. See the no-expense-spared diagram below...

diagram Click to enlarge.
It's running Fedora Linux on the Thinkpad, with a KDE desktop and Amarok as I mentioned. I don't have a huge music collection so all my mp3s fit on the Thinkpad hard disk. I configured Linux to suspend to RAM and thus boot extremely quickly with auto-login to the KDE desktop and auto-start of various programs including the music player should a cold boot be required. The thinkpad has a serial port so I was able to hook up a serial IR receiver using LIRC to receive signals, with the audio cables going to my stereo using the minidisk port. With no minidisk attached I had spare keys on the remote control (such as play/pause/stop/next/previous) that had no effect when pointed at the stereo while other controls (such as volume) function as expected. This means I can program the spare keys to be picked up by the laptop IR receiver instead, in order to operate Amarok, and with no interference with normal operation of my stereo (so only one remote control needed for the whole solution). A nice bonus of this set up was the ability to display the screen on the television via the thinkpad s-video port. With a radio controlled keyboard and built-in mouse it's easy to sit on your sofa browsing the Internet or e-mailing with the convenience of your TV and wireless broadband.

This is all sounding marvelous and when described like that I wonder why I think about replacing it, but it does have issues. Browsing the web on your TV is great, but it's not particularly convenient when someone else wants to use the TV for its main purpose in life. Niether is it convenient browsing the Internet in 800x600 which is the highest resolution my CRT TV can cope with, then there's the wireless keyboard which is slightly fiddly but I'm just being picky now. The next major problem is a bug with the thinkpad firmware that causes the wireless to stay disconnected after a certain amount of uptime, which is unresolvable and requires a full reboot to temporarily fix until the next time it goes down. Another slight usability issue is user feedback. Browsing songs, playlists, podcasts and all in Amarok is stupidly easy, but controlling from a remote control when you can't see the screen (that was another idea for putting it on the TV) is not easy. It's great you've got the secondary screen you can use if necessary, but if you're trying to do something else or not in the same room it becomes much more difficult.

So, all these little niggles to what is in theory quite a nice setup have got me thinking of a better way to solve my requirements.

Monday 12 May 2008

Welcome

I'm sitting here having just started a new blog and wondering whether to write a this is my first post entry or not, cheesy as it may be, here it is...

I've been involved with various blogs over the years but never set one up externally to the company I work for that my overlap with my professional interests. There are, of course, external blogs I've written for including Eight Bar and the blog I write with Beth about our allotment. My personal interests regularly overlap those I have at work, I intentionally use the term professional interests having recently been certified by the British Computer Society as a Chartered IT Professional; I usually describe myself informally at work as A Professional Linux Geek. I currently have some ideas I wanted to write about that don't really fit in any of the places I not-so-regularly write, I hope to log these here and continue to do so in the future.

Picture of GrahamA quick intro to me then. I've already given away I have technical interests and the name of my current employer. I left Exeter University with a degree in Computer Science and Management Science to work at the Hursley location where I established an interest in Linux. This has since been broadened into open source software generally, and open standards and the web. All this has been through a number of interesting positions working in internal support, super computing, and customer facing consulting. I'm currently working for an organisation called Emerging Technology Services that offer great skills to our customers interested in all things new and trendy.

Away from work I like to get out and about. Whether that's playing badminton (I do that a lot), or out with Beth Geocaching, general walking, or working down at our allotment. I like a lot of sports to both play and watch (except football/soccer). I have an interest in music, listening to as much as I get time for and having played the piano since just before I was 5 I think. When all else fails I can usually be found playing the odd computer game on the PC or the Wii, or around the house somewhere doing some DIY.