Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

Android Framework

This is an open source framework to ease the use of this android system services and ease the logging of the data returned by the services.

How to set a GPIO

inti = 10;
com.grimgal.android.framework.GPIOgpio =
com.grimgal.android.framework.GPIO.create(i);
{
gpio.setOut();
}
if (gpio.isOut()) {
gpio.setValue(false); // Sets the GPIO to logical false// Do something in-betweengpio.setValue(true); // Sets the GPIO to logical true
}
else {
// Error handling
}

How to read from a GPIO

inti = 10;
com.grimgal.android.framework.GPIOgpio =
com.grimgal.android.framework.GPIO.create(i);
{
gpio.setIn();
}
if (gpio.isIn()) {
booleanvalue = gpio.getValue();
// Do something with the value
}
else {
// Error handling
}

How to read from a ValueSupplier via the framework

IValueSupplierManagervalueSupplierManager =
IValueSupplierManager.
Stub.
asInterface(
ServiceManager.
getService("VALUE_SUPPLIER_MANAGER")
);
byte[] bytes = valueSupplierManager.
value("$SUP_NAME"); // e.g. ODROID_XU3_FAN_USAGEByteBufferwrapped = ByteBuffer.wrap(bytes)
floatvalue = wrapped.getFloat(); // Beware, not all suppliers return a float.// Some return a double, int, long, char etc.

How to log a ValueSupplier via the framework

Stringlog_directory = "my/log/directory/"; // Beware, write access isn't requestet // by the frameworks and needs to be requestet // by the app!Stringprefix = "my_log_for_suppliert_X";
Stringsupplier = "X";
try {
com.grimgal.android.framework.Framework.init(log_directory, prefix);
IValueSupplierManagerivsm = IValueSupplierManager.Stub.asInterface(ServiceManager.getService("VALUE_SUPPLIER_MANAGER"));
if (ivsm == null) {
com.grimgal.android.framework.Log.e("supplier","ivsm was null");
}
intfound_index = -1;
String[] suppliers = ivsm.list();
com.grimgal.android.framework.Log.v("AppLauncher","Found " +suppliers.length+" Suppliers");
for(intk =0 ; k < suppliers.length ; k++) {
com.grimgal.android.framework.Log.v("supplier",suppliers[k]);
if (suppliers[k].equals(supplier)) {
found_index = k;
}
}
if (found_index == -1) {
// Error handling
}
// Log the value supplied by the value suppliert k each 100ms (10Hz)com.grimgal.android.framework.ValueLog.run(
suppliers[found_index], // Supplier name100, // Periodjava.util.concurrent.TimeUnit.MILLISECONDS// Unit of the period
);
}
catch (IOExceptione) {
// Error handling
}
catch (RemoteExceptione2) {
// Error handling
}
catch (Exceptione3) {
// Error handling
}

License

This project is licensed under Apache 2.0 - see the LICENSE file for details.

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages