Understanding accelerometer data

Neil Jerram neiljerram at googlemail.com
Fri Oct 30 01:04:48 CET 2009

2009/10/29 Neil Jerram <neiljerram at googlemail.com>:
> It's certainly possible that I've just written my program wrong.  So
> yes, I'll try that script too.

OK, I understand what was wrong with my program now.  It was reopening
the /dev/input/event[2,3] file before every read.  It appears that the
first set of readings after opening contains incorrect data, and
unfortunately that's what my program was getting every time.

My thinking was that I didn't want to use a lot of CPU by reading the
files non-stop; hence I'd sleep for a few seconds between each read.
But then I thought that I might get out of date data, because of the
kernel buffering unread data in the open file object.  To avoid that,
I decided to open, read and close on every iteration of reading the

But I saw while googling that the buffer for these files only holds 64
sets of data - hence if the sample period is 10ms it should only ever
be possible to be up to 640ms out of date.  So the approach of keeping
the file open is fine after all.

Thanks for the help!

More information about the community mailing list