Thursday, 6 November 2008

MBWE Fuel Gauge -> Speedometer conversion

The Fuel gauge on the front of my MBWE is fairly useless, noone cares, so why not repurpose it as a speedometer?

first, stop it displaying the "fuel" Stolen from http://kyyhkynen.net/stuff/mybook/reduce_disk_usage.php

Disable the service that displays the disk usage with the leds in the front panel of your MBWE. Admit it, the feature is pretty much useless and because the service has to check the amount of free space on the disk(s), it is causing disk access.

In order to prevent the service from starting during boot, edit /etc/init.d/S15wdc-fuel-gauge. Comment out this line:

$FGD &

Then stop the service:

# /etc/init.d/S15wdc-fuel-gauge stop
Once all thats done, this is my script (The ultimate in lazy)
#!/bin/bash
INITIAL_RX=`cat /sys/class/net/eth0/device/net:eth0/statistics/rx_bytes`
sleep 10
FINAL_RX=`cat /sys/class/net/eth0/device/net:eth0/statistics/rx_bytes`
DELTA_RX=`expr $FINAL_RX - $INITIAL_RX`
KBPS_RX=`expr $DELTA_RX / 10240 `

let "RESULT = $KBPS_RX / 3"
echo $RESULT > "/sys/devices/platform/wdc-leds/leds:wdc-leds:fuel-gauge/brightness"

The 3 in there is the scaling factor between the kbps download and the number of lights on.
Since I'm not often downloading any faster than about 400kbps, and when i am im not really worried about i


0 to 100: lights one led (5 o’clock)

100 to 150: lights two leds (5 and 7 o’clock)

150 to 200: lights three leds (5, 7 and 9 o’clock)

200 to 250: lights four leds (5, 7, 9 and 11 o’clock)

250 to 280ish: lights five leds (5, 7, 9, 11 and 1 o’clock)

280ish and more: lights all leds.



I have the whole thing running as a cronjob every 5 minutes
, do that urself

Monday, 27 October 2008

My conkyrc

Contents (what you get out of this)
Weather, HDDtemp, UL/DL speed and cumulative meters, CPU load, Folding@Home status, Remote transmission download status (could be local, easy change), gmail status, RAM usage, Uptime, Date/Time, ToDo list

These all automatically update dependant on the execi variable.

Preface (What you need to get this all working)
Linux OS (Ubuntu?)
Conky (obv, see someone elses guide for how to get that *HINT* synaptic is ur friend)
Transmission download manager (local or remote)
Folding at home installed with origami (could be local or remote using the same logic as the Transmission manager)
Passwordless SSH authentication (if your using this with any remote hosts)
A todo list on the desktop called todo (strange that...)


WARNING I'm lazy so im not telling you why or how this all works. Work it out yourself. I Got alot of the system monitoring stuff from a variety of places (lifehacker i think, my apologies to whoever i stole from).


The Guts (The Guts)
cat .conkyrc
use_xft yes
xftfont verdana:size=8
alignment top_left
xftalpha 0.8
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,sticky,skip_taskbar,skip_pager
double_buffer yes
draw_shades no
draw_outline no
draw_borders no
stippled_borders 10
border_margin 4
border_width 1
default_shade_color grey
default_outline_color black
default_color BADCDD
use_spacer none
no_buffers yes
uppercase no
text_buffer_size 512
color1 F8DF58


# ${color 6694B2}${font OpenLogos:size=45} u t

