Friday, 16 April 2010

Claudia black makes this look good

OK maybe the title is a bit of a reach, but she is pretty and my topic is dull.

It is the school holidays and between entertaining the kids I have been experimenting with the vala (see there is the link to the title) language. Overall I really like it, building a usable graphical GTK application is a snap and that side of it works well.

Unfortunately, and here comes a a whole pile of fail, the documentation is lacking, not just poor but mostly non-existent. You rapidly discover yourself using the Glib and GTK library documentation to try and infer how things work.

Underneath, the vala compiler is clever, it is really a c code generator. It takes your vala source file converts it to c and compiles it. When it works smoothly it works very well, when something is not quite right you can end up with a large pile of pieces complete with the C compiler spitting out cryptic nonsense.

This is all exasperated to new heights of madness when you want to access a simple c library. I say simple because if you want to access a Glib based library its easy and "there is an app for that". Because vala is object oriented c interfaces must be described as an object. This description is performed using vapi files. The file format is documented by the simple approach of "we already wrapped a load of libs go look at their vapi files"

For my small starter project I wanted to access a tiny c library I had written. The entire interface described in a single header header (excluding copyright) is:
typedef enum motor_dir {
motor_off = 0,
motor_forward = 1,
motor_back = 2,
motor_brake = 3,
} motor_dir;

int edgerbtarm_init(void);
int edgerbtarm_close(void);
void edgerbtarm_ctrl_motor(int motorn, motor_dir direction);

Yes that is it! one enum, an initialise a finalise and a single operation function. The vapi file I came up with after a great deal of trial, error and head scratching was.
[CCode(cheader_filename = "libedgerbtarm.h",
lower_case_cprefix = "edgerbtarm_",
cprefix = "")]
namespace edgerbtarm {
[CCode(cprefix = "motor_")]
public enum motor_dir {
off,
forward,
back,
brake
}

public int init();
public int close();
public void ctrl_motor(int motorn, motor_dir direction);
}
This seemed to work until I tried to use the motor_dir type within my vala code at which point the c compiler started throwing errors about undeclared macros
arm.vala.c:297: error: ‘EDGERBTARM_TYPE_MOTOR_DIR’ undeclared (first use in this function)
I struggled for some time and finally ended up asking my friend Enrico for help. He initially suggested I simply use an int instead of the motor_dir type and cast when I needed to. This approch worked and let me compile the program, it did however seem a bit grubby and removed the type safety of the enum.

Then Enrico came up with the "correct" solution. the enum description in the in the vapi file needed an extra parameter so vala would know the enum did not have a Glib type...yeah it was obvious to me too :-/

so by altering the vapi file enum declaration to
[CCode(cprefix = "motor_", has_type_id = false)]
public enum motor_dir {
off,
forward,
back,
brake
}
Everything works as you might expect and the motor_dir enum can be used as a type within the vala program with no more fuss.

So the outcome of all this is that while vala is an interesting language which I may well use again in future, one should be aware that it is still very immature as a solution and has nowhere near enough documentation especially round the awkward stuff where it needs it most.

Monday, 8 March 2010

Music hath charms to soothe a savage breast, to soften rocks, or bend a knotted oak.

Since I last mentioned music back in January I have accumulated another ten albums and unlike last time where there were only a couple of stand outs, this time I have he opposite problem.

The unordered list:

Justin Sandercoe - "Small town eyes"

I am learning to play the guitar, I have been using Justins' course, it is very very good, this album? Also very good. If you like melodic guitar lead music with varied influences this is for you. A couple of tracks made me immediately think of some Crowded House riffs (which is not a bad thing). Only minor niggle is the uneven levels on some of the louder pieces, but it really is a minor observation on an otherwise fine first album.

Molly Lewis - "I made you a CD, but I eated it."

Although this is only a short selection of original material from Molly, it is a very promising first album. I really like her voice and although a ukulele is not generally the most well respected of instruments, in her hands, it has an odd charm. This album is available from DFTBA records.

Rhett and Link - "Up to this point"

