androidthings / sample-simplepio

Basic Peripheral I/O examples with Android Things
Apache License 2.0
187 stars 79 forks source link

Request documentation for Peripheral Manager objects from NDK #2

Closed hpsaturn closed 7 years ago

hpsaturn commented 7 years ago

Hi, I was testing GPIO with last Google Things image via /sys/class/gpio but I must run it as root user. Whats is correct way for call "PeripheralManagerService" from C++ (NDK) and grant right permissions? In general, where is documentation for NDK layer?

Many thanks, great job guys!

hpsaturn commented 7 years ago

I’m answering to myself, the last strategy used was: I used reflection so from the native layer I can access the Java layer and control the GPIO’s exposed by the framework (Peripherical Manager Service) but the performance is really bad.

My testing code (~300 kb firmware) takes around a minute in GoogleThings image (using the C++ driver and root user) but in Android Things (space user) it is taking around an hour (C++ - Java hybrid solution). Additionally, I tested with wiringpi and it only takes a few seconds (on Raspbian without sysfs gpio)

mangini commented 7 years ago

@hpsaturn You are correct that the best way at the moment is going through the Java layer. We have plans to expose NDK direct bindings in the future. Can you please report a feature request in b.android.com so that you can get updates? Thanks!

hpsaturn commented 7 years ago

Many thanks for answer, the feature request is ready: https://code.google.com/p/android/issues/detail?id=231484&thanks=231484&ts=1483569714

mangini commented 7 years ago

thank you!