Archive for May 12th, 2008

Asus EEEpc

Monday, May 12th, 2008

Just off the phone with Clove saying that my shiny new black eee 900 is winging its way to my homestead, which unfortunatly is not wer i am, but at least i wont be losing any time for revision (read: have any other reasons not to study)

I have to say I’m really disappointed with Asus’s attitude to they’re british customers regarding the battery issue and i really cant say any more about it except that were paying above the board globally, and not getting an equivalent product and an even less equivilant service.

Nevertheless I’ll be installing Ubuntu as soon as i get my grubby little mits on it, and will hopefully get some pictures, maybe actually get off my ass and do a how to. Might install an internal bluetooth mod aswell…..

On a brighter note, i really have to say Clove have been fantastic, i ordered mine about a month and a half ago and called me back the next day telling me that they were looking at a mid may delivery date, and then called me when the white eee’s came in stock at the beginning of the month, i pointed out that i had previously changed my order to the black, and they were great about it. Highly recommended! Not expensive atall either!

www.clove.co.uk

DISCLAIMER : no i dont work for them

Folding Code

Monday, May 12th, 2008

I’ve been folding for a while now, and I’d previously written a really very cobbled together way of parsing my unitinfo.txt files, but, searching for something to do other than revise, I’ve written a similarly cobbled together but much shorter way of parsing my folding progress and telling me (as in speech) how far its going.

Required: Espeak, basic bash knowledge to adjust.

note: the espeak adjustments are just personal preference, so change them at will.

Its kinda a cheat cus it calls itself but isnt recursive. I’m just lazy


#!/usr/bin/env bash
case "$1" in
"-v")
points | espeak --stdin -s200 -v en+f4
exit
;;
"-w")
points | espeak --stdin -s200 -v en+f4 -w $2
exit
;;
*)
echo "Folding Stats at "&& date +%H:%M
echo "CPU1:" && cat /var/folding/foldingathome/CPU1/unitinfo.txt | grep Progress | cut -d'[' -f1 | cut -d' ' -f2
echo "CPU2:" && cat /var/folding/foldingathome/CPU2/unitinfo.txt | grep Progress | cut -d'[' -f1 | cut -d' ' -f2
exit
;;
esac

it doesnt look very pretty on the console but i think it sounds alright.

Better get some calculus done

::Edited for new version of code with wavfile output

Embedded C GPS Project

Monday, May 12th, 2008

Afternoon folks, I’m supposed to be studying but dont have the heart to, so I’m documenting a recent project from Uni.

The remit was to be able to parse RS232 data coming in from a GPS unit and reformat it for a LCD display. I dont have the part numbers handy but I was programming on a 18F series PIC that supported C.

Most of the ancillary code is more platform dependant, such as working with the PIC interrupts etc, so for the purposes of this code snippit, assumme that a NMEA sentence (I used RMC and some RMB, but never really finished that bit) stored as a character buffer, and a structure, as defined, to store relevent data in.

PLEASE read up about NMEA sentence structure before continuing

typedef struct message
{
//date
int day, month, year;

//Time
int hour, min, sec;

//lat
int lat_deg;
float lat_min;
char lat_ref;

//lng
int lng_deg;
float lng_min;
char lng_ref;

}message;

Since NMEA sentences are comma separated values, I kinda cheated and iterated thru the string, replacing the commas with terminating characters and recording the next positions as character pointers.

for(i=0;i<BUFFERSIZE;i++){
if(end)buffer[i]=0; //wipe the rest of the sentence

if(buffer[i]==42&&check==1){ //asterix
check=0;
if(checksum==chr2hex(&buffer[i+1])) valid=1;
else valid=0;

i+=2; //get to the end of the checksum

end=1; //this is the end of the current sentence
}
if(check)checksum^=buffer[i];
if(buffer[i]==36){ //dollarsign

buffer[i]=0;

check=1;

AddToList(&(buffer[i+1])); //ignore first character

}
if(buffer[i]==44){
buffer[i]=0; //replace all commas with nulls
AddToList(&(buffer[i+1])); //add next position to list of words
}
}

The first character(dollar sign) is ignored because it is never needed beyond this point.

The NMEA sentence structure includes a asterix delimited checksum, i.e everything after the dollarsign and before the asterix is progressivly XOR’d and the hex value representation of this result is concatenated on the end of the sentence before transmission.

the chr2 hex function simply converts two ASCII characters to their Hex value equivalent.

AddToList, strangly enough, adds the pointer passed to it to a wordlist, which is an array of character pointers.

Now we have a list of pointers, because i used a character pointer array, and ended all the strings with nulls, we essentially now have individual strings for each part of the NMEA sentence, that can be addressed directly. eg:
{ //GPRMC
getTime(words[1],&incoming);
getDate(words[9],&incoming);
getLat(words[3],&incoming,*words[3+1]);
getLng(words[5],&incoming,*words[5+1]);
}

In this instance, the get functions all take two arguments, what to read from, and where to put it.

For anyone whos interested the full code is here

I guess i better do some work then.