Sep 14

I’m pretty excited I got my USB GPS receiver in the mail today.  It’s even small enough that Canada Post was able to fit it into my small apartment mailbox.  No going to the depot to pick it up!  It’s a little bit larger than I would have thought, but still pretty small (about 1.5 x the size of regular USB thumb drive).  Here is a picture of it:

It took me all of 5 minutes to get it running in Ubuntu.  All you need to do is enable the Prolific Serial to USB module called pl2303.  After that, you need to set the baud rate to 4800 and off you go.  Here is a quick list of the commands required to get this receiver running:



$ sudo modprobe pl2303
$ sudo echo "pl2303" >> /etc/modules
$ dmesg
... lots of output snipped ...
[ 1003.292048] usb 2-1: new full speed USB device using uhci_hcd and address 3
[ 1003.496629] usb 2-1: configuration #1 chosen from 1 choice
[ 1003.499558] pl2303 2-1:1.0: pl2303 converter detected
[ 1003.519282] usb 2-1: pl2303 converter now attached to ttyUSB0
$ stty 4800 < /dev/ttyUSB0
$ cat /dev/ttyUSB0
... press Ctrl+C to stop reading from the device

That’s all there is to it! Now I’m off to write a Python script to set the baud rate, read the output, and parse it into something more useful. After that I can start working on integrating it into the GPS applications I just started writing (more on this in a later post).

More Information:

  • Share/Bookmark
Sep 11

“British Prime Minister Gordon Brown apologized Friday for the “inhumane” treatment of Second World War code-breaker Alan Turing, who was convicted of gross indecency for being homosexual at a time when it was illegal in Britain…”

Read the story on CBC.ca

  • Share/Bookmark
Sep 11

I’ve had this super simple “Web Service” up on my other website for some time now, and I’ve used it fairly often through the browser and in scripts. I decided to make an even simpler one on CodeBrainz.ca for others and myself to use. The old service returned a single-node XML document, which is basically pointless and just adds a tiny bit of complexity on the client who is using it. The new address of the service is:

http://showip.codebrainz.ca

The actual code for the new service is a whopping 1 line of code:

<?php
 
echo $_SERVER['REMOTE_ADDR'];
 
?>


I’ve whipped up a couple ultra simple apps and a pointlessly simple library to save writing a few lines of code. The bash script is for for *nix-style systems while the .NET binaries are for Windows/.NET/Mono.

Here are links to each file:

I hope someone out there finds this simple service as useful as I have.

  • Share/Bookmark
Sep 11

I’m posting this table here mostly for my own reference but also for anyone else that might find it handy. I can’t count how many times I’ve searched for these values. To use the table, find the desired resolution, and find the corresponding color depth and that will be the value you need to put in your bootloader to get the kernel to boot with the non-default resolution.

For example in GRUB, open the config. file (in Debian/Ubuntu it’s at /boot/grub/menu.lst in most cases). Find the line that corresponds to the kernel you want to use the new resolution, and at the end of the line, add vga=XXX where XXX is a value from the table below. When you’re putting the video mode into the bootloader, use decimal and it will be converted to hex for the kernel.

Colours System 640×400 640×480 800×600 1024×768 1152×864 1280×1024 1600×1200
4 Hex - - 0×302 - - - -
Dec 0 0 770 0 0 0 0
8 Hex 0×300 0×301 0×303 0×305 0×161 0×307 0×31C
Dec 768 769 771 773 353 775 796
15 Hex - 0×310 0×313 0×316 0×162 0×319 0×31D
Dec 0 784 787 790 354 793 797
16 Hex - 0×311 0×314 0×317 0×163 0×31A 0×31E
Dec 0 785 788 791 355 794 798
24 Hex - 0×312 0×315 0×318 - 0×31B 0×31F
Dec 0 786 789 792 0 795 799
32 Hex - - - - 0×164 - -
Dec 0 0 0 0 356 0 0


Key: 8 bits = 256 colours, 15 bits = 32,768 colours, 16 bits = 65,536 colours, 24 bits = 16.8 million colours, 32 bits - same as 24 bits, but the extra 8 bits can be used for other things, and fits perfectly with a 32 bit PCI/VLB/EISA bus.

Additional modes are at the discretion of the manufacturer, as the VESA 2.0 document only defines modes up to 0×31F. You may need to do some fiddling around to find these extra modes.

Source: http://tldp.org/HOWTO/Framebuffer-HOWTO-5.html#ss5.3

  • Share/Bookmark
Sep 08

I posted this on CodeProject a while back…

“The library is meant to simplify getting the current weather conditions (as well as a 2 day forecast) into your .NET programs. I have created various objects to wrap the functionality provided by the Yahoo! Weather RSS Feed. I have enumerated various variables in an attempt to make the library simpler to use…”

View the article on The Code Project.

  • Share/Bookmark
Sep 08

