Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Monday, 8 May 2023

Temporary Swap File on Ubuntu

 I am training a Machine Learning (Neural Network, "AI") model for epileptic seizure detection.   An issue I have is that I have a lot more false alarm data than I do genuine seizure data, so I am using 'Data Augmentation' to make more seizure-like data.

Unfortunately when doing this using Python, it seems to eat huge amounts of memory.   The 16GB on my computer is not enough, so I added more swap space using the following:

fallocate -l 16G /swapfile2

chmod 600 /swapfile2

mkswap /swapfile2

swapon /swapfile2


Check it is working with 

swapon --show

or

free -h




Tuesday, 8 May 2012

Trouble with Ubuntu 12.04 LTS

Over the last few days I have upgraded my family's computers from Ubuntu 11.10 to 12.04.   I had been getting a bit over-confident at how good Ubuntu was, and so was not really worried about things going wrong during the upgrade, as I would have been in the past - it had been getting to the state that it 'just worked'.   So I made the mistake of doing the upgrade over a weekend when we were particularly busy, which meant it was a particular pain when things went wrong.   The issues we have had are:

  1. Our PackardBell OneTwo was un-useable - booted to a black screen - didn't have chance to work out why so I just saved some logs to report the bug later, and re-installed 11.10.
  2. My home server (my old Fujitsu Amilio laptop) appeared to upgrade without problems...but every time I tried to access it, it was dead.   I think it was suspending, even though I had set the power settings to never suspend.   Have tried leaving the lid open, with me logged in, with the screen blanked - seemed to be working when I left - need to work out what was going on there....

Monday, 7 May 2012

More on Samsung CLP-325w on Ubuntu

I have been pretty pleased with the Samsung CLP-325w - working nicely from my daughter's Ubuntu PC.
Have just had to re-install Ubuntu 11.10 on that (see separate post), so need to get the printer working again.
I had received a question about why I did not use an open source driver, and used the Samsung one last time.   The main reason was that the 'Recommended' driver when I installed the printer only worked in monochrome, not colour.
Just tried again, and used the 'recommended' driver, which was a generic PCL6 one.  Again this printed monochrome, until I realised that under the 'Printing' options it defaults to 'Normal (monochrome)' print quality.  Changing that to 'Normal' got it printing in colour.
Currently using it plugged into the USB port on the computer, because having a bit of trouble with network printing - job for next weekend.

Friday, 3 February 2012

Ubuntu 11.10 on a Lenovo G570 Laptop

I have just bought myself a new laptop.  I got a Lenovo G570 from PC World for just under £450.  It seems pretty good Intel i5 processor with 4GB Ram.

Installed the 64 bit version of Ubuntu 11.10.  Installation went without hitch.  Initial boot hang for some reason, but switching it off and on again solved that, and it has worked fine since.   Basically everything I have tried worked out of the box - screen, track pad mouse, web cam, USB.   Therefore absolutely no issues - a very good advert for Lenovo and Ubuntu.

I was really surprised at how powerful it is - I just installed a simple OSM tile server on it using the instructions at http://wiki.openstreetmap.org/wiki/Ubuntu_tile_server.   Loading the british isles OSM data extract took less than 2 hours.   My home server (ex laptop) - an intel dual core processor and 2GB Ram running 32 bit Ubuntu takes almost 24 hours.

I am thinking I should have bought 2 of them and use one as the server - it only uses 20 Watts when running at low load, which is probably less than my existing one.....

Tuesday, 13 December 2011

Access Web Server on VirtualBox Guest

I have a Windows computer where I use Oracle VirtualBox to allow me to run Ubuntu Linux.
I just found out how to access the web server on the virtual machine from the Windows Host.
You need to use the vboxmanage command that comes with virtualbox:
First do:
vboxmanage list vms
to list the names all of the virtual machines on the computer, then do:
vboxmanage modifyvm "[virtual machine name]" --natpf1 "http,tcp,,8080,,80"
You can then point your web browser on the windows host to http://localhost:8080 to see the web server on the virtual machine.

I don't know the syntax - see the VirtualBox Manual, Chapter 6 for details.

Sunday, 4 December 2011

Ubuntu Linux on a Packard Bell OneTwo - Update

The Packard Bell OneTwo touch screen computer has not been used for quite a while, so I decided to start using it rather than my daughter's PC, because it uses a lot less power and is quieter.

