Honeycomb Tablet optimized version of the Android Oscilloscope

The ultimate goal of our Bachelors Thesis one year ago was to deliver a “market-ready” version of our oscilloscope project where you can just install an app from the market and connect the oscilloscope over USB.

Before the “Tablet Age” our idea was to set up the OTG port of a phone for host mode. However, this requires rooting the phone as well as adding a voltage supply to the connector. Not a very elegant solution.

When the first tablets with honeycomb arrived (3.0) we managed to use the host port on a rooted device to get our oscilloscope working. Still, root was required.

With Honeycomb 3.1 it was not only possible to acquire permission of the USB device it also became possible to program USB with the Java API rather than to go native with libusb.

Therefore we have written a tablet optimized version of our oscilloscope. With the all new user interface comes the ability to connect to our USB oscilloscope. You can get the application from the Android Market with your 3.0 and up tablet. Get the source code: HoneyOsciPrime.tar.gz, or the APK HoneyOsciPrime.apk. You can always download our Layout Files here and build your own oscilloscope or contact us for support.

Acer A500 running OsciPrime
Screenshot of the new Honeycomb OsciPrime App

Creating a remote Scroll Wheel for your Linux Machine using Android, Bluetooth and uinput

Scrolling long documents can be tiring for your index finger on a mouse wheel or on a touch pad. What if you could use your phones touch screen to scroll a document on your computer? While maybe not the most ergonomically solution it may well be a good example of how to work with bluetooth, uinput and Android.

Setup
Android Phone ( >= 2.1)
Ubuntu Laptop with Bluetooth
Two great Tutorials:
Bluez: http://people.csail.mit.edu/albert/bluez-intro/x604.html
uinput: http://thiemonge.org/getting-started-with-uinput

Concept
The application consists of two parts:

  • A client side on the phone that serves as touch pad to scroll.
  • A server part on the computer that receives commands from the phone and emulates scroll movement for uinput.

The Client is a simple Android Activity spawning a Bluetooth Thread. Touch events then result in a Bluetooth packet that tell the server if the user moved up or down. The source code is very straight forward; only Thread synchronization is a bit tricky as well as the way how the application is stopped (locks etc.).

The Server application connects the world of Bluetooth (RFCOMM/SDP) with the uinput event input system. Basically the server registers an SDP entry and then listens on an RFCOMM channel for incoming connections. As soon as a connection is established a new input device is created and scroll events are sent. Note that you probably need to be root (or use sudo) on the Linux machine to feed uinput new events.

Instructions

  • Pair your Android phone with the Linux device
  • Start the server on your Linux device: $ sudo ./btserver (make sure BT is turned on, else there could be a segfault -> working on that)
  • Install and start the app on the phone. In the menus select your Linux device.

Building Dependencies
To build the dev-libbluetooth package was necessary on our Ubuntu machine.

The code is available under GPL. Have fun playing around with it 🙂
Note: It’s very straight forward to create a remote control for your Linux machine with the sources. Key presses can be emulated very easily with uinput.

Source Code
Android Sources
Android APK
Server code for Linux
Our App on the Android Market

Leave a comment if you like what we did or have some improvements 🙂

How to programmatically remove/hide the system bar in Honeycomb (requires root)

Without the system bar it is almost impossible to control your Honeycomb tablet. Since no hardware control buttons are enforced for the tablet the system bar is the only way to control your slate.

However, if your application incorporates a way of removing the bar and on leaving restarting the bar there is no reason why not to support such a feature.

The easy part: Restarting the bar

Restarting the bar is pretty simple, drop to a shell and start the service using the “am” command:
# am startservice -n com.android.systemui/.SystemUIService

The difficult part is to shut it permanently down. One way is to navigate to the application settings and shut it down with the “force close” button. However, attempting to kill the process with

# killall com.android.systemui

will remove the bar for a few seconds. Sadly, it will return eventually since in the applications manifest file the “persistent” parameter enforces the system to restart the service unless it is shut down properly by the “system” user itself.

The following magic line will shut down the bar permanently if executed as root:

# service call activity 79 s16 com.android.systemui

What it does is sending the Activitymanager a shutdown signal for the systemui service.
This method was tested on an Iconia A500 with Android 3.01; although it should work with other devices as well (since the source code that we use is common).

Putting it together

To remove the system bar from your application create and execute a process:

Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
proc.waitFor();

To restore the system bar use the following code snippet:

Process proc = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
proc.waitFor();

How to enable FTDI Support for your USB Host featuring Honeycomb Tablet (including sample native application)

For many projects it would be great to have an RFID-Reader on your tablet. Sadly there is no Tablet yet that has a built in NFC Chip. However, there are plenty of Readers that connect through USB to your device, and some of them use an FTDI USB Serial Converter for communication over the serial protocol.