A pair of talented comedians who use music very effectively to highlight their humour. I originally stumbled across them on youtube and decided to take a punt. The album is 27 short pieces which fit together surprisingly well. Difficult to categorise but think a cross between Flight of the Choncords and Jonathan Coulton with a dash of youtube immediacy.

They Might Be Giants - "Flood", "Apollo 18" and "John Henry"

Strictly a replacement of the old tapes which have completely disintegrated in the intervening couple of decades since first purchased. Flood is still one of my favourite albums ever, certainly in my top 10. If you do not know them TMBG are just ace, please try their music!

Seasick Steve - "Started out with nothin and i still got most of it left"

Well its a kinda fun album primarily based on blues electric "guitar" (some of the instruments are little more than a stick with a nail in and a guitar pickup.) Nothing bad, easy to get along with, definitely worth a listen.

La Roux - "La Roux"

This synth pop album was on remainder in ASDA and I took a gamble. Its OK I guess and for 3quid I cannot really complain.

Red Hot Chili Peppers - "By the way"

Not their best, but competent enough.

Aqua - "Aquarium" , "Aquarius"

Um...yes, I have a soft spot for 90's cheese OK? Nothing more than a gross self indulgence of my silly side. But they are fun ;-)


So that is my new music since January all 166 tracks of it . Most of it pretty good, certainly no lemons (well aside from the Aqua but that is supposed to be silly!)

Oh and The XX has really grown on me from last time and I am looking forward to their next release.







Squashfs

Well my last post elicited a response from Mr Lougher the squashfs author. Just not one I was expecting. Apparently he did receive one of my emails (I sent five in total) to which he has not replied as I have accidentally come across as critical.

This is absolutely not my intent and I wish to publicly say that, It would have perhaps been more constructive to actually tell me this by email and this misunderstanding could have been avoided.

For reference The final email in the series is reproduced below, if I have been overly unhelpful please let me know in the comments so I can avoid this mistake in future.

Hi, we are using Squashfs and have come across several issues. We
initialy tried to use the Debian source package of the 4.0 release but
then moved to using the the CVS edition which fixed some bugs but had
issues of its own.

Couple of things to start with:

- The commit you made recently titled "Change get_basename() to use
getcwd rather than getting the PWD env var." does not seem to be
what you intended?
http://squashfs.cvs.sourceforge.net/viewvc/squashfs/squashfs/squashfs-tools/mksquashfs.c?r1=1.145&r2=1.146

- I would like to assist in improving these tools so they work better
for our use cases. To aid in this have you considered updating the
revision control system the project is kept in? an SVN or GIT
repository is much easier to work with than CVS.

- I will probably assist with maintainership of the Debian and Ubuntu
packages (I am a Debian Developer ) and would
like to bring a couple of patches to your attention, one to avoid a
division by zero error and a second to enable building with
alternative libc. These are both attached to this mail.

- The tools currently make a number of assumptions about structure
alignment which are incorrect on some architectures. I am crafting
a patch to address this which should make the tools work correctly
on ARM (they currently simply segfault).

I hope this is seen as constructive and we can work together to
improve this software. If you do not feel you want to interact with me
and choose to take a differnt route, please let me know at your earliest
conveniance.

I do hope that Mr. Lougher will accept that I intended to be helpful and constructive and not cause offence. I have chosen to use the blog format for this as that is the form I made the previous complaint and also email between myself and Mr. Lougher appears somewhat erratic.

It should be noted that some of there points have already been addressed, however there are several more issues which I hope to be able to contribute towards.


Wednesday, 3 March 2010

Limited Success

I spent the day working with Daniel. He has been trying to get the correct runes for a GCC build in a strange environment. Turns out all he needed was me to throw stupid ideas at him until one caused him to examine some of the generated intermediate symbol maps...

Turns out that busybox awk fails in an interesting way which (eventually) causes half the symbols to be missing in the stage 1 libgcc.so object. Switched to using gawk and managed a successful build.

Seems to be a relatively good time for solutions, last week I managed to make squashfs-tools work on ARM. Unfortunately the author seems to be completely unresponsive to my (repeated) emails (if anyone wants the patch series feel free to mail me). The main issue with the tools is their complete blind assumption that a c structure can simply be cast to an arbitrary character array and get sensible results.