The main issues from when I tried it before were:

  • Screen flicker every now and then
  • Touch screen calibration issues.
We installed Ubuntu 11.10 on it as a clean install.  Went pretty well.  The issues were:
  1. Used a normal screen shape rather than wide screen.   Solved this by going to the settings / display menu and changing to a 16:10 aspect ratio screen resolution.
  2. Touch Screen Calibration:  This took a while to solve because when you pressed the screen the mouse pointer appeared at a different position.  Eventually I traced it to the display settings that I had altered - Although there is only one monitor on the computer, the software detects two displays (there must be tv-out hardware in the box, but no connector outside).  I had un-clicked the 'mirror displays' option and this had resulted in the two screens being shown side by side.  I didn't think anything of it as there is no monitor connected to the second, but it confused the touch screen calibration - switching the un-used display to 'off' solved it and the touch screen calibration is fine now.
  3. Multi-Touch:  The touch screen works just like a mouse.  I think it should be able to cope with multiple touches so you can do 'pinch' gestures etc. to re-size windows.  This is not working.   I tried using the mtview utility as described in the Ubuntu wiki, and it seems like multi touch is working - you can draw with two fingers at the same time, but the window manager does not seem to be using them.
Therefore, Ubuntu 11.10 worked much better 'out of the box' than the previous version I had tried - the main missing thing is multi-touch support for the touch screen.  This is an important one to fix for me because our son is VERY short sighted, and looks very closely at the screen, often pressing his forehead against it.  Once he has done that, the touch screen does not work because it only detects one press at a time!   I am going to have to learn how x windows input devices work to debug this I think.....

Ubuntu Linux on a Packard Bell OneTwo - Update

The Packard Bell OneTwo touch screen computer has not been used for quite a while, so I decided to start using it rather than my daughter's PC, because it uses a lot less power and is quieter.

The main issues from when I tried it before were:

  • Screen flicker every now and then
  • Touch screen calibration issues.
We installed Ubuntu 11.10 on it as a clean install.  Went pretty well.  The issues were:
  1. Used a normal screen shape rather than wide screen.   Solved this by going to the settings / display menu and changing to a 16:10 aspect ratio screen resolution.
  2. Touch Screen Calibration:  This took a while to solve because when you pressed the screen the mouse pointer appeared at a different position.  Eventually I traced it to the display settings that I had altered - Although there is only one monitor on the computer, the software detects two displays (there must be tv-out hardware in the box, but no connector outside).  I had un-clicked the 'mirror displays' option and this had resulted in the two screens being shown side by side.  I didn't think anything of it as there is no monitor connected to the second, but it confused the touch screen calibration - switching the un-used display to 'off' solved it and the touch screen calibration is fine now.
  3. Multi-Touch:  The touch screen works just like a mouse.  I think it should be able to cope with multiple touches so you can do 'pinch' gestures etc. to re-size windows.  This is not working.   I tried using the mtview utility as described in the Ubuntu wiki, and it seems like multi touch is working - you can draw with two fingers at the same time, but the window manager does not seem to be using them.
Therefore, Ubuntu 11.10 worked much better 'out of the box' than the previous version I had tried - the main missing thing is multi-touch support for the touch screen.  This is an important one to fix for me because our son is VERY short sighted, and looks very closely at the screen, often pressing his forehead against it.  Once he has done that, the touch screen does not work because it only detects one press at a time!   I am going to have to learn how x windows input devices work to debug this I think.....

Wednesday, 16 November 2011

Breaking out of a Frozen SSH Terminal Session

For a long time I have found that if the internet connection is broken during a ssh terminal session that the terminal hangs and the keyboard is un-responsive - CTRL-C, CTRL-D etc. do not do anything.  I have always just cursed and closed the terminal window.

I just found that ~. will break out of the frozen session, giving you access back to the terminal.   ~? gives a list of other escape commands, but I am not sure what I would use those for.

Sunday, 6 November 2011

Samsung Colour Laser Printer and Ubuntu Linux

Note:  You might find a more recent post more useful.

I have got sufficiently sick of my Epson inkjet printer suffering from clogged print heads, and noticed how cheap colour laser printers have become, so decided to give one a try.

I settled for a Samsung CLP-325W (w=wireless) colour laser printer.   The reason for this is that Samsung provide linux drivers for it, and I had an old Samsung laser printer a few years ago that worked nicely with linux.