Provided you have a USB Host Port and Root on your Tablet it is possible to communicate with a large number of peripherals that use the FTDI chip. And we want to show you how we did it.

To achieve this goal you will need to compile the Kernel Driver Module for FTDI Support in order to have an interface under “/dev/ttyUSB0” in the end. You do this by downloading the recent Tegra Kernel from the Android Repos:
http://android.git.kernel.org/?p=kernel/tegra.git;a=tree;h=refs/heads/android-tegra-2.6.36;hb=refs/heads/android-tegra-2.6.36

For our purpose we just downloaded a Snapshot of the Kernel.

Note: if you are unsure which kernel version to use, execute step 1 first on your device and return to the repositories to choose the appropriate version.

Follow these steps to compile the new Kernel module.

1. First you need to find the appropriate Kernel version for your Android Tablet. Some manufacturers change the “Extraversion” parameter. Drop into a root shell on the tablet and find out which version you are running; also pull the current kernel config:
# cat /proc/version

extract the kernel config from your device
$ adb pull /proc/config.gz config.gz

2. Set up the current Kernel config for your freshly downloaded Kernel snapshot. Let’s assume you put the the Kernel into ~/kernel/ .
$ zcat config.gz > ~/kernel/tegra-android-tegra-2.6.36-f48009c/.config

3. Configure your new Kernel to create the FTDI module using menuconfig
Let’s say you have your Android NDK under /opt/android-ndk-r5…
~/kernel/tegra-f6874dc$ export PATH=/opt/android-ndk-r5/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/:$PATH
~/kernel/tegra-f6874dc$ make menuconfig ARCH=arm CROSS_COMPILE=arm-eabi- -j4

Navigate to “Device Drivers -> USB Support -> USB Serial Converter Support -> USB FTDI Single Port Serial Driver” [1]
Select it as a Module hitting the “M” key so that it reads “<M>”.

Now adjust the Makefile so the Extraversion fits your extracted version.

~/kernel/tegra-android-tegra-2.6.36-f48009c$ gedit Makefile

4. Compile the module for your system

If you did not yet export the path, then do so now:
~/kernel/tegra-f6874dc$ export PATH=/opt/android-ndk-r5/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/:$PATH

And start compiling the modules:
~/kernel/tegra-android-tegra-2.6.36-f48009c$ make modules ARCH=arm CROSS_COMPILE=arm-eabi- -j4

Your modules should be building now.

5. Your FTDI Kernel module is now located in the “drivers/usb/serial” directory. You can copy it to your tablet now:

~/kernel/tegra-android-tegra-2.6.36-f48009c$ adb push drivers/usb/serial/ftdi_sio.ko /sdcard/

load the module using insmod

~/kernel/tegra-android-tegra-2.6.36-f48009c$ adb shell
$ su
# cd sdcard
# insmod ftdi_sio.ko

And done you are! Connect your FTDI Device (for instance this USB FTDI-Board: http://www.sparkfun.com/tutorials/243) and use this Code to start communicating with your peripheral device (in this case an RFID Reader).

To compile the project files extract them and use Android’s “ndk-build” script.

~/simplectrl/jni$ /opt/android-ndk-r5/ndk-build

The executable file is found in simplectrl/lib/armeabi/simpleserial. Push it to your device, connect your FTDI device and make it executable:

~/simplectrl$ adb push lib/armeabi/simpleserial /data/local/
~/simplectrl$ adb shell
$ su
# cd /data/local/
# chmod 777 simpleserial
# ./simpleserial

This has been tested on a Rooted Acer Iconia Tab A500 with Android 3.0.1 and the Kernel Version 2.6.36.3

We hope we were able to get you started with serial programing over USB 🙂
Don’t hesitate to comment our post and give us some feedback to improve our mini-article.

[1] you will also find the “USB Profilic 2303 Single Port Serial Driver” there, which is used for many USB-Serial Converters.

OsciPrime an Open Source Android Oscilloscope

Today we are releasing our first draft of the new Android Oscilloscope called OsciPrime.
We added a bunch of new features such as:

  • Trigger Offset
  • Signal Offset
  • Cursors for measurement
  • Performance Improvements
  • Running on Beagleboard with Rowboat Gingerbread

The Application is going to run on your phone as well. Although at the moment it requires you be able to record mono at 44100 [Hz] to use Audio.
You might also have to adjust measurement units in the source code.

We packed also libusb if you want to deploy the app on the Beagleboard directly into the APK.

Enjoy 🙂

Download the Source Code

(hint: You can open the menu using the menu button in the application, press once more to close again)