<br><br><div class="gmail_quote">On Sun, Oct 11, 2009 at 1:38 AM, MicVM <span dir="ltr">&lt;<a href="mailto:ssj2micvm@gmail.com">ssj2micvm@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I am trying to build a vala library to access the accelerometers of the<br>
freerunner. I am using vala just to give it a try but I am experiencing<br>
strange problems and wanted to ask if some of you can give me some hints.<br>
When i read from the input interface of an accelerometer i get the following<br>
bytestream:<br>
<br>
b 3 d1 4a 42 ea d 0 0 0 0 0 0 0 0 0<br>
1b 3 d1 4a 79 f e 0 3 0 1 0 6c 0 0 0<br>
1b 3 d1 4a d7 f e 0 3 0 2 0 26 4 0 0<br>
<br>
that looks quite good to me. However, when I try to read the values in the<br>
message as integers i have a problem when reding the &quot;value&quot; field, i.e. the<br>
last 32 bit signed integer of the message. I get strange values around +300<br>
instead of +1062 for the Z value as in the last line of the above example.<br>
Also for X and Y the values are wrong. I read the stream with the following<br>
code snippet in vala (using GIO libs):<br>
<br>
var data_stream=new DataInputStream(file_stream);<br>
data_stream.set_byte_order(DataStreamByteOrder.LITTLE_ENDIAN);<br>
<br>
//Skip time field, 8 bytes<br>
data_stream.skip(8,null);<br>
<br>
//Read eventtype<br>
eventtype=data_stream.read_uint16(null);<br>
while(eventtype!=0)<br>
{<br>
        if((eventtype==3)||(eventtype==2))<br>
        {<br>
                code=data_stream.read_uint16(null);<br>
                if(code==0)<br>
                {<br>
                        x_value=data_stream.read_int32(null);<br>
<br>
                }<br>
                if(code==1)<br>
                {<br>
                        y_value=data_stream.read_int32(null);<br>
                }<br>
                if(code==2)<br>
                {<br>
                        z_value=data_stream.read_int32(null);<br>
                }<br>
<br>
....<br>
<br>
I think somewhere I am doing a major mistake because the decoding of the<br>
int32 is a basic functionality that does not work in my case. The funny<br>
thing is that decoding of uint16 is done correctly such that eventtype and<br>
code are read correctly. Any help is appreciate :)<br>
<font color="#888888">--<br>
View this message in context: <a href="http://n2.nabble.com/Vala-DataInputStream-read-int32-in-accelerometer-message-tp3801000p3801000.html" target="_blank">http://n2.nabble.com/Vala-DataInputStream-read-int32-in-accelerometer-message-tp3801000p3801000.html</a><br>

Sent from the Openmoko Devel mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@lists.openmoko.org">devel@lists.openmoko.org</a><br>
<a href="https://lists.openmoko.org/mailman/listinfo/devel" target="_blank">https://lists.openmoko.org/mailman/listinfo/devel</a><br>
</font></blockquote></div><br>What is the maximum frequency at which you are able to read the accelerometer values?<br>Are you able to sample the values properly?<br>Are the reading in X and Y changing smoothly?<br><br>Here is a test that I conducted:<br>
<a href="http://www.youtube.com/watch?v=Bdads8XAYcE&amp;feature=fvsr">http://www.youtube.com/watch?v=Bdads8XAYcE&amp;feature=fvsr</a><br><br>Sriranjan<br>