# ${color F8DF58}${font StyleBats:size=16}8${font} Battery: ${battery_percent}% ${battery_bar}
TEXT
${color BADCDD}${font weather:size=82}${execi 600 ~/scripts/conditions.sh}${color}${font}${voffset -25} ${execi 1200 ~/scripts/pogodynka.sh}
${font weather:size=28}x ${font}HDD ${execi 1 ~/scripts/hddmonit.sh}�C
${font PizzaDude Bullets:size=16}v${font} Up: ${upspeed eth1} Kb/s
${font PizzaDude Bullets:size=16}r${font} Down: ${downspeed eth1} Kb/s
${font PizzaDude Bullets:size=16}M${font} Upload: ${totalup eth1}
${font PizzaDude Bullets:size=16}S${font} Download: ${totaldown eth1}
${color ffffff}${font StyleBats:size=16}A${font} CPU0: ${cpu cpu0}% ${cpubar cpu0}
${font StyleBats:size=16}A${font} CPU1: ${cpu cpu1}% ${cpubar cpu1}
${font StyleBats:size=16}Y${font} ${execi 10 origami monitor | awk '/Progress:/ {print $2}' | sed '/%$/N;s/\n/ /' }
${execi 600 ssh REMOTEUSER@REMOTEHOST /opt/bin/transmission-remote -l |sed 's/ [ ]*/\t/g'| awk -F'\t' '/ing/ {print $3,"\t", $9}'| sort -rn}
${color F8DF58}${font FreeSans:size=16}@${font}${execpi 300 python ~/scripts/gmail_parser.py GMAILUSER GMAILPASSWORD 3}
${color C2E078}${font PizzaDude Bullets:size=16}J${font} $mem / $memmax
${font StyleBats:size=18}P${font} Work: ${uptime_short}
${font Radio Space:size=14}${time %A %d %Y}
${font Radio Space:size=55}${time %H:%M}
${color F8DF58}${font FreeSans:size=10}${color0}TODO:${color1}
${color F8DF58}${font FreeSans:size=10}${execi 30 cat /home/USERNAME/Desktop/todo}

Saturday, 25 October 2008

Getting Skype to work with weird webcams.