The structure casting method simply does not work on ARM (or indeed any platform which has alignment restrictions) without at least adhering to some minimal rules, primary among these is that the structure *must* be aligned to a word (32bit) boundary and that if you have 16bit or 8bit quantities within the structure they may cause gaps between members i.e. the structures are not packed by default.

No this behaviour is not a bug, it is perfectly acceptable by the c standard. Just because on x86 the practice of arbitrary casting works does not mean it is safe or sensible. Nonetheless many programmers simply do not want to believe its wrong.

Anyhow, rant over, back to work!

Tuesday, 16 February 2010

Tempus fugit

Seems I managed to loose a month in there. Been working very hard on a project with an improbable deadline which has not left much time for anything else.

Finally brought to a standstill this weekend by something Joshua brought home (I think it was some form of micro biological warfare agent, judging by how I feel) It is incrediably hard to shrug off the lethargy of illness when you realize all you have to go back to is work.

On the plus side the project deadline is in three weeks time so whatever happens It will all be over by then! Whereupon I can take some time off, calm down and then start all over on the next project...

Yay?

Tuesday, 5 January 2010

Back to work

Well that is the end of my time off, tomorrow it is back to work. However my break started with snow and it seems its finishing that way.


Unfortunately despite my previous enthusiasm this weather is becoming a little tedious. Schools have been closed today so I had to child mind instead of getting anything done.

Speaking of getting things done...I have completely failed to do anything productive whatsoever for the last couple of weeks. I have played some computer games, watched some TV read some books and listened to music and you know what? Aside from a tiny guilty feeling, I have thoroughly enjoyed myself.

I suppose I should apologize for not contributing to all those open source projects that could have used my help, but that would imply remorse which I seem to be lacking. Oh well

Mentioning music, I have acquired a selection of new music over the holiday which I ought to talk about. In no particular order:
  • Iron and Wine - "Our Endless, Numbered Days"
  • Paramore - "All We Know Is Falling", "RIOT" and "Brand new eyes"
  • Phoenix - "Wolfgang Amadeus Phoenix"
  • Lady Gaga - "The Fame Monster"
  • The xx - "XX"
  • Muse - "The Resistance"
  • Cymbals Eat Guitars - "Why There Are Mountains"
  • St. Vincent - "Actor"
  • Carter Burwell - "Twilight-The Score"
  • The Darkness - "Permission to Land"
  • Oasis - "Stop the Clocks"
  • Chameleon Circuit - "Chameleon Circuit"
  • Hank_Green - "I'm So Bad at This" and "So Jokes"
Unfortunately none of it was outstanding which sometimes happens when I take a punt on a large pile of new music. On the upside none of it was particularly bad either, so a kind of "no win" deal. Though on re-listening the "XX" album is starting to grow on me and the albums from the DFTBA label are so inexpensive they are more than worth it.

Tuesday, 22 December 2009

Time off

I have the time over Christmas off, partly because I needed some distance from work but mostly because the children need looking after while their schools are on break.

Usually switching off from the work mindset is hard for me and I end up "helping" anyway. Not this time...come last Friday at quitting time I was gone. I was apparently in desperate need of this break and spending time with the kids has been great.

It has also been snowing! I used to love the snow when I was a kid and watching the boys build a snowman and have a snowball fight brought back good memories. It somehow has less amusement value when you are older and have to go to work in it and deal with all the problems with transport induces in the UK. Did I mention I was off work? ;-) I had a great time with them...and got a very cold neck.

I have also managed to solve the cat box problem. Turns out it was not the boxes, their placement or type. It seems they wanted three to choose from! They now have three boxes in which to sprawl and they use the original two in the original locations...just as long as they have the option of a third they are happy.

Now I have unwound sufficiently I am looking at tackling some Open source projects of my own which I have been neglecting. I am planning on finishing my whether station recording software and feeding my observations to the weather underground. Possibly doing some more work on Netsurf and maybe even fixing some RC bugs for Debian.