To start with, the CD that came with the printer would not mount on my daughter's Ubuntu 11.04 machine - no idea why, so we downloaded the Samsung unified driver for linux from the Samsung UK support web site.

We installed the driver by running install.sh as root, plugged in the printer and it detected ok and seems to work.  We had to select the "Samsung CLP-300 Series (SPL-C)" driver, because the recommended "CLP-325 foomatic...." one only printed black and white.

So far, so good!

The fun came when I tried to set up wireless printing so I could print to it from my laptop without my daughter's computer being switched on.   The first attempt was to repeat what I had done for the other computer, and install the Samsung unified driver on my laptop.  Unfortunately it refused to detect the printer, even when it was plugged into the USB port on the laptop.   I never found out why and tried a different approach.

I plugged the printer into my ethernet network and re-started it.  I found out that to print the diagnostics you hold the 'cancel' button (with the triangle symbol on it) for a few seconds.  This printed  out a network diagnostic page that said the network type was 'dhcp' and the ip address was 192.0.0.192.   This is odd because my router, which would act as dhcp server should give out addresses 192.168.1.*, so I assumed that it was lying about using dhcp and had a static default address.
Re-configured laptop to use the 192.0.0.* subnet and tried looking for the printer - tried a web browser, ping and nmap, and no sign of it.

Had a look at my router's dhcp list, and realised that the printer had been assigned an ip address by the router, which was not the one on the network diagnostics!!!!!
Re-printed the network diagnostics and got the correct ip address - don't know what happened there.

Pointed a web browser at the printer's IP address and got a nice status web page, with a 'login' option at the top right hand corner of the screen (once I had scrolled across because I couldn't see it on my laptop screen for some reason....).   Had to search on the internet for the default login credentials - found out that it is user name -  "admin", password - "sec00000".

Once logged in, I could set up the network to use a static IP address (so I always know where it is, and connect it to my wireless network).

Disconnected the lan cable from the printer, and sure enough, I can see the printer from my laptop.  Used the Samsung printer configuration tool to set it up as a network printer on the laptop and....it works!!!

phew!

Friday, 22 July 2011

Building Debian Packages

I worked out how to make simple debian packages by hand as described in a previous post.
Trying to build other software into packages is still rather difficult...
I found a really good, simple tutorial on how to use the debian tools to do this more easily at:
http://www.debian.org/doc/packaging-manuals/packaging-tutorial/packaging-tutorial.pdf.

Friday, 17 June 2011

Ubuntu packages and repositories

Creating Ubuntu (debian) packages always seems a bit fiddly....At the moment I can do it, so thought I'd better write down quickly how I did it.

