Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
README.md | 2013-06-10 | 6.5 kB | |
AndroidSerial-distribution.zip | 2013-06-10 | 77.0 kB | |
Totals: 2 Items | 83.5 kB | 0 |
AndroidSerial for Processing
This is a Processing-for-Android library offering the serial communication.
This library works on Android 3.1 or later since it uses Android USB Host API.
This library also includes usb-serial-for-android containing FTDI serial driver and USB CDC/ACM serial driver (for Arduino). The library still has some issues and also has bunch of improvements according to the google code site. I will update the library when the newer version is released.
Note that this version is alpha release.
How to use
Unzip AndroidSerial-distribution.zip
and copy all files including AndroidSerial
directory to your library
folder (e.g. ~/Documents/Processing/library
).
The usage of the library is almost same as processing.serial.Serial library.
The difference between processing.serial.Serial and this is a static method list()
.
The following code does NOT work on the AndroidSerial library.
println(Serial.list()); // processing.serial library
But this does work,
println(Serial.list(this));
Other methods in processing.serial.Serial class should work without any changes.
Example
You can get a working example from the sparkfun's pulse sensor SEN-11574.
- Install Android SDK Platform 10 as well as Android 3.1 or later (I tried Android SDK Platform 16 Rev. 4, SDK Platform Tools Rev. 16.0.2, SDK Tools Rev. 22, and Processing 2.0)
- Install Android mode on your Processing environment
- Go to the page
- Download the Processing sketch from
Documents
section - Open the downloaded sketch
-
Modify the code as below
L60: println(Serial.list()); // print a list of available serial ports | (add `this`) v L60: println(Serial.list(this)); // print a list of available serial ports L62: port = new Serial(this, Serial.list()[0], 19200); // make sure Arduino is talking serial at this baud rate | (add `this`) v L62: port = new Serial(this, Serial.list(this)[0], 19200); // make sure Arduino is talking serial at this baud rate
-
Please make sure that you need to check and modigy the index of
Serial.list(this)
at the line 62 in order to specify the valid port name - Create
res/xml
directories under the opened sketch directory (e.g.~/Documents/Processing/PulseSensorAmpd_Processing_1dot1
) - Copy
examples/PulseSensor11574/res/xml/device_fileter.xml
to the created directory (e.g.~/Documents/Processing/PulseSensorAmpd_Processing_1dot1/res/xml
) - Copy
examples/PulseSensor11574/AndroidManifest.xml
to the opened sketch directory (e.g.~/Documents/Processing/PulseSensorAmpd_Processing_1dot1
) - Connect your Android 3.1+ device to your computer and Run the code
- The application may report
Unexpected error
on your Android screen but you can ignore it (tapOK
) - Disconnect the Android device from the computer and connect your FTDI device or Arduino to the Android device with USB cable
- Android asks you to choose an application to launch, then choose your application (e.g.
PulseSensorAmpd_Processing_1dot1
) - Finally, you will see the same screen as your computer!
How to build
Install maven and run the command:
mvn clean deploy
And you can find the artifact file named AndroidSerial-distribution.zip
at target
directory.
Directory Structure
The directory structure of this application is as follows:
|-- .settings (E)
|-- libs
| |-- processing
| | `-- android-core
| | `-- 2.0
| `-- com
| `-- hoho
| `-- usb-serial-for-android
| `-- v010
|-- src
| |-- main
| | |-- assembly
| | |-- examples
| | | `-- PulseSensor11574 (X)
| | | | `-- res
| | | | `-- xml
| | |-- java
| | `-- resources
| `-- test
| |-- java
| `-- resources
(E) Eclipse specific setting files (X) is a working example for Sparkfun's Pulse Sensor SEN-11574
Source Code License
All program source codes are available under the MIT style License.
Copyright (c) 2013 Inventit Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Dependencies
- usb-serial-for-android ... LGPL, USB serial driver for Android
- Processing Core ... LGPL, Processing core library
- Android ... ASL 2.0, Android API Library
- SLFJ Android ... MIT, Logging framework
Known Issues
- The release binary will be moved to SourceForge though it is currently put under the project root
- Unexpected error occurs when the sketch is compiled and installed into a device
- The current version of usb-serial-for-android has several issues regarding data reading. If
java.io.IOException: Expected at least 2 bytes
is observed, please wait a moment or try to re-connect the cable though the trunk version of the driver is already fixed
Change History
0.0.1-alpha : June 10, 2013
- Initial