I'll keep this as informative.
If your webcam works in ubuntu (I'm running the 8.10 RC atm, fantastic btw) under cheese but not with skype, I did a bit of digging and cheese uses v4l2 (the 'new' webcam api) which inherently screws up skype that uses v4l1.

So, its easy enough since i came across this post and after chasing up my own system locations (this guy must be on 64bit, but i didnt ask) dead easy, instead of in the terminal going
# skype
look in your library directories (/usr/lib/ or /usr/lib32/) for v4l1compat.so,
# LD_PRELOAD=/path/to/v4l1compat.so skype
this, obv, preloads that library forcing skype to use teh right interface library.

If my explanation is wrong please correct me

Monday, 6 October 2008

Links

As Other Folks have been going in a GTD fashion, I'll be throwing useful websites and links into this post so my sievelike menory can cope with the multitude of things that come to my attention.

LectureFox Free Online Lecture Directory
MyBook Hacking Easy Peasy List Of Tutorials For Screwing with the WD My Book WE II
13 Of the Best Linux Tutorials and OpenCourseWare on the Web
Best Passwordless SSH authentication tutorial I've seen (complex but simple)
Google Courses Looks pretty good
SSH quick reference
The Academy The Videos look quite good
Euler

Wednesday, 24 September 2008

Primers Coming Up

Thru my work I'm thrown into alot of technologies that i dont nearly know enough about and as with alot of tech related things, the education scene is basic basic basic..GURU with little or no gradiation, so what I'm going to do is post what i learn when i learn it and where i learn it from and hopefully it'll be useful for someone else, and I'll also take the opportunity to rehash stuff I've already done.

ATM I'll probably be doing Bash scripting, Perl Scripting, XML, and whatever UNIX stuff comes up whenever I'm writing, but for now and for a relativly simple start; X display fowarding...

This is the setup: Linux/Unix based "client" and "server"; in my case I have headless systems that i fiddle with from time to time, but after a while vim just becomes a pain, and as for viewing html files etcetc copying things back and forth is a pain in the ass.

The solution is already there; From its beginning the X server has always been client server based on some level. Basically what were gonna do is tell the server to use the client as an X display; this is controlled thru an environment variable, strangly called DISPLAY

Lets assume were using SSH. *nix SSHd has a simple system for fowarding and routing the relevent X ports (these wont show up in your "tunnels" tab if your using something like putty, but you shouldnt be using putty anyway)

Theres two versions of this fowarding ability, X and Y. in a nutshell, X is compressed and encrypted. Y isnt. On slow links, Y is probably your best bet, also some servers dont support the X flag. Also also, some sysadms disable this X fowarding.

Anyway, to the point. 
login to the server thusly
client# ssh user@server -X

then when you get a shell check to see if DISPLAY isnt already set (some servers are good enough to do this for you)

server# echo $DISPLAY

if your lucky it'll say localhost:10.0
otherwise it'll probably say :0.0 or something similar

If your in this unlucky situation, just enter
server# DISPLAY=localhost:10:0

then try it out, by running the clock and forking it into the background (&)
server# xclock &


Job done. Later

Sunday, 14 September 2008

Long Extended Break: Hardware Update


So, gonna do a quick write up on my current setup.
Ok, from the top:
Linksys WRT54GL DD-WRT v24 std firmware (also running on the bottom right screen)
Generic Wireless headphones (not used since i heard someone else on the channel :P )
top screens : Windows server 2008 AMD Athlon X2 64 6000+ on an Nvidia MCP 65 based motherboard carrying 6GB, with the dangerous RAID 0 arrangement of two 500GB sata drives and an IDE 320GB for essential backups. (this system is hidden, lol)

The bottom two screens run off of an old Toshiba Laptop that i "repurposed", more or less the keyboard has been removed and the screen flipped around and re positioned, Intel Celeron something or other, 512 MB memory, 60 GB HDD, running Ubuntu Hardy Heron that i mainly use for chat, downloads, news, system monitoring and notes.

Fairly standard hidden speakers and everythings as hidden so i get to be messy the rest of the time. 

As for functionality, i use the laptop as an always on remote access hub that also lets me dial into work from anywhere. Also, since the laptop is keyboard mouseless, I use synergy to automatically start the client on the laptop (using the desktop as the server)

FYI easy enough to set up, just insert this:
/usr/bin/killall synergyc
/usr/bin/synergyc (server)

in these
/etc/gdm/Init/Default
/etc/gdm/PostLogin/Default
/etc/gdm/PostSession/Default
/etc/gdm/PreSession/Default

And this more or less starts and stops the server at every stage of bootup and login (note, you are not going to get to play with BIOS options et al, read the synergy FAQ

Anyway, Otherwise, I've been working on alot of bash script that I will post about separatly, but I am going to be learning perl so i will hopefully be using this thing alot more than usual.

Later guys

Saturday, 24 May 2008

EEEpc note

Ok, got the 900, sorry this blog is very very late

Pros:
AMAZINGLY small, you wont believe how small it is until you use one
The keyboard is just managable
the Webcam is amazing quality when it works
More responsive than i imagined
The Extra 16GB SSD really helps
Wonderfully fast bootups (If you never plug it in to any accessories (other than charger) set the Boot Booster enabled under the BIOS, trims a second or two)

Cons:
Battery life less than expected
Wireless strength depends on the driver you use
Webcam and Webcam-mic not fully functional (currently) under Ubuntu 8.04


What I've done:
Managed to get a dual boot system between the Xandros OS and Ubuntu 8.04 by resizing my home partition on the 16GB SSD and installing in there (dont bother with a swap drive)
Grub works wonderfully and straight out of the install i still have both the standard and recovery boot options thru xandros.

As for install, use this
And for tweaking use this BUT to fix the sound you have to go back in and re fix alsa (the 700 tweak doesnt work for the 900)

  • Edit /etc/modprobe.d/alsa-base and change the line “options snd-hda-intel model=3stack-dig”to “options snd-hda-intel model=auto”

  • ALSO, run the following command:

sudo alsactl store
  • Run:

sudo alsactl restore

I think that was all i had to do for basic operations.

Also got Kismet and the Aircrack-ng suites working with a bit of giggery pokery with an aim of stealing my dads old GPS and getting gpsmap to work properly, My personal recommendation is to install both from source, in the case of aircrack, you need to go into the folder that was built and make sure that all of the generated binary files are copied to /usr/bin or /usr/sbin depending on how paranoid you are (I'm not) because the install script doesnt install airmon, aireply, ivstools, packetforge, and a few other things i cant remember off the top of my head

As for the kismet source, i use source=madwifi_ag,atho,atheros and instead of relying on kismet to open the card as monitor, i use airmon and wlanconfig to kill the other interfaces first, eg

sudo wlanconfig ath0 destroy
sudo airmon-ng start wifi0
kismet (i did the suidinstall of kismet so there is no need for sudo. for a single user system the suidinstall is probably easiest)

I cant really talk about the performance of aircrack because truth be told i wouldnt have the patience for a 900MHz to get thru that kinda work, i collect as many packets as i can and get my dual core 3GHz 64bit system to do the dirty work (also usually do this over ssh if i can get an alternate connection, am working on a system where the ivs file can be emailed and an email reply will be sent back, with either the key, or "MEGAFAIL")

Anyway
Battery life. thats a joke. Its less that the 701 my dad has. yeah, yeah, i know, its more powerful, bigger screen, that wud be fine if it wasnt just the UK getting the kneecapped batteries:

List of countries getting 5200mAh battery:TW,HK,USA,CAN,IT
4400mAh:UK

If anyone is reading this please go to http://forum.eeeuser.com/viewtopic.php?id=27140 and make your voice heard, cus i want the battery that was handed out to reviewers! (the forum explains it better than me)

Tuesday, 13 May 2008

EEE Update etc


Just got a call from home saying that my EEE was delivered today, now thats what i call super fast delivery, kudos to clove for being so speedy

On another note my dad is cycling from ballymoney in northern ireland to montouliers in the south of france, he has an EEEpc 701 with him and hes been using it to make a blog here

Another Uni Project

If anyone is interested in Erlang B Calculations, very relevent to any communications or engineering students, I've written a little quick piece of code to calculate them.

There are several levels of functionality in the code.
Erlang B itself only has 2 variables, System load in Erlangs, and the number of "trunks" (read: servers/call center operators/phone lines), and its output is a blocking probability from 0 to 1

All three of these variables or none atall can be defined at runtime;
  • The desired blocking probability can be input to stop the calculation at that point. (default 0)
  • The Load can be defined (See Erlang A) (default 1)
  • The maximum trunks to be calculated (default 100)
The code uses the unistd.h library for argument parsing so is more or less unix only (or cygwin alternativly) and long doubles for more or less everything inside the code.

Having tested the limits, it kinda conks out then calculating large (read 1000 erlangs) on large trunks (got as far as 1234 trunks, then died)

When i get a bit of time i might optimise the factorial part so it doesnt run thru the entire factorial sequence for each number.

Anyway, the code is here. I'm not wasting my time laying out code on blogger.

I want

Jeff Han, a researcher at NYU, surpassed himself again with the most georgous multitouch display interface I've ever seen (surface/iphone eat your heart out). I always love watching TED talks, and if anyone really wants to see a good reason why Powerpoint should be killed, I'd recomment Hans Roslings talk on global poverty here

Monday, 12 May 2008

Asus EEEpc

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

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

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.


Sunday, 11 May 2008

Update

Yeah, suprise suprise, I'm actually gonna try and keep this up.

One of the major reasons for the delay since my last documented fiddle as been job hunting for a placement year next year, but I've wonderfully secured a position with Ericsson Ireland in their Athlone R&D centre. Pays good, experience is even better.

Beyond that a few other things have been making things hectic, not least of which is the impending Examination period so about the only techy thing I've been able to come up with has been a wipe and reinstall to upgrade to Hardy Heron (8.04) (I didnt update because i dont trust dist-upgrade's ability to do things my way, also meant i could blow out the cobwebs in my filesystem.)

As for that, i have to say I'm very impressed. I started out in my Linux days with Red Hat 3, when RH was OSS. Oh how times change.

I have to say tho that i was expecting more substantial differences; especially in the fact that I'm using the 64bit edition on 64 bit hardware but still have to get the stupid crappy 32 bit implementation layers for something as simple as flash (and thats not even working inside Firefox, thankyouverymuch).

Ahh, firefox, what can we say.... well, very little anymore i guess. Were all used to Firefox being a great browser but sucked up memory like an Altzimers Hooker, which allowed us to have sentences like "Everythings perfect except the memory".

Now that problem is sorted, were left with this slim slender spritely... well... fox. Now the other flaws are apparrant, like the (naturally tainted but still troublesome) security issues that just-keep-popping-up.

Ok, rant over, I love firefox, absolutly brilliant, even better now it doesnt sit on memory like a paraplegic elephant. I'm really just diverting the disappointing lack of 64 bit support across the board.

No Acrobat Reader.
No Official Google Earth. (something that could do with better math)
Actually, i cant think of many mainstream pieces of code that DONT need the 32bit interoperation libraries.

Anyway. I'll update when I'm less ranty

Monday, 7 January 2008

CES 2008

Ok, its been a bit quiet in the old experimentalism, but im just taking in Bill Gates' CES keynote, and there are a few things i wanted to comment on.

I HAVE NOT SEEN ANYTHING THAT IS NOT ALREADY EXISTING

Calendars with multiple events and shared events : GCal

Calendar integration with events: GCal + Facebook

Video Search: Gootube

Uploading Videos from cellphones: Depends on provider, but combination of twitter and a mobile email

Multiple sign ins:  OpenID, or, if like me you are a google-phile, its already more or less done.

Surface in stores: Bill, only you and a few select others have the "funds" to shop /buy a snowboard from a store that has a surface. Get realistic. Other than that, i think that the Surface is the most optimistic/interesting bit.

Surface in vegas: people are only just inching into using computer based book reading, you think that cardhogs want to give that up? you dont fly to vegas to play virtual poker.

Silverlight: "Everythings fine at the minute so we'll throw another different propriatory standard just to screw with them"

Olympics:Ok, i concede, that is kinda cool... but i wait for the day that the olymics are free and open and fair to all, kinda like the games them self perhaps?

Vista great operating system for gaming? :no comment.......

XBox as media centre: Honestly, best thing to come out of microsoft in years, given the right interoperability (thank you DivX XviD compatability) 

Remote DVR: Slingbox?

Zune Social: Ok, nice, but this could be done with a mashup of pandora, facebook/myspace, and any media player with statistics. Not many portable media players take statistics. Also, alot of that "closed loop of discovery" already exists in itunes.

Ford Sync:*refuses to make another windows in car joke* empherical comment, when was the last microsoft product that wasnt released with serious security flaws? "Get that great easy experience" ignoring the bluetooth syncing, voice training, etc etc.

Automatically calling 911: what happens if someone kicks the front of your car, setting off the airbag, and ur in the store?

Mobile search with voice:  Voice recognition has been promised for over 10 years say no more

Visual recognition: if this is genuine, this is the dogs bollix, I'd love to know whats running the recognition software and how far away this is. I notice the lovely cable on it which i assumme means that the device requires alot higher bandwidth than bluetooth or short range RF and more processing than can be squeezed into a lab box.

Slash: Everyone loves slash, but shes cute.

I'm all for connectivity and combining devices, but nobody (sane) uses devices from the same manufacturer. I use Windows for my desktop, yes. And Windows Mobile 5 on my pocket pc (altho thats a rant for another day), but i have a sony ericsson symbian phone, Linux based server, i use google for my mail, calendar, and rss feeds, Pidgin / Gaim for my IM, podget for my IPTV, VLC for my iptv also, Picasa for photo managment, winamp for music managment, Opera for web browsing, and so the list goes on.

Is there no company or big name that is gonna stand up and say "We'll support our competitions product in some way", especially when the competition is OSS.

End of Rant