Vala DataInputStream.read_int32 in accelerometer message

MicVM ssj2micvm at
Sat Oct 10 22:08:56 CEST 2009

I am trying to build a vala library to access the accelerometers of the
freerunner. I am using vala just to give it a try but I am experiencing
strange problems and wanted to ask if some of you can give me some hints.
When i read from the input interface of an accelerometer i get the following

b 3 d1 4a 42 ea d 0 0 0 0 0 0 0 0 0
1b 3 d1 4a 79 f e 0 3 0 1 0 6c 0 0 0
1b 3 d1 4a d7 f e 0 3 0 2 0 26 4 0 0

that looks quite good to me. However, when I try to read the values in the
message as integers i have a problem when reding the "value" field, i.e. the
last 32 bit signed integer of the message. I get strange values around +300
instead of +1062 for the Z value as in the last line of the above example.
Also for X and Y the values are wrong. I read the stream with the following
code snippet in vala (using GIO libs):

var data_stream=new DataInputStream(file_stream);

//Skip time field, 8 bytes

//Read eventtype

I think somewhere I am doing a major mistake because the decoding of the
int32 is a basic functionality that does not work in my case. The funny
thing is that decoding of uint16 is done correctly such that eventtype and
code are read correctly. Any help is appreciate :)
View this message in context:
Sent from the Openmoko Devel mailing list archive at

More information about the devel mailing list