Packages

  • Create a directory and put the files you want to install into a directory tree under it (e.g. if you create a directory called [pkgname], files that you want in /usr/local/bin go in [pkgname]/usr/local/bin.
  • Create a directory called [pkgname]/DEBIAN and put a file in it called 'control'.  This can be as simple as:
Package: grahamstestdeb
Version: 001
Architecture: i386
Depends:
Maintainer: Graham Jones (grahamjones139@gmail.com)
Description: Test Debian Package

  • Create a file called 'postinst' in DEBIAN.  This will be executed when the package is installed. This can be
  • #!/bin/sh
  • echo "postinst works!!!!"
  • Create the .deb package by doing
dpkg-deb --build [pkgname]
  •  Copy your new [pkgname].deb file into a new folder called repository.
  • Run 'sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz' in the repostitory directory.
  • Upload the repository directory to your web server:
ncftpput -v -R -u maps3.org.uk -p ftp.maps3.org.uk public_html/apt/ *

  • Add the following to /etc/apt/sources.lst 
deb http://apt.maps3.org.uk / 

  • Run sudo apt-get update
  • Run sudo apt-cache search [pkgname] - should find your package.
  • Run sudo apt-get install [pkgname] - should run your postinst script.
For better instructions see: http://odzangba.wordpress.com/2006/10/13/how-to-build-local-apt-repositories/#comment-7304.

Thursday, 19 May 2011

Rendering OpenStreetMap Data using Carto and Mapnik

Mapnik is often used to render OpenStreetMap (OSM) data.   The map style (line colours and sizes, icons etc.) are defined by a style file.  There is a very detailed one provided with OpenStreetMap's mapnik tools.   Unfortunately that level of detail means that the style definition is very complicated and it is hard to follow how it works.
A tool called carto is available which is a pre-processor that will take a simpler format of style file, and convert it into the mapnik file format.   I have been experimenting with trying to render OSM data using styles written for carto.   I had been hoping to use a nice graphical editor with map preview capability called tilemill, but tilemill does not work with postgresql datasources, which are necessary for OSM rendering.   Instead, I installed tilemill and used the version of carto that is included with it, but did not use the tilemill editor.

Carto Layer Definitions
Rendering data with carto needs you to do two things - define the data you want to plot on your map ('Layers'), and define how you want the data displayed ('Styles').

The datasource definitions go in a .mml file that looks something like this:

{
"_center":{"lat":36.870832154494,"lon":-113.79638671427,"zoom":5},
"_format":"png",
"srs":"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs",
"Stylesheet":["style2.mss",
"areas2.mss",
"roads2.mss",
"labels2.mss",
"natural2.mss",
"contours2.mss",
"POIs2.mss"],

"Layer":[
  {"id":"coastline",
   "name":"coastline",
   "srs":"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over",
   "class":"",
   "geometry":"polygon",
   "Datasource":{"file":"/home/graham/OSM/data/mapdata/world_boundaries/processed_p.shp","type":"shape"}},

 {"id":"landuse",
  "name":"landuse",
  "srs":"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs",
  "class":"",
  "geometry":"area",
  "Datasource": {
               "type":"postgis",
      "dbname":"kefalonia",
      "user":"www",
      "password":"1234",
      "host":"localhost",
      "port":"",
      "table":"(select way,landuse,name,\"name:en\" from planet_osm_polygon where landuse is not null) as landuse"
               }
  }
]
}
The first few lines define the projection of the output map, and the stylesheets that are to be used to define how to render the data.   The bulk of the file is layer definitions.   In this example two layers are defined.  One is a shapefile containing the coastlines (the same one that is used by the normal OSM style).   The second layer extracts all areas tagged with 'landuse=xxx'.

We have not told mapnik how to plot the data though - this is done in the style files.  The ones relevant to this example are "style2.mss" and "areas2.mss".  Style2.mss contains:

@land: #e0e0c0;
@water: #C0E0F8;
@waterline: #8CE;
Map {
  background-color:@water;
}
#coastline::outline {
  line-color:@waterline;
  line-width:1.6;
}
#coastline::fill {
  polygon-fill:@land;
  polygon-gamma:0.75;
}
Here the things starting '@' are variables which allow you to define colours etc.  at the top of the file, then use them several times throughout it, making future maintenance easier.   In this example we define the background colour for the map, fill it in blue to represent water.   We then draw a line around the costline, and fill in the land with a separate colour.

The areas2.mss style is slightly more complicated:
#landuse {
   [landuse="residential"]
   {
      polygon-fill: #b0b0b0;
   }
   [landuse="industrial"]
   {
      polygon-fill: #a0a0a0;
   }
   [landuse="forest"]
   {
      polygon-fill: #a0d0a0;
   }
}
In this example the [] expressions are filters, which allows us to define different fill colours depending on the landuse tag.

These are just extracts - the actual styles I am using are getting progressively more and more complicated.   You can see the files, and a modified version of the generate_image.py script provided by OSM, which takes a carto .mml file as input in my svn repository (soon to be copied to github..)

Using these styles, I have updated my kefalonia map to give this:
and this:




These styles are nowhere near as clever as the standard OSM ones.  In particular I have not tried to devine different styles fo rdifferent zoom levels  instead I have two sets of stylesheets for two different zoom levels - I think in the end I will have there - one for a 'country level', another for a 'town level', and a third for higher zoom levels.

There are also a few issues - the line styles do not look as nice as the OSM ones - I do not know why...and there is a problem with the road names where sometimes other roads crossing over each other obliterate the labels.   THe reason is that I draw the road and the label at the same time - it will probably look better if I do the labels after all roads have been drawn.   Will hav eto work out how to do that!



Friday, 29 April 2011

Installation of Carto Mapnik Style File Builder on Ubuntu

