Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 23 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,43 @@
# Serial Port communication library for Android (with Java API)
# Serial Port Comms for Android - Java

This is a serial port library for Android, with both JNI API and Java API.
This is a serial port communications library for Android with Java API on top of C++ implementation with JNI interface.

The Java API is bridged to JNI implementation, and not all of the API is strictly tested. Use it at your own risk.
The underlying implementation is wjwwood's cross-platform serial library https://github.com/wjwwood/serial.

This library is based on wjwwood's cross-platform serial library https://github.com/wjwwood/serial.
[TOC]

### NOT UNDERT MAINTIANCE
I'm too busy to maintain this open source project.
You can fork and made any changes whenever needed.
# Technology

* Android
* Native Development Kit (NDK)
* Java
* C++

### Documentation
# Source Code

* Native API: See original C++ document at http://wjwwood.github.com/serial/
* Java API: See javadoc in source files.
git clone https://github.com/stevebroshar/serial-android.git

### Dependencies
# Debug

* NDK r21e
Run in Android Studio.

### Install
# Consume

Get the code:
Add the source files to your project or import it as an Android Library project.

git clone https://github.com/chzhong/serial-android.git
# Contributors

Build Native Code:

Android Studio NDK support is still in beta, so please build the so files using ndk-build:

cd android/library/src/main/jni
./build-jni.sh
William Woodall <wjwwood@gmail.com>

Any change to native code it build with Android Studio are welcome.
John Harrison <ash.gti@gmail.com>

NOTE: There might be some issue while building with different NDK revisions.
Cheng Zhong <hust.zcheng@gmail.com>

Use:
Steve Broshar mister.broshar@gmail.com

* Use it directly in your native code.
* Import it as an Android Library project.
# License

### License
## wjwwood's cross-platform serial library

The MIT License

Expand All @@ -54,15 +49,4 @@ The above copyright notice and this permission notice shall be included in all c

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.

### Authors

William Woodall <wjwwood@gmail.com>
John Harrison <ash.gti@gmail.com>

Cheng Zhong <hust.zcheng@gmail.com>

### Contact

William Woodall <william@osrfoundation.org>

Cheng Zhong <hust.zcheng@gmail.com>
#
1 change: 1 addition & 0 deletions libserial/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build
/.idea
*.iml
/.cxx
10 changes: 10 additions & 0 deletions libserial/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ android {
targetSdkVersion 30
versionCode 1
versionName "1.0"
externalNativeBuild {
ndkBuild {
cppFlags '-fexceptions'
}
}
}

buildTypes {
Expand All @@ -40,6 +45,11 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
externalNativeBuild {
ndkBuild {
path file('src/main/jni/Android.mk')
}
}
}

dependencies {
Expand Down
8 changes: 3 additions & 5 deletions libserial/src/main/java/serial/Serial.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,17 @@ public class Serial implements Closeable {
* @return an array of available ports.
*/
public static PortInfo[] listPorts() {
PortInfo[] ports;
String[] portDescs = native_listPorts();
if (portDescs != null && portDescs.length > 0) {
ports = new PortInfo[portDescs.length];
PortInfo[] ports = new PortInfo[portDescs.length];
int index = 0;
for (String portDesc : portDescs) {
String[] parts = FIELD_DELIM.split(portDesc);
ports[index++] = new PortInfo(parts[0], parts[1], parts[2]);
}
} else {
ports = null;
return ports;
}
return ports;
return new PortInfo[0];
}

/**
Expand Down
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
compileSdkVersion 28
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "serial.android.sample"
minSdkVersion 16
targetSdkVersion 23
minSdkVersion 28
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand Down