Wednesday 26 November 2008

Daily Electricity Bill

Way back at the end of July I started looking into how to graph current cost data. I was looking at this from the point of view of putting the information together on a web page somewhere and potentially sending out useful information via e-mail to me and Beth on our power usage.

Recently I've been looking into this again and over the past couple of weeks we've been receiving a daily HTML formatted e-mail with an attached graph image that might look something like this:


This is a really handy reminder each day to try and be as green as possible but also to show us how we did on the previous day. The graph shows two lines, the red one showing the actual power usage in watts and a straight blue line showing our average usage for that day.

Also attached to the e-mail are the charges and a few summary statistics for the day. So on the example above you can see we averaged 240 watts throughout the day with our minimum usage recorded as 61 watts and maximum usage as 2359. The total usage doesn't mean very much without time associated with it, but I've listed it there all the same. The total can be used to work out the kWh reading for the day, total divided by 1440 minutes in the day (and points on the graph) divided by 60 minutes in an hour.

The costs are rather crudely calculated. We're charged for electricity on two levels, our first 225kWh per quarter are at a higher rate than any usage thereafter. For us, this averages out at around 10 pence per kWh cost so that rough average is used to calculate an estimate for the total cost in GBP.

This only a really simple way in which the current cost data can be used, Dale is way ahead of me on other applications for the data. I intend to extend the e-mail we're getting at the moment to integrate into a little web system we can use at home to log in and look through historic records of our usage and also produce other summaries such as weekly or quarterly usage. Also, the ability to add notes to each day will needed so when we look back over historic data we might have recorded what particular spikes in our usage are. All this is an effort to educate ourselves more in our power usage so we can change our behavior to be more efficient with it.

Thursday 20 November 2008

One A Day

I'm taking part in a little Flickr group project at the moment to take and upload one picture a day for a month. The group is called A month in my life... and was the idea of Mirriam, an old school friend I've recently got back in touch with through Flickr.

It's a great idea, I bought a new camera earlier in the year and only really used it in anger when Beth and I were on holiday in New York. Having to take one picture a day is forcing me to get off my back-side and look for interesting things to picture. I'm also finding I'm looking at the world slightly differently, stopping to appreciate and think about light and colour a lot more. If I take a picture of a boring subject I'm thinking about how I can make it more interesting while taking the picture but also with a few trivial editing techniques.

I've been going for 7 days now and so far I think my favourite shot of the ones I've taken is this one:
One a Day

I'd not heard of this one-a-day type idea before, but apparently people on Flickr commit to doing this for a whole year so it looks like I'm getting off lightly with just one month. There's plenty of interesting work going up in the group at the moment, with a lot more people about to start contributing through December. Should be exciting, I'm looking forward to seeing what everyone else comes up with too.

Monday 17 November 2008

Super Computing Project Ends

Not blogged in a while, will spare the details/excuses but back in September I had the opportunity to get back into Super Computing for a one-off project. It's this that has kept me so busy throughout October and into November where I was really very well submerged into work for an extended period. Normally I like to keep balanced in my work-life balance. However, this project demanded a lot of time and attention and fortunately my wife, Beth, was away for a couple of weeks on business too so I really had the opportunity to get stuck in.

As I suspected (from much experience in the area) in my previous post there really was a lot of information missing at the beginning of the project. This is to be expected, the customer cannot be expected to know 100% what they want, they may not even know what is available, possible or on offer. To compound this, even the best sales team can't look into minute details when proposing a solution or making bid. So we had a productive kick-off meeting, made a lot of good decisions and recorded these to concrete the design details.

What happened next you can never be prepared for, but we've probably all experienced it. Yes, the iron fist of the bean counters barged their ugly way into the project. The previously neatly agreed deadlines and design proposals were lobbed into the air with such careless abandon it was almost humorous. The promise at the start of the project from my ex-manager that "this one would be different", and we "wouldn't have to work silly hours or cut corners" was about to be viciously broken into pieces. (Wow, I can sound like such a drama queen). Project deadlines were brought forward by give-or-take 50% simply to meet a financial deadline (of one of the parties involved not IBM I should add) way out of my control. When you're met with this kind of single-minded decision making as the technical leader of a project it's very frustrating but you know there is nothing more to be done except save time where you can and work your butt off. Anybody who knows me and my work will know I hate to deliver anything less than the very best solution I think is right. So I openly request to Mr Financial Man, whoever and wherever you are to listen to people, who like yourselves, are considered the expert in their area.

This was a Linux cluster, which for the uninitiated consists of a number of computers set up to be joined to work together on a single large problem that would take any one of them an unrealistic amount of time to compute. Using the example raised by OzBeefer on my last post, climate modelling algorithms are quite large and complex taking a single computer a long time to run, so loads of them need to work together in order to predict the weather in the future before it becomes the past! Fortunately, the design of this cluster wasn't rocket science and it was quite small. Things progressed very smoothly without any potential problems that might otherwise have occurred and with some very long working hours (read 12+ hours/day) the cluster was eventually delivered to the new schedule at the customer location.