I find mapnik style files a bit clumsy to edit - lots of repetition that makes them hard to follow.
There are (at least) two utilities available that may make style file generation simpler.  These are Cascadenik and Carto.
It appears that Carto is being more actively developed at the moment, so I thought I would look at that first. Carto also reports to be much faster than Cascadenink.
The problem is that Carto is new-fangled and uses a javascript based language called node.js.   Despite my dislike of javascript, I thought I would persevere.  This is how I got it working on my Ubuntu 10.10 system:

  • Downloaded node.js version 0.4.7 from http://nodejs.org, and extracted it into /usr/local/node-v0.4.7.  Built with ./configure; make; make install.
  • Installed the node package manager npm using: curl http://npmjs.org/install.sh | sh
  • Installed carto dependencies:
    • npm install get     [used to be node-get, but the module has changed name]
    • npm install step
    • npm install srs
    • npm install underscore
    • npm install zipfile (actually did this twice because one of the document build actions failed on the first attempt...).
  • Downloaded carto using:  git clone https://github.com/mapbox/carto.git
  • No compilation necessary (it is javascript).  Executing cd carto; ./bin/carto gave no nasty errors, just "no input files", which looks promising.
I just need to work out how to use it now.

I have had a quick look at TileMill, which is a web based editor for carto stylesheets - it is very impressive - you can change the stylesheet and preview the map in real time.   The only problem that I have found with tilemill is that it does not seem to work with a postgresql database as the data source, which is where my OSM data is stored.  But at least I should get the idea about the structure of the files using that tool.

Sunday, 3 April 2011

Trouble with mysql, apache, php5 and codeIgniter

I am working on a new web interface to townguide based on php so it can be used on a low cost web hosting service (rendering will be done by a separate computer).
I am going to use the codeIgniter web framework because it seems simple, and is simiar to django, which I was just starting to get used to.....
Alas getting database access working on my laptop for development was difficult.
I have apache, php5 and mysql all working, but whenever I tried to load the database module of codeIgniter I got a 500 Internal Server error, but no errors in either the apache or codeigniter error logs.   This made debugging difficult.
After much searching on the internet I realised it was because I needed to install libapache2-mod-auth-mysql as well as php5-mysql.
Doing sudo apt-get install libapache2-mod-auth-mysql and re-starting apache made the following trivial mysql db connection work:

$conn = mysql_connect('localhost', 'www', '1234');
if($conn) {
  echo 'Finally connected!!!';
 } else {
  die('Still cannot connect' . mysql_error());
 }
?> 
A bit late now, but I think this will also have solved the problem connecting to the database using codeigniter....

Tuesday, 29 March 2011

Disk Crash on Linux

Well, I thought that the introduction of the ext3 (and higher) file systems had stopped all of the problems of disk crashes and mangled filesystems on linux.
But, after a few years of reliable operation the root filesystem on my home server (my old Fujitsu Siemens laptop) seems to have mangled.
The symptoms were....not booting - you get the 'Starting up......' message during boot then the system appears to hang.  But if you listen carefully you hear that the disk is actually doing something.  So I left it for a few hours.....
When I came back to it there was a 'failed to mount /dev/sda1' type error message, with an option to skip mounting or manually fix it.
I went for manually fixing it, because not mounting the root filesystem will not get me very far.
This dropped me into a single user shell.
I ran fsck and it said that an Inode has illegal blocks.  I selected the option to clear them...and again said yes when it asked me again.
It then said it was restarting e2fsck from the beginning, and spent quite a few minutes checking....

Then at Pass 2 fsck said it had found a deleted or unused inode.  Again I said 'y' to the 'Clear?' question....
Then lots of offers to fix things (to the extent that I just held my finger on the 'y' key...)

Then fsck announced that it was complete and I should re-boot linux.   Re-ran fsck and it announced that /dev/sda1 was clean, so re-booted.....but booting is taking a suspiciously long time.....like it has been trying for 10 minutes and hasn't got past the boot up splash screen...I'm going to need a plan B...

Well, I don't know what the problem is.   Tried booting off a USB memory stick, and the disk checks ok and mounts, but the boot process just hangs.   I decided I had spent too long on this so it is currently installing Ubuntu 10.10 on the disk instead, so can't try any more diagnosis!

Friday, 18 February 2011

Mounting FTP Directory as a Filesystem

I just discovered a really useful trick to mount the directory structure of a remote FTP server as a directory on a linux computer.   You use a program called curlftps.   On Ubuntu do:
sudo apt-get install curlftps
The directories on the remote ftp server are then mounted using:
 curlftpfs ftp://[username]:[password]@[server address] [local directory mount point] 
