├── examplesync ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── layout │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── felhr │ │ └── serialportexamplesync │ │ └── MainActivity.java ├── proguard-rules.pro └── build.gradle ├── usbserial ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── felhr │ │ │ ├── usbserial │ │ │ ├── SerialPortCallback.java │ │ │ ├── AbstractWorkerThread.java │ │ │ ├── UsbSpiInterface.java │ │ │ ├── SerialOutputStream.java │ │ │ ├── UsbSerialDebugger.java │ │ │ ├── SerialInputStream.java │ │ │ ├── UsbSerialInterface.java │ │ │ ├── SerialBuffer.java │ │ │ └── UsbSpiDevice.java │ │ │ ├── deviceids │ │ │ ├── CP2130Ids.java │ │ │ ├── CH34xIds.java │ │ │ ├── XdcVcpIds.java │ │ │ ├── Helpers.java │ │ │ ├── PL2303Ids.java │ │ │ └── CP210xIds.java │ │ │ └── utils │ │ │ ├── Utils.java │ │ │ ├── SafeUsbRequest.java │ │ │ ├── HexData.java │ │ │ └── ProtocolBuffer.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── felhr │ │ │ ├── deviceids │ │ │ └── DeviceIdTest.java │ │ │ └── usbserial │ │ │ └── FTDISerialDeviceTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── felhr │ │ └── tests │ │ ├── usbserial │ │ └── SerialBufferTest.java │ │ └── utils │ │ └── ProtocolBufferTest.java ├── eclipse_lib │ └── usbserial.jar ├── proguard-rules.pro └── build.gradle ├── examplestreams ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── felhr │ │ │ └── examplestreams │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── felhr │ │ │ └── examplestreams │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── felhr │ │ └── examplestreams │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── integrationapp ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── felhr │ │ │ └── integrationapp │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── felhr │ │ │ └── integrationapp │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── felhr │ │ └── integrationapp │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── examplemultipleports ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── felhr │ │ │ └── examplemultipleports │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── felhr │ │ │ └── examplemultipleports │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── felhr │ │ └── examplemultipleports │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── example ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── felhr │ │ └── serialportexample │ │ └── MainActivity.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── integration ├── send_packet.py ├── validate_serial_tx.py ├── send_packet.sh ├── integration_sync.py ├── integration.py └── README.md ├── .gitignore ├── RELEASING.md ├── .travis.yml ├── LICENSE ├── release.sh ├── CHANGELOG.md ├── gradlew.bat ├── gradlew └── README.md /examplesync/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /usbserial/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /examplestreams/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /integrationapp/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /examplemultipleports/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.jks 3 | signing.properties -------------------------------------------------------------------------------- /usbserial/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':usbserial', ':example', ':examplesync', ':examplestreams', ':examplemultipleports', ':integrationapp' -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /usbserial/eclipse_lib/usbserial.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/usbserial/eclipse_lib/usbserial.jar -------------------------------------------------------------------------------- /integrationapp/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | IntegrationApp 3 | 4 | -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Example multiple ports 3 | 4 | -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplesync/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplesync/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplesync/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplesync/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplesync/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplesync/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplesync/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplesync/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplesync/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplesync/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_NAME=6.1.0 2 | VERSION_CODE=1 3 | ANDROID_BUILD_MIN_SDK_VERSION=12 4 | ANDROID_BUILD_TARGET_SDK_VERSION=27 5 | ANDROID_BUILD_SDK_VERSION=27 6 | -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplestreams/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/integrationapp/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/green-green-avk/UsbSerial/master/examplemultipleports/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/usbserial/SerialPortCallback.java: -------------------------------------------------------------------------------- 1 | package com.felhr.usbserial; 2 | 3 | import java.util.List; 4 | 5 | 6 | public interface SerialPortCallback { 7 | void onSerialPortsDetected(List serialPorts); 8 | } 9 | -------------------------------------------------------------------------------- /examplestreams/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /examplesync/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /integrationapp/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /example/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 14 15:18:57 PST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip 7 | -------------------------------------------------------------------------------- /examplesync/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ExampleSync 3 | Hello world! 4 | Settings 5 | Synchronous Serial Port 6 | 7 | -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examplestreams/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ExampleInputOutputStream 3 | Hello world! 4 | Settings 5 | InputStream and OutputStream Serial Port 6 | 7 | -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examplestreams/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /integrationapp/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SerialPortExample 5 | Hello world! 6 | Settings 7 | Serial Port 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /examplesync/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examplestreams/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /integration/send_packet.py: -------------------------------------------------------------------------------- 1 | # UsbSerial test: Sending single packet 2 | # args: 3 | # port (eg /dev/ttyUSB0) 4 | # size in bytes (eg 1024) 5 | # speed in bauds (eg 115200) 6 | 7 | import serial 8 | import sys 9 | import os 10 | 11 | port = sys.argv[1] 12 | size = sys.argv[2] 13 | speed = sys.argv[3] 14 | 15 | comm = serial.Serial(port, int(speed)) 16 | 17 | data_tx = os.urandom(int(size)) 18 | 19 | bytes_sent = comm.write(data_tx) 20 | 21 | print(str(bytes_sent)) -------------------------------------------------------------------------------- /integrationapp/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /integrationapp/src/test/java/com/felhr/integrationapp/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.felhr.integrationapp; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Key 16 | *.jks 17 | 18 | # Local configuration file (sdk path, etc) 19 | local.properties 20 | 21 | # Intellij project files 22 | *.iml 23 | *.ipr 24 | *.iws 25 | .idea/ 26 | *.prefs 27 | 28 | # Gradle 29 | build/ 30 | .gradle 31 | 32 | # Byte-compiled / optimized / DLL files 33 | __pycache__/ 34 | *.pyc 35 | *.py[cod] 36 | *$py.class 37 | -------------------------------------------------------------------------------- /examplemultipleports/src/test/java/com/felhr/examplemultipleports/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.felhr.examplemultipleports; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /examplestreams/src/test/java/com/felhr/examplestreams/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.felhr.examplestreams; 2 | 3 | import org.junit.Test; 4 | 5 | import static junit.framework.Assert.assertEquals; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/deviceids/CP2130Ids.java: -------------------------------------------------------------------------------- 1 | package com.felhr.deviceids; 2 | 3 | import static com.felhr.deviceids.Helpers.createTable; 4 | import static com.felhr.deviceids.Helpers.createDevice; 5 | 6 | public class CP2130Ids 7 | { 8 | private static final long[] cp2130Devices = createTable( 9 | createDevice(0x10C4, 0x87a0) 10 | ); 11 | 12 | public static boolean isDeviceSupported(int vendorId, int productId) 13 | { 14 | return Helpers.exists(cp2130Devices, vendorId, productId); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package com.felhr.utils; 2 | 3 | import com.annimon.stream.Collectors; 4 | import com.annimon.stream.Stream; 5 | import com.annimon.stream.function.Predicate; 6 | 7 | import java.util.Collection; 8 | import java.util.List; 9 | 10 | 11 | public class Utils { 12 | public static List removeIf(Collection c, Predicate predicate) { 13 | return Stream.of(c.iterator()) 14 | .filterNot(predicate) 15 | .collect(Collectors.toList()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /integration/validate_serial_tx.py: -------------------------------------------------------------------------------- 1 | # UsbSerial test: Validate single packet 2 | # args: 3 | # port (eg /dev/ttyUSB0) 4 | # size in bytes (eg 1024) 5 | # speed in bauds (eg 115200) 6 | 7 | import serial 8 | import sys 9 | import os 10 | 11 | port = sys.argv[1] 12 | size = sys.argv[2] 13 | speed = sys.argv[3] 14 | 15 | comm = serial.Serial(port, int(speed)) 16 | 17 | data_tx = os.urandom(int(size)) 18 | 19 | comm.write(data_tx) 20 | 21 | data_rx = comm.read(int(size)) 22 | 23 | if data_tx == data_rx: 24 | print("Success: Data was transmitted correctly") 25 | else: 26 | print("Error: Data was not transmitted") -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/deviceids/CH34xIds.java: -------------------------------------------------------------------------------- 1 | package com.felhr.deviceids; 2 | 3 | import static com.felhr.deviceids.Helpers.createTable; 4 | import static com.felhr.deviceids.Helpers.createDevice; 5 | 6 | public class CH34xIds 7 | { 8 | private CH34xIds() 9 | { 10 | 11 | } 12 | 13 | private static final long[] ch34xDevices = createTable( 14 | createDevice(0x4348, 0x5523), 15 | createDevice(0x1a86, 0x7523), 16 | createDevice(0x1a86, 0x5523), 17 | createDevice(0x1a86, 0x0445) 18 | ); 19 | 20 | public static boolean isDeviceSupported(int vendorId, int productId) 21 | { 22 | return Helpers.exists(ch34xDevices, vendorId, productId); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Program Files (x86)\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /examplesync/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/AndroidSDK/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /example/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/usbserial/AbstractWorkerThread.java: -------------------------------------------------------------------------------- 1 | package com.felhr.usbserial; 2 | 3 | abstract class AbstractWorkerThread extends Thread { 4 | boolean firstTime = true; 5 | private volatile boolean keep = true; 6 | private volatile Thread workingThread; 7 | 8 | void stopThread() { 9 | keep = false; 10 | if (this.workingThread != null) { 11 | this.workingThread.interrupt(); 12 | } 13 | } 14 | 15 | public final void run() { 16 | if (!this.keep) { 17 | return; 18 | } 19 | this.workingThread = Thread.currentThread(); 20 | while (this.keep && (!this.workingThread.isInterrupted())) { 21 | doRun(); 22 | } 23 | } 24 | 25 | abstract void doRun(); 26 | } 27 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | Releasing 2 | ======== 3 | 4 | 1. Change the `VERSION_NAME` value in `gradle.properties` to the version number to be released. 5 | 2. Update the `README.md` with the new version and update `CHANGELOG.md` 6 | 3. `./gradlew clean build` 7 | 4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version) 8 | 5. `git tag -a X.Y.Z -m "Version X.Y.Z"` `-m "Changelog message 1"` `-m "Changelog message 2"` `-m "Changelog message 3"` 9 | 6. `git push && git push --tags` 10 | 11 | *Note:* To get the changelog messages from the commit history, issue 12 | 13 | ```shell 14 | git log "$(git tag | tail -n2 | head -n1)..$(git tag | tail -n1)" --oneline --invert-grep --grep="Merge pull request" --grep="Prepare for release" | cut -d' ' -f2- | sed -E -e 's/^/-m "/' | sed -E -e 's/$/"/' 15 | ``` 16 | 17 | -------------------------------------------------------------------------------- /examplestreams/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /integrationapp/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /examplemultipleports/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/deviceids/XdcVcpIds.java: -------------------------------------------------------------------------------- 1 | package com.felhr.deviceids; 2 | 3 | import static com.felhr.deviceids.Helpers.createTable; 4 | import static com.felhr.deviceids.Helpers.createDevice; 5 | 6 | public class XdcVcpIds 7 | { 8 | /* 9 | * Werner Wolfrum (w.wolfrum@wolfrum-elektronik.de) 10 | */ 11 | 12 | /* Different products and vendors of XdcVcp family 13 | */ 14 | private static final long[] xdcvcpDevices = createTable( 15 | createDevice(0x264D, 0x0232), // VCP (Virtual Com Port) 16 | createDevice(0x264D, 0x0120), // USI (Universal Sensor Interface) 17 | createDevice(0x0483, 0x5740) //CC3D (STM) 18 | ); 19 | 20 | public static boolean isDeviceSupported(int vendorId, int productId) 21 | { 22 | return Helpers.exists(xdcvcpDevices, vendorId, productId); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/deviceids/Helpers.java: -------------------------------------------------------------------------------- 1 | package com.felhr.deviceids; 2 | 3 | import java.util.Arrays; 4 | 5 | class Helpers { 6 | 7 | /** 8 | * Create a device id, since they are 4 bytes each, we can pack the pair in an long. 9 | */ 10 | static long createDevice(int vendorId, int productId) { 11 | return ((long) vendorId) << 32 | (productId & 0xFFFF_FFFFL); 12 | } 13 | 14 | /** 15 | * Creates a sorted table. 16 | * This way, we can use binarySearch to find whether the entry exists. 17 | */ 18 | static long[] createTable(long ... entries) { 19 | Arrays.sort(entries); 20 | return entries; 21 | } 22 | 23 | static boolean exists(long[] devices, int vendorId, int productId) { 24 | return Arrays.binarySearch(devices, createDevice(vendorId, productId)) >= 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /integration/send_packet.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | 3 | # UsbSerial 4 | # 5 | # This test generates a number of files specified by the user and send them through the serial port. 6 | # 7 | # args: 8 | # -p: serial port (ttyUSB0, ttyUSB1..) 9 | # -b: baud rate 10 | # -t: number of times this test will be repeated 11 | # -s: size of the random files generated for testing purposes 12 | 13 | while getopts p:t:s:b: OPTION; 14 | do 15 | case $OPTION 16 | in 17 | p) PORT=$OPTARG;; 18 | t) TIMES=$OPTARG;; 19 | s) SIZE=$OPTARG;; 20 | b) BAUD=$OPTARG;; 21 | esac 22 | done 23 | 24 | stty -F $PORT $BAUD 25 | 26 | for i in $(seq 1 $TIMES); 27 | do 28 | dd if=/dev/urandom of=$i bs=$SIZE count=1 status=none 29 | echo "Packet $i of $SIZE was created" 30 | cat $i > $PORT 31 | echo "Packet $i of $SIZE was sent" 32 | 33 | done 34 | 35 | rm [0-9]* 36 | -------------------------------------------------------------------------------- /usbserial/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Program Files (x86)\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. 20 | -dontwarn org.codehaus.mojo.animal_sniffer.* -------------------------------------------------------------------------------- /integrationapp/src/androidTest/java/com/felhr/integrationapp/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.felhr.integrationapp; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.felhr.integrationapp", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examplemultipleports/src/androidTest/java/com/felhr/examplemultipleports/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.felhr.examplemultipleports; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.felhr.examplemultipleports", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/usbserial/UsbSpiInterface.java: -------------------------------------------------------------------------------- 1 | package com.felhr.usbserial; 2 | 3 | 4 | public interface UsbSpiInterface 5 | { 6 | // Clock dividers; 7 | int DIVIDER_2 = 2; 8 | int DIVIDER_4 = 4; 9 | int DIVIDER_8 = 8; 10 | int DIVIDER_16 = 16; 11 | int DIVIDER_32 = 32; 12 | int DIVIDER_64 = 64; 13 | int DIVIDER_128 = 128; 14 | 15 | // Common SPI operations 16 | boolean connectSPI(); 17 | void writeMOSI(byte[] buffer); 18 | void readMISO(int lengthBuffer); 19 | void writeRead(byte[] buffer, int lenghtRead); 20 | void setClock(int clockDivider); 21 | void selectSlave(int nSlave); 22 | void setMISOCallback(UsbMISOCallback misoCallback); 23 | void closeSPI(); 24 | 25 | // Status information 26 | int getClockDivider(); 27 | int getSelectedSlave(); 28 | 29 | interface UsbMISOCallback 30 | { 31 | int onReceivedData(byte[] data); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examplestreams/src/androidTest/java/com/felhr/examplestreams/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.felhr.examplestreams; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static junit.framework.Assert.assertEquals; 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getTargetContext(); 24 | 25 | assertEquals("com.felhr.examplestreams", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | android: 3 | components: 4 | - tools 5 | - platform-tools 6 | # Note that the tools section appears twice on purpose as it’s required to get the newest Android SDK tools. 7 | # See: https://docs.travis-ci.com/user/languages/android/#Overview 8 | - tools 9 | - build-tools-27.0.3 10 | - build-tools-27.0.2 11 | - build-tools-26.0.2 12 | - android-27 13 | - android-26 14 | before_cache: 15 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 16 | before_install: 17 | - yes | sdkmanager "platforms;android-27" 18 | cache: 19 | directories: 20 | - $HOME/.gradle/caches/ 21 | - $HOME/.gradle/wrapper/ 22 | before_script: 23 | - export VERSION_TO_BUILD="$TRAVIS_TAG" 24 | script: ./gradlew clean build 25 | deploy: 26 | provider: releases 27 | api_key: $GITHUB_OAUTH_TOKEN 28 | file: usbserial/build/outputs/aar/usbserial-${VERSION_TO_BUILD}-release.aar 29 | skip_cleanup: true 30 | on: 31 | tags: true -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /examplesync/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /examplestreams/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /examplemultipleports/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Felipe Herranz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/utils/SafeUsbRequest.java: -------------------------------------------------------------------------------- 1 | package com.felhr.utils; 2 | 3 | import android.hardware.usb.UsbRequest; 4 | 5 | import java.lang.reflect.Field; 6 | import java.nio.ByteBuffer; 7 | 8 | 9 | public class SafeUsbRequest extends UsbRequest 10 | { 11 | static final String usbRqBufferField = "mBuffer"; 12 | static final String usbRqLengthField = "mLength"; 13 | 14 | @Override 15 | public boolean queue(ByteBuffer buffer, int length) 16 | { 17 | Field usbRequestBuffer; 18 | Field usbRequestLength; 19 | try 20 | { 21 | usbRequestBuffer = UsbRequest.class.getDeclaredField(usbRqBufferField); 22 | usbRequestLength = UsbRequest.class.getDeclaredField(usbRqLengthField); 23 | usbRequestBuffer.setAccessible(true); 24 | usbRequestLength.setAccessible(true); 25 | usbRequestBuffer.set(this, buffer); 26 | usbRequestLength.set(this, length); 27 | } catch (Exception e) 28 | { 29 | throw new RuntimeException(e); 30 | } 31 | 32 | return super.queue(buffer, length); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /integration/integration_sync.py: -------------------------------------------------------------------------------- 1 | # UsbSerial test: Integration test 2 | # args: 3 | # port (eg /dev/ttyUSB0) 4 | # speed in bauds (eg 115200) 5 | 6 | import serial 7 | import sys 8 | import os 9 | 10 | class style(): 11 | RED = lambda x: '\033[31m' + str(x) 12 | GREEN = lambda x: '\033[32m' + str(x) 13 | BLUE = lambda x: '\033[34m' + str(x) 14 | RESET = lambda x: '\033[0m' + str(x) 15 | 16 | port = sys.argv[1] 17 | speed = sys.argv[2] 18 | 19 | test_sizes = [1024, 2048, 16384] 20 | 21 | for i in range(0,3): 22 | comm = serial.Serial(port, int(speed)) 23 | print("Creating " + str(test_sizes[i]) + " bytes buffer") 24 | data_tx = os.urandom(test_sizes[i]) 25 | print("Sending buffer of " + str(test_sizes[i]) + " bytes") 26 | comm.write(data_tx) 27 | print("Receiving " + str(test_sizes[i]) + " bytes buffer") 28 | data_rx = comm.read(test_sizes[i]) 29 | 30 | if data_tx == data_rx: 31 | print(style.GREEN("Success: " + str(test_sizes[i]) + " bytes buffer was transmitted correctly")) 32 | else: 33 | print(style.RED("Error: " + str(test_sizes[i]) + " bytes buffer was not transmitted correctly")) 34 | print(style.RESET("")) 35 | -------------------------------------------------------------------------------- /integration/integration.py: -------------------------------------------------------------------------------- 1 | # UsbSerial test: Integration test 2 | # args: 3 | # port (eg /dev/ttyUSB0) 4 | # speed in bauds (eg 115200) 5 | 6 | import serial 7 | import sys 8 | import os 9 | 10 | class style(): 11 | RED = lambda x: '\033[31m' + str(x) 12 | GREEN = lambda x: '\033[32m' + str(x) 13 | BLUE = lambda x: '\033[34m' + str(x) 14 | RESET = lambda x: '\033[0m' + str(x) 15 | 16 | port = sys.argv[1] 17 | speed = sys.argv[2] 18 | 19 | test_sizes = [1024, 2048, 16384, 65535, 131072] 20 | 21 | for i in range(0,5): 22 | comm = serial.Serial(port, int(speed)) 23 | print("Creating " + str(test_sizes[i]) + " bytes buffer") 24 | data_tx = os.urandom(test_sizes[i]) 25 | print("Sending buffer of " + str(test_sizes[i]) + " bytes") 26 | comm.write(data_tx) 27 | print("Receiving " + str(test_sizes[i]) + " bytes buffer") 28 | data_rx = comm.read(test_sizes[i]) 29 | 30 | if data_tx == data_rx: 31 | print(style.GREEN("Success: " + str(test_sizes[i]) + " bytes buffer was transmitted correctly")) 32 | else: 33 | print(style.RED("Error: " + str(test_sizes[i]) + " bytes buffer was not transmitted correctly")) 34 | print(style.RESET("")) 35 | -------------------------------------------------------------------------------- /integrationapp/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /examplestreams/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | 5 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 6 | 7 | defaultConfig { 8 | applicationId "com.felhr.examplestreams" 9 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 10 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 11 | versionName project.VERSION_NAME 12 | versionCode Integer.parseInt(project.VERSION_CODE) 13 | } 14 | 15 | compileOptions { 16 | encoding "UTF-8" 17 | sourceCompatibility JavaVersion.VERSION_1_8 18 | targetCompatibility JavaVersion.VERSION_1_8 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation 'com.android.support:support-v4:23.1.1' 24 | implementation 'com.android.support:appcompat-v7:23.1.1' 25 | implementation 'com.android.support:design:23.1.1' 26 | 27 | implementation 'com.android.support:support-annotations:28.0.0' 28 | 29 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 30 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 31 | androidTestImplementation 'junit:junit:4.12' 32 | 33 | testImplementation 'junit:junit:4.12' 34 | 35 | implementation project(':usbserial') 36 | } 37 | -------------------------------------------------------------------------------- /examplesync/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | 5 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 6 | 7 | defaultConfig { 8 | applicationId "com.felhr.serialportexamplesync" 9 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 10 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 11 | versionName project.VERSION_NAME 12 | versionCode Integer.parseInt(project.VERSION_CODE) 13 | } 14 | 15 | compileOptions { 16 | encoding "UTF-8" 17 | sourceCompatibility JavaVersion.VERSION_1_8 18 | targetCompatibility JavaVersion.VERSION_1_8 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation 'com.android.support:support-v4:23.1.1' 24 | implementation 'com.android.support:appcompat-v7:23.1.1' 25 | implementation 'com.android.support:design:23.1.1' 26 | 27 | implementation 'com.android.support:support-annotations:28.0.0' 28 | 29 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 30 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 31 | androidTestImplementation 'junit:junit:4.12' 32 | 33 | testImplementation 'junit:junit:4.12' 34 | 35 | implementation project(':usbserial') 36 | } 37 | -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | 5 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 6 | 7 | defaultConfig { 8 | applicationId "com.felhr.serialportexample" 9 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 10 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 11 | versionName project.VERSION_NAME 12 | versionCode Integer.parseInt(project.VERSION_CODE) 13 | } 14 | 15 | compileOptions { 16 | encoding "UTF-8" 17 | sourceCompatibility JavaVersion.VERSION_1_8 18 | targetCompatibility JavaVersion.VERSION_1_8 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation 'com.android.support:support-v4:23.1.1' 24 | implementation 'com.android.support:appcompat-v7:23.1.1' 25 | implementation 'com.android.support:design:23.1.1' 26 | 27 | implementation 'com.android.support:support-annotations:28.0.0' 28 | 29 | implementation 'com.android.support:support-annotations:28.0.0' 30 | 31 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 33 | androidTestImplementation 'junit:junit:4.12' 34 | 35 | testImplementation 'junit:junit:4.12' 36 | 37 | implementation project(':usbserial') 38 | } 39 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #Arguments: 3 | # -v version eg 6.0.3 4 | # -m 6.0.3 5 | set -e 6 | 7 | while getopts v:m: OPTION; 8 | do 9 | case $OPTION 10 | in 11 | v) VERSION=$OPTARG;; 12 | m) MESSAGE=$OPTARG;; 13 | esac 14 | done 15 | 16 | # Show error message if no version was provided 17 | if [[ -z ${VERSION} ]]; 18 | then 19 | echo "UsbSerial: Error!! No version was provided" 20 | exit 0 21 | fi 22 | 23 | # Show error message if no message was provided 24 | if [[ -z ${MESSAGE} ]]; 25 | then 26 | echo "UsbSerial: Error!! No message was provided" 27 | exit 0 28 | fi 29 | 30 | echo "UsbSerial: Starting Release $VERSION with commit message $MESSAGE" 31 | 32 | VERSION_NAME="VERSION_NAME=$VERSION" 33 | 34 | # Updating gradle.properties with version 35 | ex -sc '1d|x' gradle.properties 36 | ex -sc "1i|$VERSION_NAME" -cx gradle.properties 37 | 38 | # Updating README file 39 | GRADLE_LINE="implementation 'com.github.felHR85:UsbSerial:${VERSION}'" 40 | LINE=$(cat README.md | grep -nr implementation\ \'com.github.felHR85:UsbSerial: | awk -F ":" '{print $2}') 41 | ex -sc "${LINE}d|x" README.md 42 | ex -sc "${LINE}i|$GRADLE_LINE" -cx README.md 43 | 44 | # Gradle clean and build 45 | ./gradlew clean build 46 | 47 | # Git stuff 48 | git add . 49 | git commit -m "${MESSAGE}" 50 | git tag ${VERSION} 51 | git push origin master 52 | git push --tags 53 | 54 | echo "UsbSerial: Release Finished!!!" 55 | -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/usbserial/SerialOutputStream.java: -------------------------------------------------------------------------------- 1 | package com.felhr.usbserial; 2 | 3 | import java.io.OutputStream; 4 | 5 | public class SerialOutputStream extends OutputStream 6 | { 7 | private int timeout = 0; 8 | 9 | protected final UsbSerialInterface device; 10 | 11 | public SerialOutputStream(UsbSerialInterface device) 12 | { 13 | this.device = device; 14 | } 15 | 16 | @Override 17 | public void write(int b) 18 | { 19 | device.syncWrite(new byte[] { (byte)b }, timeout); 20 | } 21 | 22 | @Override 23 | public void write(byte[] b) 24 | { 25 | device.syncWrite(b, timeout); 26 | } 27 | 28 | @Override 29 | public void write(byte b[], int off, int len) 30 | { 31 | if(off < 0 ){ 32 | throw new IndexOutOfBoundsException("Offset must be >= 0"); 33 | } 34 | 35 | if(len < 0){ 36 | throw new IndexOutOfBoundsException("Length must positive"); 37 | } 38 | 39 | if(off + len > b.length) { 40 | throw new IndexOutOfBoundsException("off + length greater than buffer length"); 41 | } 42 | 43 | if (off == 0 && len == b.length) { 44 | write(b); 45 | return; 46 | } 47 | 48 | device.syncWrite(b, off, len, timeout); 49 | } 50 | 51 | public void setTimeout(int timeout) { 52 | this.timeout = timeout; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /integrationapp/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 5 | 6 | defaultConfig { 7 | applicationId "com.felhr.integrationapp" 8 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 9 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 10 | versionName project.VERSION_NAME 11 | versionCode Integer.parseInt(project.VERSION_CODE) 12 | } 13 | 14 | compileOptions { 15 | encoding "UTF-8" 16 | sourceCompatibility JavaVersion.VERSION_1_8 17 | targetCompatibility JavaVersion.VERSION_1_8 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation 'com.android.support:support-v4:23.1.1' 23 | implementation 'com.android.support:appcompat-v7:23.1.1' 24 | implementation 'com.android.support:design:23.1.1' 25 | 26 | implementation 'com.android.support:support-annotations:28.0.0' 27 | 28 | implementation 'com.android.support:support-annotations:28.0.0' 29 | 30 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 31 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 32 | androidTestImplementation 'junit:junit:4.12' 33 | 34 | testImplementation 'junit:junit:4.12' 35 | 36 | implementation 'com.squareup.okio:okio:2.1.0' 37 | 38 | implementation project(':usbserial') 39 | } 40 | -------------------------------------------------------------------------------- /integration/README.md: -------------------------------------------------------------------------------- 1 | UsbSerial Integration Tests 2 | =========================== 3 | For the purpose of helping people contributing to UsbSerial a little set of integration tests have been added. It consists in two parts. 4 | - Python script integration.py that sends a series packets (1kb, 2kb, 8kb, 64kb and 128kb) and validates that those packets are received back correctly. 5 | - Integration Android app that implements UsbSerial and just receives and sends back the packets sent by the python script. 6 | 7 | Requirements 8 | -------------------------------------- 9 | - Windows/OSX/Linux with Python 3 installed 10 | - [PySerial](https://pypi.org/project/pyserial/) 11 | - Android phone with Android 3.1 and with USB OTG capabilities 12 | 13 | Steps 14 | -------------------------------------- 15 | Let's say we want to test UsbSerial transmitting at 115200 bauds and our PC port is /dev/ttyUSB0 16 | - [Modify UsbService in Integration app to 115200 bauds](https://github.com/felHR85/UsbSerial/blob/integration_tests/integrationapp/src/main/java/com/felhr/integrationapp/UsbService.java#L61). 17 | - Compile and install Integration app on your device. 18 | - Connect your phone to a serial device at one end and your PC at the other end. 19 | - Run python integration.py /dev/ttyUSB0 115200 20 | 21 | Other Scripts 22 | -------------------------------------- 23 | - send_packet.py (python send_packet.py /dev/ttyUSB0 1024 115200) 24 | - validate_serial_tx.py (python validate_serial_tx.py /dev/ttyUSB0 1024 115200) -------------------------------------------------------------------------------- /examplemultipleports/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | 5 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 6 | 7 | defaultConfig { 8 | applicationId "com.felhr.examplemultipleports" 9 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 10 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 11 | versionName project.VERSION_NAME 12 | versionCode Integer.parseInt(project.VERSION_CODE) 13 | } 14 | 15 | compileOptions { 16 | encoding "UTF-8" 17 | sourceCompatibility JavaVersion.VERSION_1_8 18 | targetCompatibility JavaVersion.VERSION_1_8 19 | } 20 | 21 | buildTypes { 22 | release { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | 28 | } 29 | 30 | dependencies { 31 | implementation 'com.android.support:support-v4:23.1.1' 32 | implementation 'com.android.support:appcompat-v7:23.1.1' 33 | implementation 'com.android.support:design:23.1.1' 34 | 35 | implementation 'com.android.support:support-annotations:28.0.0' 36 | 37 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 38 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 39 | androidTestImplementation 'junit:junit:4.12' 40 | 41 | testImplementation 'junit:junit:4.12' 42 | 43 | implementation project(':usbserial') 44 | implementation 'com.annimon:stream:1.2.1' 45 | } 46 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | 4 | Release 6.1.0 5 | -------------------------------------- 6 | - Added 1228800 and 2000000 baud rates to CH34xx driver. 7 | - Microchip pid/vid correclty determined. 8 | - FTDI sync method back to previous implementation. 9 | - setBreak method implemented in CP210x devices. 10 | - Added chunked stream methods. 11 | 12 | Release 6.0.6 13 | -------------------------------------- 14 | - Added custom baud rates in FTDI devices. 15 | - Added setBreak method. Currently only working in FTDI devices. 16 | 17 | Release 6.0.5 18 | -------------------------------------- 19 | - Solved issue with CDC. 20 | - Added new pair of VID/PID pairs for CP2102. 21 | - Threads closing in a safer way. 22 | 23 | Release 6.0.4 24 | -------------------------------------- 25 | - Proguard rules. 26 | - FTDI driver improved again. 27 | 28 | Release 6.0.3 29 | -------------------------------------- 30 | - VID/PID pairs are sorted and searched in a faster way. 31 | - FTDI driver improved. 32 | 33 | Release 6.0.2 34 | -------------------------------------- 35 | - Solved issue when disconnecting multiple serial ports. 36 | 37 | Release 6.0.1 38 | -------------------------------------- 39 | - Internal serial buffer now uses [Okio](https://github.com/square/okio). This erases the 16kb write 40 | limitation from previous versions and reduces memory footprint. 41 | - Improved CP2102 driver and added more VID/PID pairs. 42 | - Added a [utility class for handling the common problem of split received information in some chipsets](https://github.com/felHR85/UsbSerial/blob/master/usbserial/src/main/java/com/felhr/utils/ProtocolBuffer.java). 43 | 44 | -------------------------------------------------------------------------------- /usbserial/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | def artifact = "usbserial.jar" 4 | 5 | android { 6 | 7 | group = 'com.felhr.usbserial' 8 | version = project.VERSION_NAME 9 | 10 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 11 | 12 | compileOptions { 13 | encoding "UTF-8" 14 | sourceCompatibility JavaVersion.VERSION_1_8 15 | targetCompatibility JavaVersion.VERSION_1_8 16 | } 17 | 18 | defaultConfig { 19 | minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 20 | targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 21 | archivesBaseName = "${project.name}-${project.VERSION_NAME}" 22 | consumerProguardFiles 'proguard-rules.pro' 23 | } 24 | 25 | //noinspection GroovyAssignabilityCheck 26 | task deleteJar(type: Delete) { 27 | delete "eclipse_lib/${artifact}" 28 | } 29 | 30 | //noinspection GroovyAssignabilityCheck 31 | task createJar(type: org.gradle.api.tasks.Copy) { 32 | from('build/intermediates/bundles/release/') 33 | into('eclipse_lib/') 34 | include('classes.jar') 35 | rename('classes.jar', artifact) 36 | } 37 | 38 | dependencies { 39 | implementation 'com.annimon:stream:1.2.1' 40 | implementation 'com.squareup.okio:okio:2.1.0' 41 | 42 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 43 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 44 | androidTestImplementation 'junit:junit:4.12' 45 | 46 | testImplementation 'junit:junit:4.12' 47 | 48 | } 49 | 50 | createJar.dependsOn(deleteJar, build) 51 | } 52 | -------------------------------------------------------------------------------- /usbserial/src/main/java/com/felhr/utils/HexData.java: -------------------------------------------------------------------------------- 1 | package com.felhr.utils; 2 | 3 | public class HexData 4 | { 5 | private static final String HEXES = "0123456789ABCDEF"; 6 | private static final String HEX_INDICATOR = "0x"; 7 | private static final String SPACE = " "; 8 | 9 | private HexData() 10 | { 11 | 12 | } 13 | 14 | public static String hexToString(byte[] data) 15 | { 16 | if(data != null) 17 | { 18 | StringBuilder hex = new StringBuilder(2*data.length); 19 | for(int i=0;i<=data.length-1;i++) 20 | { 21 | byte dataAtIndex = data[i]; 22 | hex.append(HEX_INDICATOR); 23 | hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4)) 24 | .append(HEXES.charAt((dataAtIndex & 0x0F))); 25 | hex.append(SPACE); 26 | } 27 | return hex.toString(); 28 | }else 29 | { 30 | return null; 31 | } 32 | } 33 | 34 | public static byte[] stringTobytes(String hexString) 35 | { 36 | String stringProcessed = hexString.trim().replaceAll("0x", ""); 37 | stringProcessed = stringProcessed.replaceAll("\\s+",""); 38 | byte[] data = new byte[stringProcessed.length()/2]; 39 | int i = 0; 40 | int j = 0; 41 | while(i <= stringProcessed.length()-1) 42 | { 43 | byte character = (byte) Integer.parseInt(stringProcessed.substring(i, i+2), 16); 44 | data[j] = character; 45 | j++; 46 | i += 2; 47 | } 48 | return data; 49 | } 50 | 51 | public static String hex4digits(String id) 52 | { 53 | if(id.length() == 1) return "000" + id; 54 | if(id.length() == 2) return "00" + id; 55 | if(id.length() == 3) return "0" + id; 56 | else return id; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /examplestreams/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /integrationapp/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /examplemultipleports/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 19 | 20 | 29 | 30 | 39 | 40 | 41 | 42 | 43 |