Well I could ramble on about Linux, clustering, algorithms, networks, storage, optimisations and the projects I've worked on for hours yet, which gives me an idea... for those people reading this in the Hursley community answers on the back of a postcard, comment, e-mail or whatever if you think hearing my ramblings about this stuff might be vaguely interesting some time over lunch, tea/coffee, beers, etc?

Friday 26 September 2008

Squeezebox Duet: My Impressions

Having recently had my little whinge about setting up the SqueezeBox Duet it's about time I said something about the box itself. Both professional and user reviews around the web are pretty much universally glowing with praise for it and I have to say to a large extent I agree.

First of all, there's the hardware which is sleek looking with a glossy black finish. The hardware is in two parts (ignore the odd cable here and there), the SqueezeBox Receiver:

Which, while not belittling the technicality of it, is to the consumer essentially just a dumb receiver box. It takes an audio stream over either a wired or wireless Ethernet connection and spits it out through your stereo using a digital or analogue audio connection. Then there's the controller:

Which is an altogether more exciting piece of kit. It's a wifi-device that can talk directly to your wifi router or be bridged onto your wired network via the Receiver if you don't have wifi. It features a rather strangely arranged set of controls that become familiar after a little usage. There is a jog dial with selection button, then buttons for playback, volume, control of the playlist and navigation around the menus. As you can see, it's got a nice full colour LCD display too. This means you can wander around anywhere within wireless range, control your music and get feedback directly on the device on just about anything you might want to know.

Software wise, things also come in two parts (well three if you count the firmware on the receiver). There's the software on the controller and some software to run on your PC which is listed as optional but I would consider very much essential. Both of these parts are open source with decent plugin interfaces and documented APIs you can access.

The controller runs a customised embedded Linux distributions known as Squeeze OS which is responsible for running the user interface application on the controller called Squeeze Play. The nice thing about this is you can take the user interface part, Squeeze Play, and run it on your desktop too. While the controller software is open source and pluggable, I haven't found anybody having written any useful applets to run within Squeeze Play yet but it's still early days so hopefully those people producing screen savers will come up with some good ideas for applets. That said, I can have a bit of a hack around too to see how easy it is to program for and whether I can produce something useful too.

The open source server software is called Squeeze Center and should be run somewhere with access to your local music collection. It supports a huge number of formats including flac, ogg and mp3 of course. Squeeze Center is hugely flexible and configurable, mostly through a bunch of supplied plugins. It provides a web interface as well as access to other interfaces so it can also be used to control the music playing as well as being the configuration hub for the entire setup.

Out of the box Squeeze Center provides access to your local music collection via a number of sorting methods (such as by artist, album, song, genre, etc) as well as providing standard playlist functionality. It also allows you to listen to Internet radio through a number of free and paid for services such as shout cast streams, mp3tunes and last.fm (a last.fm scrobbler plugin is also included). It gives you a favourites menu so you can tag anything as a favourite and later get quick access to it through this menu. Last but not least there's the Extras which doesn't do a huge amount out of the box (this is where most 3rd party plugins are accessed) but it does give you access to podcasts - you can subscribe to RSS or OPML podcast feeds and have them streamed to your hi-fi, cool!

I like to use dynamic playlists and that's some functionality that doesn't get included by default so I've found some plugins that do that for me now. Being a UK resident I want access to the BBC audio content and some kind person has written a plugin to access all their content too, including Live Radio streams, listen again streams as well as BBC podcasts. The final plugin I'm finding useful at the moment is one that automatically adds tracks to my music collection when I copy them to my music directory using a groovy Linux kernel feature, Inotify, otherwise you have to rescan your collection manually after adding new tracks. The plugins I've installed are tagged in Delicious.

Overall, the system seems to work very well. It's great having the flexibility of having an entire music collection at your finger tips ready to play, no messing with things that spin any more, and having access to all the additional content over the Internet is another real bonus. The packaging and interface of the components are really nice and are only set to get better over time, particularly as they're open source. This means I can get my hands on extra code in the form of those useful plugins as well as writing my own. But it also means when Slim Devices get caught up in adding support for new products or bug fixing as they inevitably will, new functionality will always be progressing at least through the community. So now I've got everything fixed up in my config, listening to music at home is quite a cool experience, happy days!

Monday 22 September 2008

Squeezebox Duet is alive at last

Back in the middle of May I decided to set up my home stereo properly in our new house so I ordered a new stereo (an Onkyo CR-515) and decided to replace an old Thinkpad I used to store my digital music collection with a new device on the market from Slim Devices, the SqueezeBox Duet and a low-power PC as a media server.

Initially I wasn't able to set it up as I was experimenting with using a Linksys NSLU2 (or slug) as the media server. Unfortunately, this was vastly underpowered for the job so I had to re-think that part of my solution. In late June I had my new server so I looked out some pictures I took while unpacking and wrote my first post about the SqueezeBox Duet.


