Sensors

1,950 views
Skip to first unread message

babak

unread,
Nov 13, 2010, 3:18:12 PM11/13/10
to android-ndk
Hello All,

I am looking for a way to get data of sensors (especially
Accelerometer) rapidly without using the listener base approach. I am
looking for it in Android NDk, but I can not find any lib that I can
use!
Actually, I am totally beginner in NDk, so anybody knows where can I
find the list of all libraries which are available with Android NDk?

Thank you in advance

Dev Eloper

unread,
Nov 15, 2010, 8:47:38 AM11/15/10
to andro...@googlegroups.com
I wonder wgat would happen if you opeened up the special files under /dev for the sensors your after. I know some of them are in there.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Mike Stone

unread,
Nov 16, 2010, 6:04:53 PM11/16/10
to android-ndk
I am also looking on how to accomplish this so if anyone has any ideas
or suggestions, please enlighten.

Dianne Hackborn

unread,
Nov 16, 2010, 10:16:49 PM11/16/10
to andro...@googlegroups.com
You can't, currently the only API is the listener-based Java API.

Permissions should not allow applications to directly open the underlying devices (heck on some hardware the data may not come from an input device at all).

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Mike Stone

unread,
Nov 17, 2010, 11:50:08 AM11/17/10
to android-ndk
Thank you Dianne for your response.

On Nov 16, 10:16 pm, Dianne Hackborn <hack...@android.com> wrote:
> You can't, currently the only API is the listener-based Java API.
>
> Permissions should not allow applications to directly open the underlying
> devices (heck on some hardware the data may not come from an input device at
> all).
>
>
>
>
>
>
>
>
>
> On Sat, Nov 13, 2010 at 12:18 PM, babak <bnade...@gmail.com> wrote:
> > Hello All,
>
> > I am looking for a way to get data of sensors (especially
> > Accelerometer) rapidly without using the listener base approach. I am
> > looking for it in Android NDk, but I can not find any lib that I can
> > use!
> > Actually, I am totally beginner in NDk, so anybody knows where can I
> > find the list of all libraries which are available with Android NDk?
>
> > Thank you in advance
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "android-ndk" group.
> > To post to this group, send email to andro...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > android-ndk...@googlegroups.com<android-ndk%2Bunsubscribe@googlegr oups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-ndk?hl=en.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com

babak

unread,
Nov 18, 2010, 11:17:09 AM11/18/10
to android-ndk
Thank you Dianne,
but still I have a problem! According to Android 2.2 compatibility
document, device should deliver the accelerometer events in 50Hz or
faster. I am working on HTC Desire, and I just get events each 0.2 sec
which means 5Hz.
What is the problem? How can I reach to 50Hz sampling rate? Is there
any problem with the device? I also checked the Samsung Galaxy S, and
it was worse than HTC Desire.

Regards.
Babak

P.S. If I just want to develop for my own phone, is it possible to
reach the accelerometer data faster?


On Nov 17, 4:16 am, Dianne Hackborn <hack...@android.com> wrote:
> You can't, currently the only API is the listener-based Java API.
>
> Permissions should not allow applications to directly open the underlying
> devices (heck on some hardware the data may not come from an input device at
> all).
>
>
>
> On Sat, Nov 13, 2010 at 12:18 PM, babak <bnade...@gmail.com> wrote:
> > Hello All,
>
> > I am looking for a way to get data of sensors (especially
> > Accelerometer) rapidly without using the listener base approach. I am
> > looking for it in Android NDk, but I can not find any lib that I can
> > use!
> > Actually, I am totally beginner in NDk, so anybody knows where can I
> > find the list of all libraries which are available with Android NDk?
>
> > Thank you in advance
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "android-ndk" group.
> > To post to this group, send email to andro...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > android-ndk...@googlegroups.com<android-ndk%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/android-ndk?hl=en.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com

Dianne Hackborn

unread,
Nov 18, 2010, 3:20:11 PM11/18/10
to andro...@googlegroups.com
Are you actually telling it how fast you want the data?

To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

babak

unread,
Nov 18, 2010, 4:59:59 PM11/18/10
to android-ndk
If I understand you correctly, yes.
I need data in 50Hz or faster. I used registerListener
(SensorEventListener listener, Sensor sensor, int rate), with the
SENSOR_DELAY_FASTEST.
Have you any idea?
> > <android-ndk%2Bunsu...@googlegroups.com<android-ndk%252Buns...@googlegroups.com>

Dianne Hackborn

unread,
Nov 18, 2010, 6:00:21 PM11/18/10
to andro...@googlegroups.com
Try a known working app on your device to see what its behavior is.  For example I think OS / Sensors in ApiDemos will have it report at the highest rate.  You can also use "adb shell getevent" to see the raw events being generated (if your device implements sensors through input events, which most do I believe).  Note that these events are often filtered if they don't change, so if your device isn't moving you may not get many reports.

You would also probably get a lot more help if you asked your questions on a general Android development group like android-developers or stackOverflow, since you are just trying to use one of the normal SDK APIs.

To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.




--
Dianne Hackborn
Android framework engineer

Foad Rezek

unread,
Nov 11, 2013, 4:07:10 PM11/11/13
to andro...@googlegroups.com, hac...@android.com
Hi Dianne,
Do you mean that we cannot override sensor values by other sensor values (obtained from another device for example...) ?
I have a project to do in which I need to inject new values of sensors replacing the original sensors' values, is this possible by any mean ? ( kernel / library.. ?)

Thanks in advance.

Jessica

unread,
Mar 12, 2015, 6:29:27 AM3/12/15
to andro...@googlegroups.com, hac...@android.com
If the underlying sensors are IIO and HID based there is a c application/derivers - generic_buffer in the Linux kernel which can be compiled(cross or using ndk) and can be used to fetch the sensor samples.
e.g : 
./generic_buffer -c <number of samples> -n <sensor_name>
Reply all
Reply to author
Forward
0 new messages