This works fine (you do not even need to be root to do it), but the password will be present if you do 'ps -ef | grep ftp'.
A solution is to create a .netrc file in the /root directory containing:

machine [server address]
login [username]
password [password]
You can then add the file system to /etc/fstab by adding the following line to /etc/fstab:
curlftpfs#[server address] [local directory mount point] fuse allow_other,rw,user,noauto 0 0
You can then just do
sudo mount [local directory mount point]
and you get the same effect with the server password invisible.



Tuesday, 28 December 2010

Personal Weather Station

I have just bought my wife, Sandie a personal weather station from Maplin.  It is a much better one than the simple one that broke recently - it has external humidity as well as temperature, plus wind speed and direction and rain detection.  Most importantly it has a USB connection so we should be able to connect it to an internet weather network so it can appear on our iGoogle home pages.

The maplin version is apparently a re-branded WH1080PC weather station - I chose this one rather than a more modern one because people have managed to get it working with Linux - I want to use a very low power single board computer to interface it, rather than a big PC running Windows.

I have chosen a bifferboard single board computer because it is cheap and has both USB and ethernet connections (I would have liked wireless lan too, but could not find something to do that, so I got the two USB port version of bifferboard, so will have a go at adding a USB wireless network interface card to it later).
My original idea was to use some software called meteoplug because you can buy a bifferboard with that already installed, so I know it would work.  However, when I looked into it, it is a subscription service that is not open source - all I really want to do is obtain data from the weather station and send it to weatherunderground, which can not be that difficult.
Fortunately there is an open source project, pywws, which is compatibly with the WH-1080PC weather station.
I thought it best to get it going on a desktop linux set-up first, then try to get it working on the single board computer.
From my Ubuntu 10.10 laptop I did:
svn checkout http://pywws.googlecode.com/svn/trunk/ pywws
sudo apt-get install python-usb
cd pywws 
python TestWeatherStation.py
Initially this gave an error "IOError: Claim interface failed", so I tried:
sudo python TestWeatherStation.py
Success - a string of numbers, and no errors!

To get rid of the requirement to run the program as root you have to tell 'udev' to give other users permission.
lsusb reports the vendor and product ID of the device (1941 and 8021 respectively), but this is actually reported as a USB missile launcher rather than a weather station.
I added a file called 05-weatherstation.rules to /etc/udev/rules.d, which contained the following line:

SUBSYSTEM=="usb", ATTRS{idVendor}=="1941", ATTRS{idProduct}=="8021", MODE:="0666", GROUP:="usb"