It's only now I'm able to write that I've successfully set up my complete solution as of the start of September. I've been having huge difficulties getting the box to stream audio properly with all sorts of symptoms. I'll spare the long description and cut to the solution, I changed my wireless router settings from its default channel 11 setting to channel 1 and everything sprung into life. During my 3 months of debugging to find this simple solution I contacted Slim Devices through various means, forums, chat channels, and official support. While the staff were extremely keen to help and reasonably responsive given the time difference between California and the UK, at no point did they give me any useful suggestions towards the successful solution. It was this that prompted me to think about the different types of open source. Now I can conclude that you're pretty much on your own with a SqueezeBox, but that's something I can live with quite easily, so now it's working I'm a happy bunny.

For future reference, next time I move house I'll do a scan of the local wireless networks much earlier and change my channel accordingly. I'm no wireless expert but then I'm no dummy either, so when I can communicate over my wireless network with several devices including more than one laptop, a Nintendo Wii and the SqueezeBox Duet Controller, I would suggest it's reasonable to expect the other half of the Duet (the Receiver) to work too. Not so apparently.

Friday 19 September 2008

Turning my house off

HE-307
After talking recently about the stand-by power savers I've been messing with at home I've made another small investment in the Home Easy range. We now have a switch I've located downstairs we can use to turn one or more sockets off in the house. It's a small step I know, but this simple device will effectively become the on/off switch for our house. Currently, we're only using it to control one socket to switch off all the electrical gadgets in the living room such as the TV, DVD hard disk recorder, Wii, etc.

I like the idea of being able to turn your whole house on/off. So this switch has the potential to be extended should I make further investment into Home Easy kit. We could eventually have computer controlled devices all around the house to activate lighting or any electrical device. With one press of this button the whole lot would turn off in order to make power savings as we leave the house or overnight though. As well as saving some cash it gives you a great green feeling of energy saving too, safe in the knowledge that only the essentials are left on at home. For us right now, the essentials are the home server, network router, our fridge-freezer and currently a second freezer to store our surplus vegetables from the allotment. These typically use 130 watts as an average total which goes down from something like 170 watts I think when we turn off the stand-by switch.

I was hoping for a certain amount of traction and community to build up around the Home Easy range, being the first reasonably complete and affordable range of radio controlled devices in the UK. However, that doesn't seem to be the case. I have loads of little questions I would love to ask Home Easy, mostly about future products and their intentions. So far, it's been difficult to communicate with them or other users of the products. For example, their web site has a forum link with a few registered users on the forums, including some staff from Home Easy. In order to get access though, you have to e-mail one particular guy and wait for him to approve your access which isn't ideal. I e-mailed several months ago and I'm still awaiting my ID. Conclusion, the forum isn't very active and the community I was hoping for doesn't exist, yet.

Wednesday 17 September 2008

Dipping my toe back into super computing

I've been out of university and working in IT for a good few years now and held several different roles along the way. When I started work I was doing an internal support role after which I moved to my current department, Emerging Technologies, where I've held several roles including being an emerging tech specialist and working for IBM's Linux Integration Centre.

I've used the attention-grabbing title for the work I very much enjoy doing but due to certain circumstances thought I had left behind in my career. Super computing sounds very grand and conjures up all sorts of ideas along with other grand titles for the type of work I do such as Beowulf Clustering. The term I prefer, but can also be misleading, is High Performance Computing (HPC). There are all sorts of misconceptions about HPC but easily my favourite is when people pretend to joke, but expecting a serious answer ask something like “Wow, how many frames per second can you get on Quake with that?”.

The opportunity has come up for me to go back to this area for a one-off project, working with some of my ex-colleagues. I'm very much looking forward getting stuck in as the work is usually interesting and my old team are fantastic. As ever with these projects, there are an enormous number of unknown's at the start of the project. I already feel at home knowing the list of things we don't know yet – where the hardware is right now (delivery due soon), what the software stack will be, firmware levels, network layout and design, naming conventions, management and monitoring required, storage requirements, job scheduling, operating system, tweaks and configuration, etc. That's all part of the fun though, I get to work things out along the way and fill in the gaps for areas that, for no fault of their own, people just don't think about answering until implementation time. The kick-off meeting is due soon now so I'm looking forward to getting people to think about all the tiny details I'll need in order to supply our customer with the best suited system I can.

Thursday 28 August 2008

Ubiquity for Firefox

Today I was introduced to a new Firefox extension called Ubiquity via the blog post from Mozilla labs. It's a completely different take on the user interface and usability of your web browser. This video explains better than I could...



It's only at version 0.1 right now and it's already amazing so I'm really looking forward to seeing new versions come out as it develops. I'm already a big fan and thoroughly recommend trying it out for something a bit different in your web browsing life!

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!