Here’s a very simple PHP script I whipped up to get the names, sizes, and mount state of a disk or partition in GNU/Linux or similar OS. It’s meant to be used on the shell in other scripts, so the output is easy to parse.

Use is as follows:

diskinfo [options] DISKNAME

DISKNAME is the name of the disk or partition, with or without the /dev/ portion. The script accepts several options, the --version option shows version and license information, the --help shows the version message and a help/usage message. The -s option makes the size of the disk or partition be printed in bytes, with -b in blocks, or with -h as a more appropriate unit (KB, MB, GB, etc.). The -m option displays whether the disk or partition is mounted or not, 1 if it is or 0 if it’s not. Have a look at the code, it’s fairly easy to see what’s going on and/or modify the behavior.

Download the script file, make it executable, and put it in a location in your $PATH environment variable (ex. /usr/bin) or call it otherwise.

  • Share/Bookmark
Sep 06

Not sure why there isn’t a whole lot of information on doing this, but I wanted to install Ubuntu 9.04 using the Alternate CD on my EeePC using a USB drive, so here’s a little guide for preparing the installation USB drive.  Hopefully someone out there will also find it useful.  Don’t hesitate to ask if you have any question about installing Ubuntu this way.

What you need:

  • The hd-media image for Jaunty
  • The Ubuntu Alternate CD ISO Image (x86 or AMD64)
  • A USB drive that will be completely erased, so back it up first
  • A computer running Ubuntu (or other GNU/Linux distro)


The Process:

I’m assuming the person following this guide is fairly comfortable with the command line and knows how to determine which device your USB drive is detected as.  If you don’t know how to do this, Google is your friend.  I’ll only warn about this once, but if you don’t get the right device name, there is a possibility that you will screw up one of your other partitions, possibly hosing your whole system, or at least wiping the wrong partition.  On my system the USB drive is detected as /dev/sdb so I will use this in my example, obviously substitute whatever you USB drive is detected as.  CONTINUE AT YOUR OWN RISK!

We’re going to do this as root, so be careful!

sudo su		# enter your password

Then we’ll setup a temporary location to do our thing in.

mkdir /tmp/altinst && cd /tmp/altinst

Now we’ll download the required files, the hd-media image and the Alternate CD image.

wget http://archive.ubuntu.com/ubuntu/dists/jaunty/main/installer-i386/current/images/hd-media/boot.img.gz
wget http://mirror.csclub.uwaterloo.ca/ubuntu-releases/9.04/ubuntu-9.04-alternate-i386.iso

Note that I’m using a Canadian mirror, feel free to choose another mirror closer to you if you want. They are listed on this page.

The next thing is to erase and prepare the USB drive. This isn’t really necessary if your USB drive already has a single FAT partition that is empty.

Start by blowing away any existing partition table on the disk.

dd if=/dev/zero of=/dev/sdb bs=1M count=1

I’m using cfdisk here to do the partitioning, but use whatever program you want (ex, fdisk, sfdisk, etc).

cfdisk /dev/sdb

Using the cfdisk program, create a single primary partition and set its type to 0c (FAT32 LBA). After the partition is created we’ll format it.

mkfs -t vfat /dev/sdb1

Ok, so now that we have a nice clean USB drive with a single FAT partition, we’ll copy the hd-media image onto the USB drive.

zcat boot.img.gz >/dev/sdb1

Now we’re almost done, we just need to copy the Alternate CD image onto the drive. First we’ll mount the partition.

mount /dev/sdb1 /mnt

Then we’ll copy the image to the USB drive.

cp ubuntu-9.04-alternate-i386.iso /mnt/

That’s it! You now have USB drive that you can use to install the Ubuntu Alternate CD without a CDROM drive.

You can now delete our working directory:

rm -r /tmp/altinst
  • Share/Bookmark
Sep 03

As part of a project I’m working on to create a GPS/mapping program and to learn about GIS in general, I’ve started working on class library to represent geographical coordinates (latitude and longitude) and to convert between the various formats/representations of those coordinates.  It also includes the beginnings of a Parse() method, which is not tested and likely doesn’t work yet, which will take in virtually any common coordinate string and convert it to a Coordinate object.

It probably took longer to document the class than it did to write the code, but it may prove useful to others, so it was worth it.  When I get a chance, I’ll attach a binary/dll for download along with the accompanying XML documentation.


If anyone uses this, make sure to let me know if you find any problems so I can update my code.

Here is the current C# code file:
Coordinate Class File

Will re-upload the file shortly.

  • Share/Bookmark
Sep 01

It doesn’t get much easier than this:

using System.Net;
using System.Net.NetworkInformation;
...
public static bool Ping(string ipAddress)
{
    System.Net.NetworkInformation.Ping ping =
        new System.Net.NetworkInformation.Ping();
    IPAddress address = IPAddress.Parse(ipAddress);
    PingReply reply = ping.Send(address, 30);
    return (reply.Status == IPStatus.Success) ? true : false;
}
  • Share/Bookmark

1,134 spam comments
blocked by
Akismet