I also added a line to /etc/group to create the 'usb' group, and made myself a member of that group.
Re-started udev with 'sudo service udev restart', and now the test works without being root (note the colon in 'MODE:=' - it is very important!

pywws seems to work suspiciously well - creating a data directory (~/weather/data) and running

pywws/LogData.py -vvv ~/weather/data/
creates a file with some convincing looking numbers in it.   I have created a weather station on weatherunderground, so I think the next thing to do is install the weather station outside, then try to use pywws to send data to weatherunderground.

Personal Weather Station

I have just bought my wife, Sandie a personal weather station from Maplin.  It is a much better one than the simple one that broke recently - it has external humidity as well as temperature, plus wind speed and direction and rain detection.  Most importantly it has a USB connection so we should be able to connect it to an internet weather network so it can appear on our iGoogle home pages.

The maplin version is apparently a re-branded WH1080PC weather station - I chose this one rather than a more modern one because people have managed to get it working with Linux - I want to use a very low power single board computer to interface it, rather than a big PC running Windows.

I have chosen a bifferboard single board computer because it is cheap and has both USB and ethernet connections (I would have liked wireless lan too, but could not find something to do that, so I got the two USB port version of bifferboard, so will have a go at adding a USB wireless network interface card to it later).
My original idea was to use some software called meteoplug because you can buy a bifferboard with that already installed, so I know it would work.  However, when I looked into it, it is a subscription service that is not open source - all I really want to do is obtain data from the weather station and send it to weatherunderground, which can not be that difficult.
Fortunately there is an open source project, pywws, which is compatibly with the WH-1080PC weather station.
I thought it best to get it going on a desktop linux set-up first, then try to get it working on the single board computer.
From my Ubuntu 10.10 laptop I did:
svn checkout http://pywws.googlecode.com/svn/trunk/ pywws
sudo apt-get install python-usb
cd pywws 
python TestWeatherStation.py
Initially this gave an error "IOError: Claim interface failed", so I tried:
sudo python TestWeatherStation.py
Success - a string of numbers, and no errors!

To get rid of the requirement to run the program as root you have to tell 'udev' to give other users permission.
lsusb reports the vendor and product ID of the device (1941 and 8021 respectively), but this is actually reported as a USB missile launcher rather than a weather station.
I added a file called 05-weatherstation.rules to /etc/udev/rules.d, which contained the following line:

SUBSYSTEM=="usb", ATTRS{idVendor}=="1941", ATTRS{idProduct}=="8021", MODE:="0666", GROUP:="usb"

I also added a line to /etc/group to create the 'usb' group, and made myself a member of that group.
Re-started udev with 'sudo service udev restart', and now the test works without being root (note the colon in 'MODE:=' - it is very important!

pywws seems to work suspiciously well - creating a data directory (~/weather/data) and running

pywws/LogData.py -vvv ~/weather/data/
creates a file with some convincing looking numbers in it.   I have created a weather station on weatherunderground, so I think the next thing to do is install the weather station outside, then try to use pywws to send data to weatherunderground.

Ubuntu Linux on a Packard Bell OneTwo

This post is a record of me getting Ubuntu Linux (Release 10.10 - Maverick) running on our new Packard Bell OneTwo all-in-one touch screen PC.   I will update it as I make progress fixing the bits that have caused problems.

Installation
Installation was pretty easy - I booted of an Ubuntu 10.10 USB memory stick, and selected manual disk partitioning.
I kept the Windows 7 partition (/dev/sda1) unchanged, and did not touch the other two windows partitions (/dev/sda2 and /dev/sda3).   I deleted the blank 'Data' partition (/dev/sda4) and created a new swap partition (/dev/sda5) and ext4 root partition (/dev/sda6).
Installation went without problem and the machine now dual boots Ubuntu and Windows 7.

Note that I did have a funny happening yesterday when the machine completely refused to boot after I had been using windows.  I fixed this by booting off the USB memory stick and re-installing grub as described in a previous post - This has not happened again.

Audio
Worked out of the box.

Video
Ubuntu did not detect the correct screen size initially - it used a normal aspect ratio rather than wide screen, so only the centre of the screen was used, and the touch screen calibration was way out - this is because it thinks it has two displays (I don't know where the second is - there is no VGA or s-video connector on the back).
This was fixed by going to the System->Preferences->Monitor menu and un-checking the "Same image in all monitors" option.
You can then drag the main screen (labelled "Laptop") away from the second (labelled "Unknown") and set the laptop resolution to 1600x900 resolution.

This makes the screen the correct size, but every now and then it flickers twice within less than a second - it seems that the screen backlight dims momentarily before coming back to full brightness.  This seems to be associated with disk activity - I don't know what causes this - it does not do it in Windows - Any suggestions for fixing it would be appreciated!.

Touch Screen
I was impressed that the touch screen worked 'out of the box' once I had fixed the monitor resolution issue.
Update 01/01/2011 - I decided to do a clean install of Ubuntu 10.10, just in case I had mangled it installing different testing packages going through bugs on launchpad.   Having done the install and updating all packages using update manager, the touch screen is working perfectly - pressing the screen is the same as moving the mouse to the location and left click - Success!!!! (I hope!)  - Ok, I'll give it a couple of days to make sure it doesn't beak before I say success.

Unfortunately there are problems with it.   It seems that once you have done a 'drag' using the touch screen, x-windows thinks the mouse button is still pressed - moving the real mouse changes the shape of the drag region, and worse still, the real mouse button stops working.   Sometimes the keyboard stops working too (both mouse and keyboard are wireless, using a USB receiver)


Investigations so far:
sudo apt-get install input-utils
provides a program called 'lsinput'.  Doing
sudo lsinput
lists the touch screen as:


/dev/input/event6
   bustype : BUS_USB
   vendor  : 0x408
   product : 0x3001
   version : 272
   name    : "PixArt Imaging Inc. Optical Touc"
   phys    : "usb-0000:00:1a.2-1/input0"
   uniq    : ""
   bits ev : EV_SYN EV_KEY EV_ABS EV_MSC
Installing multi-touch utilities by doing:
sudo apt-get install utouch libutouch-grail-dev utouch-grail-tools
sudo apt-get install mtdev-tools
bzr branch lp:~utouch-team/utouch/mtview
cd mtview
make
Provides amongst other things a utility called mtview.  Running that lets you draw pretty patterns on the screen using multi touch - it certainly seems capable of detecting and tracking two fingers at once.
Given this I think the touch screen is basically working, and it is the interface to x-windows that is the problem.
I'll have to work out how x-windows drivers work to fix this though....



I will update this section as I investigate further.

Web Cam
Not tested.

Ubuntu Linux on a Packard Bell OneTwo

This post is a record of me getting Ubuntu Linux (Release 10.10 - Maverick) running on our new Packard Bell OneTwo all-in-one touch screen PC.   I will update it as I make progress fixing the bits that have caused problems.

Installation
Installation was pretty easy - I booted of an Ubuntu 10.10 USB memory stick, and selected manual disk partitioning.
I kept the Windows 7 partition (/dev/sda1) unchanged, and did not touch the other two windows partitions (/dev/sda2 and /dev/sda3).   I deleted the blank 'Data' partition (/dev/sda4) and created a new swap partition (/dev/sda5) and ext4 root partition (/dev/sda6).
Installation went without problem and the machine now dual boots Ubuntu and Windows 7.

Note that I did have a funny happening yesterday when the machine completely refused to boot after I had been using windows.  I fixed this by booting off the USB memory stick and re-installing grub as described in a previous post - This has not happened again.

Audio
Worked out of the box.

Video
Ubuntu did not detect the correct screen size initially - it used a normal aspect ratio rather than wide screen, so only the centre of the screen was used, and the touch screen calibration was way out - this is because it thinks it has two displays (I don't know where the second is - there is no VGA or s-video connector on the back).
This was fixed by going to the System->Preferences->Monitor menu and un-checking the "Same image in all monitors" option.
You can then drag the main screen (labelled "Laptop") away from the second (labelled "Unknown") and set the laptop resolution to 1600x900 resolution.

This makes the screen the correct size, but every now and then it flickers twice within less than a second - it seems that the screen backlight dims momentarily before coming back to full brightness.  This seems to be associated with disk activity - I don't know what causes this - it does not do it in Windows - Any suggestions for fixing it would be appreciated!.

Touch Screen
I was impressed that the touch screen worked 'out of the box' once I had fixed the monitor resolution issue.
Update 01/01/2011 - I decided to do a clean install of Ubuntu 10.10, just in case I had mangled it installing different testing packages going through bugs on launchpad.   Having done the install and updating all packages using update manager, the touch screen is working perfectly - pressing the screen is the same as moving the mouse to the location and left click - Success!!!! (I hope!)  - Ok, I'll give it a couple of days to make sure it doesn't beak before I say success.

Unfortunately there are problems with it.   It seems that once you have done a 'drag' using the touch screen, x-windows thinks the mouse button is still pressed - moving the real mouse changes the shape of the drag region, and worse still, the real mouse button stops working.   Sometimes the keyboard stops working too (both mouse and keyboard are wireless, using a USB receiver)


Investigations so far:
sudo apt-get install input-utils
provides a program called 'lsinput'.  Doing
sudo lsinput
lists the touch screen as:


/dev/input/event6
   bustype : BUS_USB
   vendor  : 0x408
   product : 0x3001
   version : 272
   name    : "PixArt Imaging Inc. Optical Touc"
   phys    : "usb-0000:00:1a.2-1/input0"
   uniq    : ""
   bits ev : EV_SYN EV_KEY EV_ABS EV_MSC
Installing multi-touch utilities by doing:
sudo apt-get install utouch libutouch-grail-dev utouch-grail-tools
sudo apt-get install mtdev-tools
bzr branch lp:~utouch-team/utouch/mtview
cd mtview
make
Provides amongst other things a utility called mtview.  Running that lets you draw pretty patterns on the screen using multi touch - it certainly seems capable of detecting and tracking two fingers at once.
Given this I think the touch screen is basically working, and it is the interface to x-windows that is the problem.
I'll have to work out how x-windows drivers work to fix this though....



I will update this section as I investigate further.

Web Cam
Not tested.