├── AndroidStuido_3.0_COMTEST
├── ComTest_AndroidStudio3.0
│ ├── ComTest.iml
│ ├── app
│ │ ├── CMakeLists.txt
│ │ ├── app.iml
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── androidTest
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── silencefun
│ │ │ │ └── comtest
│ │ │ │ └── ExampleInstrumentedTest.java
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── cpp
│ │ │ │ └── native-lib.c
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── silencefun
│ │ │ │ │ └── comtest
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ ├── MyFunc.java
│ │ │ │ │ ├── SerialHelper.java
│ │ │ │ │ ├── been
│ │ │ │ │ ├── AssistBean.java
│ │ │ │ │ └── ComBean.java
│ │ │ │ │ └── serialport
│ │ │ │ │ ├── SerialPort.java
│ │ │ │ │ └── SerialPortFinder.java
│ │ │ └── res
│ │ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ │ ├── drawable
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_background.xml
│ │ │ │ ├── layout-land
│ │ │ │ └── main.xml
│ │ │ │ ├── layout-port
│ │ │ │ └── main.xml
│ │ │ │ ├── layout
│ │ │ │ └── activity_main.xml
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.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
│ │ │ │ └── values
│ │ │ │ ├── baudrates.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── silencefun
│ │ │ └── comtest
│ │ │ └── ExampleUnitTest.java
│ ├── build.gradle
│ ├── build
│ │ └── android-profile
│ │ │ ├── profile-2018-03-06-13-34-02-587.json
│ │ │ └── profile-2018-03-06-13-34-02-587.rawproto
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── local.properties
│ └── settings.gradle
└── readme.md
├── Android_SetN81
├── ComTest.iml
├── app
│ ├── CMakeLists.txt
│ ├── app.iml
│ ├── build.gradle
│ ├── proguard-rules.pro
│ ├── release
│ │ ├── app-release.apk
│ │ └── output.json
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── silencefun
│ │ │ └── comtest
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── cpp
│ │ │ └── native-lib.c
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── silencefun
│ │ │ │ └── comtest
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── MyFunc.java
│ │ │ │ ├── SerialHelper.java
│ │ │ │ ├── been
│ │ │ │ ├── AssistBean.java
│ │ │ │ └── ComBean.java
│ │ │ │ └── serialport
│ │ │ │ ├── SerialPort.java
│ │ │ │ └── SerialPortFinder.java
│ │ └── res
│ │ │ ├── drawable-v24
│ │ │ ├── corner_view.xml
│ │ │ ├── corner_view_gray.xml
│ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── drawable
│ │ │ ├── corner_view.xml
│ │ │ ├── corner_view_gray.xml
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ ├── include_common_head.xml
│ │ │ └── main.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ ├── ic_launcher_round.png
│ │ │ └── icon_return_black.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-v19
│ │ │ └── styles.xml
│ │ │ ├── values-v21
│ │ │ ├── dimens.xml
│ │ │ └── styles.xml
│ │ │ └── values
│ │ │ ├── baudrates.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── silencefun
│ │ └── comtest
│ │ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
├── readme.md
└── settings.gradle
├── ComAssistant
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
├── AndroidManifest.xml
├── bin
│ ├── AndroidManifest.xml
│ ├── classes.dex
│ ├── classes
│ │ ├── android_serialport_api
│ │ │ ├── SerialPort.class
│ │ │ ├── SerialPortFinder$Driver.class
│ │ │ └── SerialPortFinder.class
│ │ └── com
│ │ │ └── bjw
│ │ │ ├── ComAssistant
│ │ │ ├── BuildConfig.class
│ │ │ ├── ComAssistantActivity$ButtonClickEvent.class
│ │ │ ├── ComAssistantActivity$CheckBoxChangeEvent.class
│ │ │ ├── ComAssistantActivity$DispQueueThread$1.class
│ │ │ ├── ComAssistantActivity$DispQueueThread.class
│ │ │ ├── ComAssistantActivity$EditorActionEvent.class
│ │ │ ├── ComAssistantActivity$FocusChangeEvent.class
│ │ │ ├── ComAssistantActivity$ItemSelectedEvent.class
│ │ │ ├── ComAssistantActivity$SerialControl.class
│ │ │ ├── ComAssistantActivity$ToggleButtonCheckedChangeEvent.class
│ │ │ ├── ComAssistantActivity$radioButtonClickEvent$1.class
│ │ │ ├── ComAssistantActivity$radioButtonClickEvent.class
│ │ │ ├── ComAssistantActivity.class
│ │ │ ├── MyFunc.class
│ │ │ ├── R$array.class
│ │ │ ├── R$attr.class
│ │ │ ├── R$drawable.class
│ │ │ ├── R$id.class
│ │ │ ├── R$layout.class
│ │ │ ├── R$string.class
│ │ │ ├── R.class
│ │ │ ├── SerialHelper$ReadThread.class
│ │ │ ├── SerialHelper$SendThread.class
│ │ │ └── SerialHelper.class
│ │ │ └── bean
│ │ │ ├── AssistBean.class
│ │ │ └── ComBean.class
│ ├── jarlist.cache
│ ├── javaapk.com-ComAssistant.apk
│ ├── res
│ │ └── crunch
│ │ │ ├── drawable-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── drawable-ldpi
│ │ │ └── ic_launcher.png
│ │ │ └── drawable-mdpi
│ │ │ └── ic_launcher.png
│ └── resources.ap_
├── gen
│ └── com
│ │ └── bjw
│ │ └── ComAssistant
│ │ ├── BuildConfig.java
│ │ └── R.java
├── jni
│ ├── Android.mk
│ ├── Application.mk
│ ├── SerialPort.c
│ ├── SerialPort.h
│ └── gen_SerialPort_h.sh
├── libs
│ ├── armeabi-v7a
│ │ └── libserial_port.so
│ ├── armeabi
│ │ └── libserial_port.so
│ └── x86
│ │ └── libserial_port.so
├── lint.xml
├── obj
│ └── local
│ │ ├── armeabi-v7a
│ │ ├── libserial_port.so
│ │ └── objs
│ │ │ └── serial_port
│ │ │ ├── SerialPort.o
│ │ │ └── SerialPort.o.d
│ │ ├── armeabi
│ │ ├── libserial_port.so
│ │ └── objs
│ │ │ └── serial_port
│ │ │ ├── SerialPort.o
│ │ │ └── SerialPort.o.d
│ │ └── x86
│ │ ├── libserial_port.so
│ │ └── objs
│ │ └── serial_port
│ │ ├── SerialPort.o
│ │ └── SerialPort.o.d
├── proguard.cfg
├── project.properties
├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-ldpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── layout-land
│ │ └── main.xml
│ ├── layout-port
│ │ └── main.xml
│ └── values
│ │ ├── baudrates.xml
│ │ └── strings.xml
└── src
│ ├── android_serialport_api
│ ├── SerialPort.java
│ └── SerialPortFinder.java
│ └── com
│ └── bjw
│ ├── ComAssistant
│ ├── ComAssistantActivity.java
│ ├── MyFunc.java
│ └── SerialHelper.java
│ └── bean
│ ├── AssistBean.java
│ └── ComBean.java
├── ComTest2
├── .gitignore
├── .idea
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── runConfigurations.xml
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── net
│ │ │ └── test
│ │ │ └── comtest2
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ ├── android_serialport_api
│ │ │ │ ├── SerialPort.java
│ │ │ │ └── SerialPortFinder.java
│ │ │ └── net
│ │ │ │ └── test
│ │ │ │ └── comtest2
│ │ │ │ ├── ComAssistantActivity.java
│ │ │ │ ├── MyFunc.java
│ │ │ │ ├── SerialHelper.java
│ │ │ │ └── been
│ │ │ │ ├── AssistBean.java
│ │ │ │ └── ComBean.java
│ │ ├── jni
│ │ │ ├── android_serialport_api_SerialPort.c
│ │ │ └── android_serialport_api_SerialPort.h
│ │ ├── jniLibs
│ │ │ ├── armeabi-v7a
│ │ │ │ └── libserial_port.so
│ │ │ ├── armeabi
│ │ │ │ └── libserial_port.so
│ │ │ └── x86
│ │ │ │ └── libserial_port.so
│ │ └── res
│ │ │ ├── drawable
│ │ │ └── ic_launcher.png
│ │ │ ├── layout-land
│ │ │ └── main.xml
│ │ │ ├── layout-port
│ │ │ └── main.xml
│ │ │ ├── layout
│ │ │ └── activity_main.xml
│ │ │ └── values
│ │ │ ├── baudrates.xml
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── net
│ │ └── test
│ │ └── comtest2
│ │ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── ComTest_SetN81
├── ComTest.iml
├── app
│ ├── CMakeLists.txt
│ ├── app.iml
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── silencefun
│ │ │ └── comtest
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── cpp
│ │ │ └── native-lib.c
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── silencefun
│ │ │ │ └── comtest
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── MyFunc.java
│ │ │ │ ├── SerialHelper.java
│ │ │ │ ├── been
│ │ │ │ ├── AssistBean.java
│ │ │ │ └── ComBean.java
│ │ │ │ └── serialport
│ │ │ │ ├── SerialPort.java
│ │ │ │ └── SerialPortFinder.java
│ │ └── res
│ │ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── drawable
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout-land
│ │ │ └── main.xml
│ │ │ ├── layout-port
│ │ │ └── main.xml
│ │ │ ├── layout
│ │ │ └── activity_main.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.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
│ │ │ └── values
│ │ │ ├── baudrates.xml
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── silencefun
│ │ └── comtest
│ │ └── ExampleUnitTest.java
├── build.gradle
├── build
│ └── android-profile
│ │ ├── profile-2018-03-13-16-54-24-831.json
│ │ └── profile-2018-03-13-16-54-24-831.rawproto
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
├── readme.md
└── settings.gradle
└── README.md
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/ComTest.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | add_library( # Sets the name of the library.
14 | native-lib
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).
20 | src/main/cpp/native-lib.c)
21 |
22 | # Searches for a specified prebuilt library and stores the path as a
23 | # variable. Because CMake includes system libraries in the search path by
24 | # default, you only need to specify the name of the public NDK library
25 | # you want to add. CMake verifies that the library exists before
26 | # completing its build.
27 |
28 | find_library( # Sets the name of the path variable.
29 | log-lib
30 |
31 | # Specifies the name of the NDK library that
32 | # you want CMake to locate.
33 | log )
34 |
35 | # Specifies libraries CMake should link to your target library. You
36 | # can link multiple libraries, such as libraries you define in this
37 | # build script, prebuilt third-party libraries, or system libraries.
38 |
39 | target_link_libraries( # Specifies the target library.
40 | native-lib
41 |
42 | # Links the target library to the log library
43 | # included in the NDK.
44 | ${log-lib} )
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | defaultConfig {
6 | applicationId "com.silencefun.comtest"
7 | minSdkVersion 19
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | externalNativeBuild {
13 | cmake {
14 | cppFlags ""
15 | }
16 | }
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | externalNativeBuild {
25 | cmake {
26 | path "CMakeLists.txt"
27 | }
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
34 | testImplementation 'junit:junit:4.12'
35 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
36 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
37 | }
38 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/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 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/androidTest/java/com/silencefun/comtest/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest;
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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.silencefun.comtest", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/cpp/native-lib.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "android/log.h"
10 | static const char *TAG="serial_port";
11 | #define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##args)
12 | #define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, TAG, fmt, ##args)
13 | #define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##args)
14 |
15 |
16 |
17 | static speed_t getBaudrate(jint baudrate)
18 | {
19 | switch(baudrate) {
20 | case 0: return B0;
21 | case 50: return B50;
22 | case 75: return B75;
23 | case 110: return B110;
24 | case 134: return B134;
25 | case 150: return B150;
26 | case 200: return B200;
27 | case 300: return B300;
28 | case 600: return B600;
29 | case 1200: return B1200;
30 | case 1800: return B1800;
31 | case 2400: return B2400;
32 | case 4800: return B4800;
33 | case 9600: return B9600;
34 | case 19200: return B19200;
35 | case 38400: return B38400;
36 | case 57600: return B57600;
37 | case 115200: return B115200;
38 | case 230400: return B230400;
39 | case 460800: return B460800;
40 | case 500000: return B500000;
41 | case 576000: return B576000;
42 | case 921600: return B921600;
43 | case 1000000: return B1000000;
44 | case 1152000: return B1152000;
45 | case 1500000: return B1500000;
46 | case 2000000: return B2000000;
47 | case 2500000: return B2500000;
48 | case 3000000: return B3000000;
49 | case 3500000: return B3500000;
50 | case 4000000: return B4000000;
51 | default: return -1;
52 | }
53 | }
54 |
55 |
56 | int outfd;
57 | JNIEXPORT jobject JNICALL
58 | Java_com_silencefun_comtest_serialport_SerialPort_open(JNIEnv *env, jobject instance, jstring path,
59 | jint baudrate, jint flags) {
60 | int fd;
61 | speed_t speed;
62 | jobject mFileDescriptor;
63 |
64 | /* Check arguments */
65 | {
66 | speed = getBaudrate(baudrate);
67 | if (speed == -1) {
68 | /* TODO: throw an exception */
69 | LOGE("Invalid baudrate");
70 | return NULL;
71 | }
72 | }
73 |
74 | /* Opening device */
75 | {
76 | jboolean iscopy;
77 | const char *path_utf = (*env)->GetStringUTFChars(env, path, &iscopy);
78 | LOGD("Opening serial port %s with flags 0x%x", path_utf, O_RDWR | flags);
79 | fd = open(path_utf, O_RDWR | flags);
80 | LOGD("open() fd = %d", fd);
81 | (*env)->ReleaseStringUTFChars(env, path, path_utf);
82 | if (fd == -1)
83 | {
84 | /* Throw an exception */
85 | LOGE("Cannot open port");
86 | /* TODO: throw an exception */
87 | return NULL;
88 | }
89 | }
90 |
91 | /* Configure device */
92 | {
93 | struct termios cfg;
94 | LOGD("Configuring serial port");
95 | if (tcgetattr(fd, &cfg))
96 | {
97 | LOGE("tcgetattr() failed");
98 | close(fd);
99 | /* TODO: throw an exception */
100 | return NULL;
101 | }
102 |
103 | cfmakeraw(&cfg);
104 | cfsetispeed(&cfg, speed);
105 | cfsetospeed(&cfg, speed);
106 |
107 | if (tcsetattr(fd, TCSANOW, &cfg))
108 | {
109 | LOGE("tcsetattr() failed");
110 | close(fd);
111 | /* TODO: throw an exception */
112 | return NULL;
113 | }
114 | }
115 |
116 | /* Create a corresponding file descriptor */
117 | {
118 | jclass cFileDescriptor = (*env)->FindClass(env, "java/io/FileDescriptor");
119 | jmethodID iFileDescriptor = (*env)->GetMethodID(env, cFileDescriptor, "", "()V");
120 | jfieldID descriptorID = (*env)->GetFieldID(env, cFileDescriptor, "descriptor", "I");
121 | mFileDescriptor = (*env)->NewObject(env, cFileDescriptor, iFileDescriptor);
122 | (*env)->SetIntField(env, mFileDescriptor, descriptorID, (jint)fd);
123 | }
124 |
125 | outfd = fd;
126 | return mFileDescriptor;
127 | }
128 |
129 | JNIEXPORT void JNICALL
130 | Java_com_silencefun_comtest_serialport_SerialPort_close(JNIEnv *env, jobject instance) {
131 |
132 | /*jclass SerialPortClass = (*env)->GetObjectClass(env, instance);
133 | jclass FileDescriptorClass = (*env)->FindClass(env, "java/io/FileDescriptor");
134 |
135 | jfieldID mFdID = (*env)->GetFieldID(env, SerialPortClass, "mFd", "Ljava/io/FileDescriptor;");
136 | jfieldID descriptorID = (*env)->GetFieldID(env, FileDescriptorClass, "descriptor", "I");
137 |
138 | jobject mFd = (*env)->GetObjectField(env, instance, mFdID);
139 | jint descriptor = (*env)->GetIntField(env, mFd, descriptorID);*/
140 |
141 | LOGD("close(fd = %d)", outfd);
142 | tcflush(outfd, TCIOFLUSH);
143 | close(outfd);}
144 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/java/com/silencefun/comtest/MyFunc.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest;
2 |
3 | /**
4 | * @author benjaminwan
5 | *����ת������
6 | */
7 | public class MyFunc {
8 | //-------------------------------------------------------
9 | // �ж�������ż����λ���㣬���һλ��1��Ϊ������Ϊ0��ż��
10 | static public int isOdd(int num)
11 | {
12 | return num & 0x1;
13 | }
14 | //-------------------------------------------------------
15 | static public int HexToInt(String inHex)//Hex�ַ���תint
16 | {
17 | return Integer.parseInt(inHex, 16);
18 | }
19 | //-------------------------------------------------------
20 | static public byte HexToByte(String inHex)//Hex�ַ���תbyte
21 | {
22 | return (byte)Integer.parseInt(inHex,16);
23 | }
24 | //-------------------------------------------------------
25 | static public String Byte2Hex(Byte inByte)//1�ֽ�ת2��Hex�ַ�
26 | {
27 | return String.format("%02x", inByte).toUpperCase();
28 | }
29 | //-------------------------------------------------------
30 | static public String ByteArrToHex(byte[] inBytArr)//�ֽ�����תתhex�ַ���
31 | {
32 | StringBuilder strBuilder=new StringBuilder();
33 | int j=inBytArr.length;
34 | for (int i = 0; i < j; i++)
35 | {
36 | strBuilder.append(Byte2Hex(inBytArr[i]));
37 | strBuilder.append(" ");
38 | }
39 | return strBuilder.toString();
40 | }
41 | //-------------------------------------------------------
42 | static public String ByteArrToHex(byte[] inBytArr,int offset,int byteCount)//�ֽ�����תתhex�ַ�������ѡ����
43 | {
44 | StringBuilder strBuilder=new StringBuilder();
45 | int j=byteCount;
46 | for (int i = offset; i < j; i++)
47 | {
48 | strBuilder.append(Byte2Hex(inBytArr[i]));
49 | }
50 | return strBuilder.toString();
51 | }
52 | //-------------------------------------------------------
53 | //תhex�ַ���ת�ֽ�����
54 | static public byte[] HexToByteArr(String inHex)//hex�ַ���ת�ֽ�����
55 | {
56 | int hexlen = inHex.length();
57 | byte[] result;
58 | if (isOdd(hexlen)==1)
59 | {//����
60 | hexlen++;
61 | result = new byte[(hexlen/2)];
62 | inHex="0"+inHex;
63 | }else {//ż��
64 | result = new byte[(hexlen/2)];
65 | }
66 | int j=0;
67 | for (int i = 0; i < hexlen; i+=2)
68 | {
69 | result[j]=HexToByte(inHex.substring(i,i+2));
70 | j++;
71 | }
72 | return result;
73 | }
74 | }
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/java/com/silencefun/comtest/been/AssistBean.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest.been;
2 |
3 | import java.io.Serializable;
4 |
5 |
6 | public class AssistBean implements Serializable{
7 | private static final long serialVersionUID = -5620661009186692227L;
8 | private boolean isTxt=true;
9 | private String SendTxtA="COMA",SendTxtB="COMB",SendTxtC="COMC",SendTxtD="COMD";
10 | private String SendHexA="AA",SendHexB="BB",SendHexC="CC",SendHexD="DD";
11 | public String sTimeA="500";
12 | public String sTimeB="500";
13 | public String sTimeC="500";
14 | public String sTimeD="500";
15 | public boolean isTxt()
16 | {
17 | return isTxt;
18 | }
19 | public void setTxtMode(boolean isTxt)
20 | {
21 | this.isTxt = isTxt;
22 | }
23 |
24 | public String getSendA()
25 | {
26 | if (isTxt)
27 | {
28 | return SendTxtA;
29 | } else
30 | {
31 | return SendHexA;
32 | }
33 | }
34 | public String getSendB()
35 | {
36 | if (isTxt)
37 | {
38 | return SendTxtB;
39 | } else
40 | {
41 | return SendHexB;
42 | }
43 | }
44 | public String getSendC()
45 | {
46 | if (isTxt)
47 | {
48 | return SendTxtC;
49 | } else
50 | {
51 | return SendHexC;
52 | }
53 | }
54 | public String getSendD()
55 | {
56 | if (isTxt)
57 | {
58 | return SendTxtD;
59 | } else
60 | {
61 | return SendHexD;
62 | }
63 | }
64 |
65 | public void setSendA(String sendA)
66 | {
67 | if (isTxt)
68 | {
69 | SendTxtA = sendA;
70 | } else
71 | {
72 | SendHexA = sendA;
73 | }
74 | }
75 |
76 | public void setSendB(String sendB)
77 | {
78 | if (isTxt)
79 | {
80 | SendTxtB = sendB;
81 | } else
82 | {
83 | SendHexB = sendB;
84 | }
85 | }
86 |
87 | public void setSendC(String sendC)
88 | {
89 | if (isTxt)
90 | {
91 | SendTxtC = sendC;
92 | } else
93 | {
94 | SendHexC = sendC;
95 | }
96 | }
97 |
98 | public void setSendD(String sendD)
99 | {
100 | if (isTxt)
101 | {
102 | SendTxtD = sendD;
103 | } else
104 | {
105 | SendHexD = sendD;
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/java/com/silencefun/comtest/been/ComBean.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest.been;
2 |
3 | import java.text.SimpleDateFormat;
4 |
5 | /**
6 | * Created by silencefun on 2018/1/20.
7 | */
8 |
9 | public class ComBean {
10 |
11 | public byte[] bRec=null;
12 | public String sRecTime="";
13 | public String sComPort="";
14 | public ComBean(String sPort,byte[] buffer,int size){
15 | sComPort=sPort;
16 | bRec=new byte[size];
17 | for (int i = 0; i < size; i++)
18 | {
19 | bRec[i]=buffer[i];
20 | }
21 | SimpleDateFormat sDateFormat = new SimpleDateFormat("hh:mm:ss");
22 | sRecTime = sDateFormat.format(new java.util.Date());
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/java/com/silencefun/comtest/serialport/SerialPort.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.silencefun.comtest.serialport;
18 |
19 | import java.io.File;
20 | import java.io.FileDescriptor;
21 | import java.io.FileInputStream;
22 | import java.io.FileOutputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 | import java.io.OutputStream;
26 |
27 | import android.util.Log;
28 |
29 | public class SerialPort {
30 |
31 | private static final String TAG = "SerialPort";
32 |
33 | /*
34 | * Do not remove or rename the field mFd: it is used by native method close();
35 | */
36 | private FileDescriptor mFd;
37 | private FileInputStream mFileInputStream;
38 | private FileOutputStream mFileOutputStream;
39 |
40 | public SerialPort(File device, int baudrate, int flags) throws SecurityException, IOException {
41 |
42 |
43 |
44 | mFd = open(device.getAbsolutePath(), baudrate, flags);
45 | if (mFd == null) {
46 | Log.e(TAG, "native open returns null");
47 | throw new IOException();
48 | }
49 | mFileInputStream = new FileInputStream(mFd);
50 | mFileOutputStream = new FileOutputStream(mFd);
51 | }
52 |
53 | // Getters and setters
54 | public InputStream getInputStream() {
55 | return mFileInputStream;
56 | }
57 |
58 | public OutputStream getOutputStream() {
59 | return mFileOutputStream;
60 | }
61 |
62 | // JNI
63 | private native static FileDescriptor open(String path, int baudrate, int flags);
64 | public native void close();
65 | static {
66 | System.loadLibrary("native-lib");
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/java/com/silencefun/comtest/serialport/SerialPortFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.silencefun.comtest.serialport;
18 |
19 | import java.io.File;
20 | import java.io.FileReader;
21 | import java.io.IOException;
22 | import java.io.LineNumberReader;
23 | import java.util.Iterator;
24 | import java.util.Vector;
25 |
26 | import android.util.Log;
27 |
28 | public class SerialPortFinder {
29 |
30 | public class Driver {
31 | public Driver(String name, String root) {
32 | mDriverName = name;
33 | mDeviceRoot = root;
34 | }
35 | private String mDriverName;
36 | private String mDeviceRoot;
37 | Vector mDevices = null;
38 | public Vector getDevices() {
39 | if (mDevices == null) {
40 | mDevices = new Vector();
41 | File dev = new File("/dev");
42 | File[] files = dev.listFiles();
43 | int i;
44 | for (i=0; i mDrivers = null;
61 |
62 | Vector getDrivers() throws IOException {
63 | if (mDrivers == null) {
64 | mDrivers = new Vector();
65 | LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
66 | String l;
67 | while((l = r.readLine()) != null) {
68 | // Issue 3:
69 | // Since driver name may contain spaces, we do not extract driver name with split()
70 | String drivername = l.substring(0, 0x15).trim();
71 | String[] w = l.split(" +");
72 | if ((w.length >= 5) && (w[w.length-1].equals("serial"))) {
73 | Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length-4]);
74 | mDrivers.add(new Driver(drivername, w[w.length-4]));
75 | }
76 | }
77 | r.close();
78 | }
79 | return mDrivers;
80 | }
81 |
82 | public String[] getAllDevices() {
83 | Vector devices = new Vector();
84 | // Parse each driver
85 | Iterator itdriv;
86 | try {
87 | itdriv = getDrivers().iterator();
88 | while(itdriv.hasNext()) {
89 | Driver driver = itdriv.next();
90 | Iterator itdev = driver.getDevices().iterator();
91 | while(itdev.hasNext()) {
92 | String device = itdev.next().getName();
93 | String value = String.format("%s (%s)", device, driver.getName());
94 | devices.add(value);
95 | }
96 | }
97 | } catch (IOException e) {
98 | e.printStackTrace();
99 | }
100 | return devices.toArray(new String[devices.size()]);
101 | }
102 |
103 | public String[] getAllDevicesPath() {
104 | Vector devices = new Vector();
105 | // Parse each driver
106 | Iterator itdriv;
107 | try {
108 | itdriv = getDrivers().iterator();
109 | while(itdriv.hasNext()) {
110 | Driver driver = itdriv.next();
111 | Iterator itdev = driver.getDevices().iterator();
112 | while(itdev.hasNext()) {
113 | String device = itdev.next().getAbsolutePath();
114 | devices.add(device);
115 | }
116 | }
117 | } catch (IOException e) {
118 | e.printStackTrace();
119 | }
120 | return devices.toArray(new String[devices.size()]);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/values/baudrates.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - 50
6 | - 75
7 | - 110
8 | - 134
9 | - 150
10 | - 200
11 | - 300
12 | - 600
13 | - 1200
14 | - 1800
15 | - 2400
16 | - 4800
17 | - 9600
18 | - 19200
19 | - 38400
20 | - 57600
21 | - 115200
22 | - 230400
23 | - 460800
24 | - 500000
25 | - 576000
26 | - 921600
27 | - 1000000
28 | - 1152000
29 | - 1500000
30 | - 2000000
31 | - 2500000
32 | - 3000000
33 | - 3500000
34 | - 4000000
35 |
36 |
37 | - 50
38 | - 75
39 | - 110
40 | - 134
41 | - 150
42 | - 200
43 | - 300
44 | - 600
45 | - 1200
46 | - 1800
47 | - 2400
48 | - 4800
49 | - 9600
50 | - 19200
51 | - 38400
52 | - 57600
53 | - 115200
54 | - 230400
55 | - 460800
56 | - 500000
57 | - 576000
58 | - 921600
59 | - 1000000
60 | - 1152000
61 | - 1500000
62 | - 2000000
63 | - 2500000
64 | - 3000000
65 | - 3500000
66 | - 4000000
67 |
68 |
69 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hello World, ComAssistantActivity!
5 | ComAssistant
6 |
7 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/app/src/test/java/com/silencefun/comtest/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.0'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/build/android-profile/profile-2018-03-06-13-34-02-587.rawproto:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/build/android-profile/profile-2018-03-06-13-34-02-587.rawproto
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 05 15:00:23 CST 2018
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-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Mon Mar 05 15:00:23 CST 2018
11 | ndk.dir=F\:\\sdk\\ndk-bundle
12 | sdk.dir=F\:\\sdk
13 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/ComTest_AndroidStudio3.0/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/AndroidStuido_3.0_COMTEST/readme.md:
--------------------------------------------------------------------------------
1 | Android Studio 3.0 cmake 方式实现
2 |
3 | 详情请参考Android 串口通信开发笔记3
4 | https://www.jianshu.com/p/6a6c47a3b01b
5 |
--------------------------------------------------------------------------------
/Android_SetN81/ComTest.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Android_SetN81/app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | add_library( # Sets the name of the library.
14 | native-lib
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).
20 | src/main/cpp/native-lib.c)
21 |
22 | # Searches for a specified prebuilt library and stores the path as a
23 | # variable. Because CMake includes system libraries in the search path by
24 | # default, you only need to specify the name of the public NDK library
25 | # you want to add. CMake verifies that the library exists before
26 | # completing its build.
27 |
28 | find_library( # Sets the name of the path variable.
29 | log-lib
30 |
31 | # Specifies the name of the NDK library that
32 | # you want CMake to locate.
33 | log )
34 |
35 | # Specifies libraries CMake should link to your target library. You
36 | # can link multiple libraries, such as libraries you define in this
37 | # build script, prebuilt third-party libraries, or system libraries.
38 |
39 | target_link_libraries( # Specifies the target library.
40 | native-lib
41 |
42 | # Links the target library to the log library
43 | # included in the NDK.
44 | ${log-lib} )
--------------------------------------------------------------------------------
/Android_SetN81/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | android {
3 | compileSdkVersion 25
4 | defaultConfig {
5 | applicationId "com.silencefun.comtest"
6 | minSdkVersion 19
7 | targetSdkVersion 25
8 | versionCode 1
9 | versionName "1.0"
10 | externalNativeBuild {
11 | cmake {
12 | cppFlags ""
13 | }
14 | }
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | externalNativeBuild {
23 | cmake {
24 | path "CMakeLists.txt"
25 | }
26 | }
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(include: ['*.jar'], dir: 'libs')
31 | compile 'com.android.support:appcompat-v7:25.2.0'
32 | testImplementation 'junit:junit:4.12'
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/Android_SetN81/app/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 |
--------------------------------------------------------------------------------
/Android_SetN81/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/release/app-release.apk
--------------------------------------------------------------------------------
/Android_SetN81/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.silencefun.comtest","split":"","minSdkVersion":"19"}}]
--------------------------------------------------------------------------------
/Android_SetN81/app/src/androidTest/java/com/silencefun/comtest/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest;
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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.silencefun.comtest", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/java/com/silencefun/comtest/MyFunc.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest;
2 |
3 | /**
4 | * @author benjaminwan
5 | *����ת������
6 | */
7 | public class MyFunc {
8 | //-------------------------------------------------------
9 | // �ж�������ż����λ���㣬���һλ��1��Ϊ������Ϊ0��ż��
10 | static public int isOdd(int num)
11 | {
12 | return num & 0x1;
13 | }
14 | //-------------------------------------------------------
15 | static public int HexToInt(String inHex)//Hex�ַ���תint
16 | {
17 | return Integer.parseInt(inHex, 16);
18 | }
19 | //-------------------------------------------------------
20 | static public byte HexToByte(String inHex)//Hex�ַ���תbyte
21 | {
22 | return (byte)Integer.parseInt(inHex,16);
23 | }
24 | //-------------------------------------------------------
25 | static public String Byte2Hex(Byte inByte)//1�ֽ�ת2��Hex�ַ�
26 | {
27 | return String.format("%02x", inByte).toUpperCase();
28 | }
29 | //-------------------------------------------------------
30 | static public String ByteArrToHex(byte[] inBytArr)//�ֽ�����תתhex�ַ���
31 | {
32 | StringBuilder strBuilder=new StringBuilder();
33 | int j=inBytArr.length;
34 | for (int i = 0; i < j; i++)
35 | {
36 | strBuilder.append(Byte2Hex(inBytArr[i]));
37 | strBuilder.append(" ");
38 | }
39 | return strBuilder.toString();
40 | }
41 | //-------------------------------------------------------
42 | static public String ByteArrToHex(byte[] inBytArr,int offset,int byteCount)//�ֽ�����תתhex�ַ�������ѡ����
43 | {
44 | StringBuilder strBuilder=new StringBuilder();
45 | int j=byteCount;
46 | for (int i = offset; i < j; i++)
47 | {
48 | strBuilder.append(Byte2Hex(inBytArr[i]));
49 | }
50 | return strBuilder.toString();
51 | }
52 | //-------------------------------------------------------
53 | //תhex�ַ���ת�ֽ�����
54 | static public byte[] HexToByteArr(String inHex)//hex�ַ���ת�ֽ�����
55 | {
56 | int hexlen = inHex.length();
57 | byte[] result;
58 | if (isOdd(hexlen)==1)
59 | {//����
60 | hexlen++;
61 | result = new byte[(hexlen/2)];
62 | inHex="0"+inHex;
63 | }else {//ż��
64 | result = new byte[(hexlen/2)];
65 | }
66 | int j=0;
67 | for (int i = 0; i < hexlen; i+=2)
68 | {
69 | result[j]=HexToByte(inHex.substring(i,i+2));
70 | j++;
71 | }
72 | return result;
73 | }
74 | }
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/java/com/silencefun/comtest/been/AssistBean.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest.been;
2 |
3 | import java.io.Serializable;
4 |
5 |
6 | public class AssistBean implements Serializable{
7 | private static final long serialVersionUID = -5620661009186692227L;
8 | private boolean isTxt=true;
9 | private String SendTxtA="test" ;
10 | private String SendHexA="AA";
11 | public String sTimeA="500";
12 |
13 | public boolean isTxt()
14 | {
15 | return isTxt;
16 | }
17 | public void setTxtMode(boolean isTxt)
18 | {
19 | this.isTxt = isTxt;
20 | }
21 |
22 | public String getSendA()
23 | {
24 | if (isTxt)
25 | {
26 | return SendTxtA;
27 | } else
28 | {
29 | return SendHexA;
30 | }
31 | }
32 |
33 |
34 | public void setSendA(String sendA)
35 | {
36 | if (isTxt)
37 | {
38 | SendTxtA = sendA;
39 | } else
40 | {
41 | SendHexA = sendA;
42 | }
43 | }
44 |
45 |
46 | }
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/java/com/silencefun/comtest/been/ComBean.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest.been;
2 |
3 | import java.text.SimpleDateFormat;
4 |
5 | /**
6 | * Created by silencefun on 2018/1/20.
7 | */
8 |
9 | public class ComBean {
10 |
11 | public byte[] bRec=null;
12 | public String sRecTime="";
13 | public String sComPort="";
14 | public ComBean(String sPort,byte[] buffer,int size){
15 | sComPort=sPort;
16 | bRec=new byte[size];
17 | for (int i = 0; i < size; i++)
18 | {
19 | bRec[i]=buffer[i];
20 | }
21 | SimpleDateFormat sDateFormat = new SimpleDateFormat("hh:mm:ss");
22 | sRecTime = sDateFormat.format(new java.util.Date());
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/java/com/silencefun/comtest/serialport/SerialPort.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.silencefun.comtest.serialport;
18 |
19 | import java.io.File;
20 | import java.io.FileDescriptor;
21 | import java.io.FileInputStream;
22 | import java.io.FileOutputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 | import java.io.OutputStream;
26 |
27 | import android.util.Log;
28 |
29 | public class SerialPort {
30 |
31 | private static final String TAG = "SerialPort";
32 |
33 | /*
34 | * Do not remove or rename the field mFd: it is used by native method close();
35 | */
36 | private FileDescriptor mFd;
37 | private FileInputStream mFileInputStream;
38 | private FileOutputStream mFileOutputStream;
39 |
40 | public SerialPort(File device, int baudrate, int dataBits, int stopBits, char parity) throws SecurityException, IOException {
41 |
42 |
43 | // mFd = open(device.getAbsolutePath(), baudrate, flags);
44 |
45 | mFd = open(device.getAbsolutePath(), baudrate,dataBits,stopBits,parity);
46 | if (mFd == null) {
47 | Log.e(TAG, "native open returns null");
48 | throw new IOException();
49 | }
50 | mFileInputStream = new FileInputStream(mFd);
51 | mFileOutputStream = new FileOutputStream(mFd);
52 | }
53 | public SerialPort(File device, int baudrate, int flags) throws SecurityException, IOException {
54 |
55 |
56 | // mFd = open(device.getAbsolutePath(), baudrate, flags);
57 |
58 | mFd = open(device.getAbsolutePath(), baudrate,8,2,'E');
59 | if (mFd == null) {
60 | Log.e(TAG, "native open returns null");
61 | throw new IOException();
62 | }
63 | mFileInputStream = new FileInputStream(mFd);
64 | mFileOutputStream = new FileOutputStream(mFd);
65 | }
66 | // Getters and setters
67 | public InputStream getInputStream() {
68 | return mFileInputStream;
69 | }
70 |
71 | public OutputStream getOutputStream() {
72 | return mFileOutputStream;
73 | }
74 |
75 | // JNI
76 | private native static FileDescriptor open(String path, int baudrate, int flags);
77 |
78 | // 调用JNI中 打开方法的声明
79 |
80 | /**
81 | * @param dataBits 类型 int数据位 取值 位7或8
82 | * @param parity char校验类型 取值N ,E, O,,S
83 | * @param stopBits 类型 int 停止位 取值1 或者 2
84 | * @return
85 | */
86 | private native static FileDescriptor open(String path, int baudrate, int dataBits, int stopBits, char parity);
87 |
88 | public native void close();
89 |
90 | static {
91 | System.loadLibrary("native-lib");
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/java/com/silencefun/comtest/serialport/SerialPortFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.silencefun.comtest.serialport;
18 |
19 | import java.io.File;
20 | import java.io.FileReader;
21 | import java.io.IOException;
22 | import java.io.LineNumberReader;
23 | import java.util.Iterator;
24 | import java.util.Vector;
25 |
26 | import android.util.Log;
27 |
28 | public class SerialPortFinder {
29 |
30 | public class Driver {
31 | public Driver(String name, String root) {
32 | mDriverName = name;
33 | mDeviceRoot = root;
34 | }
35 | private String mDriverName;
36 | private String mDeviceRoot;
37 | Vector mDevices = null;
38 | public Vector getDevices() {
39 | if (mDevices == null) {
40 | mDevices = new Vector();
41 | File dev = new File("/dev");
42 | File[] files = dev.listFiles();
43 | int i;
44 | for (i=0; i mDrivers = null;
61 |
62 | Vector getDrivers() throws IOException {
63 | if (mDrivers == null) {
64 | mDrivers = new Vector();
65 | LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
66 | String l;
67 | while((l = r.readLine()) != null) {
68 | // Issue 3:
69 | // Since driver name may contain spaces, we do not extract driver name with split()
70 | String drivername = l.substring(0, 0x15).trim();
71 | String[] w = l.split(" +");
72 | if ((w.length >= 5) && (w[w.length-1].equals("serial"))) {
73 | Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length-4]);
74 | mDrivers.add(new Driver(drivername, w[w.length-4]));
75 | }
76 | }
77 | r.close();
78 | }
79 | return mDrivers;
80 | }
81 |
82 | public String[] getAllDevices() {
83 | Vector devices = new Vector();
84 | // Parse each driver
85 | Iterator itdriv;
86 | try {
87 | itdriv = getDrivers().iterator();
88 | while(itdriv.hasNext()) {
89 | Driver driver = itdriv.next();
90 | Iterator itdev = driver.getDevices().iterator();
91 | while(itdev.hasNext()) {
92 | String device = itdev.next().getName();
93 | String value = String.format("%s (%s)", device, driver.getName());
94 | devices.add(value);
95 | }
96 | }
97 | } catch (IOException e) {
98 | e.printStackTrace();
99 | }
100 | return devices.toArray(new String[devices.size()]);
101 | }
102 |
103 | public String[] getAllDevicesPath() {
104 | Vector devices = new Vector();
105 | // Parse each driver
106 | Iterator itdriv;
107 | try {
108 | itdriv = getDrivers().iterator();
109 | while(itdriv.hasNext()) {
110 | Driver driver = itdriv.next();
111 | Iterator itdev = driver.getDevices().iterator();
112 | while(itdev.hasNext()) {
113 | String device = itdev.next().getAbsolutePath();
114 | devices.add(device);
115 | }
116 | }
117 | } catch (IOException e) {
118 | e.printStackTrace();
119 | }
120 | return devices.toArray(new String[devices.size()]);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/drawable-v24/corner_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/drawable-v24/corner_view_gray.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/drawable/corner_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/drawable/corner_view_gray.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/layout/include_common_head.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
18 |
19 |
20 |
33 |
34 |
45 |
46 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-hdpi/icon_return_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-hdpi/icon_return_black.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/values-v19/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
15 |
16 |
24 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/values-v21/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 25dp
4 |
5 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/values/baudrates.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - 50
6 | - 75
7 | - 110
8 | - 134
9 | - 150
10 | - 200
11 | - 300
12 | - 600
13 | - 1200
14 | - 1800
15 | - 2400
16 | - 4800
17 | - 9600
18 | - 19200
19 | - 38400
20 | - 57600
21 | - 115200
22 | - 230400
23 | - 460800
24 | - 500000
25 | - 576000
26 | - 921600
27 | - 1000000
28 | - 1152000
29 | - 1500000
30 | - 2000000
31 | - 2500000
32 | - 3000000
33 | - 3500000
34 | - 4000000
35 |
36 |
37 | - 50
38 | - 75
39 | - 110
40 | - 134
41 | - 150
42 | - 200
43 | - 300
44 | - 600
45 | - 1200
46 | - 1800
47 | - 2400
48 | - 4800
49 | - 9600
50 | - 19200
51 | - 38400
52 | - 57600
53 | - 115200
54 | - 230400
55 | - 460800
56 | - 500000
57 | - 576000
58 | - 921600
59 | - 1000000
60 | - 1152000
61 | - 1500000
62 | - 2000000
63 | - 2500000
64 | - 3000000
65 | - 3500000
66 | - 4000000
67 |
68 |
69 | - N
70 | - O
71 | - E
72 |
73 |
74 |
75 | - 8
76 | - 7
77 |
78 |
79 | - 1
80 | - 2
81 |
82 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | #FF6600
9 | #42a9ff
10 |
11 | #C0B7b0
12 |
13 | #d6d6d6
14 |
15 |
16 |
17 | #2196F3
18 | #1976D2
19 | #BBDEFB
20 | #ADD8E6
21 | #66000000
22 | @color/colorPrimary
23 |
24 | #f3f3f3
25 | #999999
26 |
27 | #dbdbdb
28 |
29 | #bdd1d0d0
30 |
31 | #80000000
32 | #50adadad
33 |
34 |
35 | #f2a201
36 | #007ade
37 | #e7a2c7
38 | #acacac
39 | #e9e9e9
40 | #b21616
41 | #d3d3d3
42 | #ababab
43 | #666666
44 |
45 |
46 | #6b2a84
47 |
48 | #33000000
49 |
50 | #00000000
51 |
52 | #FFFFFF
53 | #dddddd
54 | #000000
55 |
56 | #FF0000
57 | #00FF00
58 | #000FF0
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 25dp
4 |
5 |
6 |
7 | 36sp
8 |
9 | 26sp
10 |
11 | 60sp
12 |
13 | 20sp
14 |
15 | 16sp
16 |
17 |
18 | 16dp
19 | 1dp
20 | 2dp
21 | 48dp
22 | 64dp
23 |
24 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | hello
5 | 安默串口调试工具
6 | ca-app-pub-7888464047936141~9816752609
7 | ASCII
8 | HEX
9 |
10 | 清除
11 | 自清
12 | 输入要发送的内容
13 | 串口路径
14 |
15 |
16 | 波特率
17 | 数据位
18 | 停止位
19 | 校验方式
20 |
21 |
22 | 设定自动发送时间间隔
23 | 自动发送
24 | 发送
25 |
26 | 1.此 安默 串口调试工具 支持 数据位 校验位 校验方式的设定(默认是N-8-1),\n2.有任何建议问题,请联系github@siencefun ,欢迎STAR. \n3.选择自清则接收区域达到500项自动清除
27 |
28 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Android_SetN81/app/src/test/java/com/silencefun/comtest/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/Android_SetN81/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.0'
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | google()
19 | jcenter()
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/Android_SetN81/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/Android_SetN81/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/Android_SetN81/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Android_SetN81/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 05 15:00:23 CST 2018
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-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/Android_SetN81/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Android_SetN81/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Android_SetN81/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Mon Mar 05 15:00:23 CST 2018
11 | ndk.dir=F\:\\sdk\\ndk-bundle
12 | sdk.dir=F\:\\sdk
13 |
--------------------------------------------------------------------------------
/Android_SetN81/readme.md:
--------------------------------------------------------------------------------
1 | 1.此 安默(总得起个名吧 silencefun ----> fun-silence 安默出来了) 串口调试工具 支持 数据位 校验位 校验方式的设定(默认是N-8-1)
2 |
3 | 2.简书地址https://www.jianshu.com/p/0868e90303be
4 |
5 | 3.项目参考N久前不知哪位大神的 Eclipse 下的 串口调试工具源码 ,不知如何关联 原作者,但是表示敬意。
6 |
7 | 4.原UI还是照搬 Eclipse 项目的 后来感觉 有点 low 更改完UI 在app-release 下有生成的的一个 apk 尚未测试应该没问题。
8 |
--------------------------------------------------------------------------------
/Android_SetN81/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/ComAssistant/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ComAssistant/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | javaapk.com-ComAssistant
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ComAssistant/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.7
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.7
12 |
--------------------------------------------------------------------------------
/ComAssistant/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/ComAssistant/bin/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/ComAssistant/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes.dex
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/android_serialport_api/SerialPort.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/android_serialport_api/SerialPort.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/android_serialport_api/SerialPortFinder$Driver.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/android_serialport_api/SerialPortFinder$Driver.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/android_serialport_api/SerialPortFinder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/android_serialport_api/SerialPortFinder.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/BuildConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/BuildConfig.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$ButtonClickEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$ButtonClickEvent.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$CheckBoxChangeEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$CheckBoxChangeEvent.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$DispQueueThread$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$DispQueueThread$1.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$DispQueueThread.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$DispQueueThread.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$EditorActionEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$EditorActionEvent.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$FocusChangeEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$FocusChangeEvent.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$ItemSelectedEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$ItemSelectedEvent.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$SerialControl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$SerialControl.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$ToggleButtonCheckedChangeEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$ToggleButtonCheckedChangeEvent.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$radioButtonClickEvent$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$radioButtonClickEvent$1.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$radioButtonClickEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity$radioButtonClickEvent.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/ComAssistantActivity.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/MyFunc.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/MyFunc.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/R$array.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/R$array.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/R$attr.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/R$drawable.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/R$id.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/R$layout.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/R$string.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/R.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/SerialHelper$ReadThread.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/SerialHelper$ReadThread.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/SerialHelper$SendThread.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/SerialHelper$SendThread.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/ComAssistant/SerialHelper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/ComAssistant/SerialHelper.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/bean/AssistBean.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/bean/AssistBean.class
--------------------------------------------------------------------------------
/ComAssistant/bin/classes/com/bjw/bean/ComBean.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/classes/com/bjw/bean/ComBean.class
--------------------------------------------------------------------------------
/ComAssistant/bin/jarlist.cache:
--------------------------------------------------------------------------------
1 | # cache for current jar dependency. DO NOT EDIT.
2 | # format is
3 | # Encoding is UTF-8
4 |
--------------------------------------------------------------------------------
/ComAssistant/bin/javaapk.com-ComAssistant.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/javaapk.com-ComAssistant.apk
--------------------------------------------------------------------------------
/ComAssistant/bin/res/crunch/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/res/crunch/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComAssistant/bin/res/crunch/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/res/crunch/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComAssistant/bin/res/crunch/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/res/crunch/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComAssistant/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/bin/resources.ap_
--------------------------------------------------------------------------------
/ComAssistant/gen/com/bjw/ComAssistant/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.bjw.ComAssistant;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/ComAssistant/gen/com/bjw/ComAssistant/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.bjw.ComAssistant;
9 |
10 | public final class R {
11 | public static final class array {
12 | public static final int baudrates_name=0x7f040000;
13 | public static final int baudrates_value=0x7f040001;
14 | }
15 | public static final class attr {
16 | }
17 | public static final class drawable {
18 | public static final int ic_launcher=0x7f020000;
19 | }
20 | public static final class id {
21 | public static final int ButtonClear=0x7f060003;
22 | public static final int ButtonSendCOMA=0x7f060015;
23 | public static final int ButtonSendCOMB=0x7f060021;
24 | public static final int ButtonSendCOMC=0x7f06002e;
25 | public static final int ButtonSendCOMD=0x7f06003a;
26 | public static final int LinearLayoutALLCOM=0x7f06003b;
27 | public static final int LinearLayoutCOMA=0x7f06000a;
28 | public static final int LinearLayoutCOMAB=0x7f060009;
29 | public static final int LinearLayoutCOMB=0x7f060016;
30 | public static final int LinearLayoutCOMC=0x7f060023;
31 | public static final int LinearLayoutCOMCD=0x7f060022;
32 | public static final int LinearLayoutCOMD=0x7f06002f;
33 | public static final int LinearLayoutOption1COMA=0x7f06000e;
34 | public static final int LinearLayoutOption1COMB=0x7f06001a;
35 | public static final int LinearLayoutOption1COMC=0x7f060027;
36 | public static final int LinearLayoutOption1COMD=0x7f060033;
37 | public static final int LinearLayoutOption2COMA=0x7f060011;
38 | public static final int LinearLayoutOption2COMB=0x7f06001d;
39 | public static final int LinearLayoutOption2COMC=0x7f06002a;
40 | public static final int LinearLayoutOption2COMD=0x7f060036;
41 | public static final int LinearLayoutRecDisp=0x7f060000;
42 | public static final int LinearLayoutRecTool=0x7f060002;
43 | public static final int LinearLayoutTooLCOMA=0x7f06000c;
44 | public static final int LinearLayoutTooLCOMB=0x7f060018;
45 | public static final int LinearLayoutTooLCOMC=0x7f060025;
46 | public static final int LinearLayoutTooLCOMD=0x7f060031;
47 | public static final int SpinnerBaudRateCOMA=0x7f06000f;
48 | public static final int SpinnerBaudRateCOMB=0x7f06001b;
49 | public static final int SpinnerBaudRateCOMC=0x7f060028;
50 | public static final int SpinnerBaudRateCOMD=0x7f060034;
51 | public static final int SpinnerCOMA=0x7f06000d;
52 | public static final int SpinnerCOMB=0x7f060019;
53 | public static final int SpinnerCOMC=0x7f060026;
54 | public static final int SpinnerCOMD=0x7f060032;
55 | public static final int TextView01=0x7f06001f;
56 | public static final int TextView02=0x7f06002c;
57 | public static final int TextView03=0x7f060038;
58 | public static final int ToggleButtonCOMB=0x7f06001c;
59 | public static final int ToggleButtonCOMC=0x7f060029;
60 | public static final int ToggleButtonCOMD=0x7f060035;
61 | public static final int checkBoxAutoCOMA=0x7f060014;
62 | public static final int checkBoxAutoCOMB=0x7f060020;
63 | public static final int checkBoxAutoCOMC=0x7f06002d;
64 | public static final int checkBoxAutoCOMD=0x7f060039;
65 | public static final int checkBoxAutoClear=0x7f060008;
66 | public static final int editTextCOMA=0x7f06000b;
67 | public static final int editTextCOMB=0x7f060017;
68 | public static final int editTextCOMC=0x7f060024;
69 | public static final int editTextCOMD=0x7f060030;
70 | public static final int editTextLines=0x7f060007;
71 | public static final int editTextRecDisp=0x7f060001;
72 | public static final int editTextTimeCOMA=0x7f060012;
73 | public static final int editTextTimeCOMB=0x7f06001e;
74 | public static final int editTextTimeCOMC=0x7f06002b;
75 | public static final int editTextTimeCOMD=0x7f060037;
76 | public static final int radioButtonHex=0x7f060006;
77 | public static final int radioButtonTxt=0x7f060005;
78 | public static final int radioGroupOption=0x7f060004;
79 | public static final int textView1=0x7f060013;
80 | public static final int toggleButtonCOMA=0x7f060010;
81 | }
82 | public static final class layout {
83 | public static final int main=0x7f030000;
84 | }
85 | public static final class string {
86 | public static final int app_name=0x7f050001;
87 | public static final int hello=0x7f050000;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/ComAssistant/jni/Android.mk:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2009 Cedric Priscal
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | LOCAL_PATH := $(call my-dir)
18 |
19 | include $(CLEAR_VARS)
20 |
21 | TARGET_PLATFORM := android-3
22 | LOCAL_MODULE := serial_port
23 | LOCAL_SRC_FILES := SerialPort.c
24 | LOCAL_LDLIBS := -llog
25 |
26 | include $(BUILD_SHARED_LIBRARY)
27 |
--------------------------------------------------------------------------------
/ComAssistant/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_ABI := armeabi armeabi-v7a x86
2 |
--------------------------------------------------------------------------------
/ComAssistant/jni/SerialPort.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009-2011 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #include "SerialPort.h"
26 |
27 | #include "android/log.h"
28 | static const char *TAG="serial_port";
29 | #define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##args)
30 | #define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, TAG, fmt, ##args)
31 | #define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##args)
32 |
33 | static speed_t getBaudrate(jint baudrate)
34 | {
35 | switch(baudrate) {
36 | case 0: return B0;
37 | case 50: return B50;
38 | case 75: return B75;
39 | case 110: return B110;
40 | case 134: return B134;
41 | case 150: return B150;
42 | case 200: return B200;
43 | case 300: return B300;
44 | case 600: return B600;
45 | case 1200: return B1200;
46 | case 1800: return B1800;
47 | case 2400: return B2400;
48 | case 4800: return B4800;
49 | case 9600: return B9600;
50 | case 19200: return B19200;
51 | case 38400: return B38400;
52 | case 57600: return B57600;
53 | case 115200: return B115200;
54 | case 230400: return B230400;
55 | case 460800: return B460800;
56 | case 500000: return B500000;
57 | case 576000: return B576000;
58 | case 921600: return B921600;
59 | case 1000000: return B1000000;
60 | case 1152000: return B1152000;
61 | case 1500000: return B1500000;
62 | case 2000000: return B2000000;
63 | case 2500000: return B2500000;
64 | case 3000000: return B3000000;
65 | case 3500000: return B3500000;
66 | case 4000000: return B4000000;
67 | default: return -1;
68 | }
69 | }
70 |
71 | /*
72 | * Class: android_serialport_SerialPort
73 | * Method: open
74 | * Signature: (Ljava/lang/String;II)Ljava/io/FileDescriptor;
75 | */
76 | JNIEXPORT jobject JNICALL Java_android_1serialport_1api_SerialPort_open
77 | (JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags)
78 | {
79 | int fd;
80 | speed_t speed;
81 | jobject mFileDescriptor;
82 |
83 | /* Check arguments */
84 | {
85 | speed = getBaudrate(baudrate);
86 | if (speed == -1) {
87 | /* TODO: throw an exception */
88 | LOGE("Invalid baudrate");
89 | return NULL;
90 | }
91 | }
92 |
93 | /* Opening device */
94 | {
95 | jboolean iscopy;
96 | const char *path_utf = (*env)->GetStringUTFChars(env, path, &iscopy);
97 | LOGD("Opening serial port %s with flags 0x%x", path_utf, O_RDWR | flags);
98 | fd = open(path_utf, O_RDWR | flags);
99 | LOGD("open() fd = %d", fd);
100 | (*env)->ReleaseStringUTFChars(env, path, path_utf);
101 | if (fd == -1)
102 | {
103 | /* Throw an exception */
104 | LOGE("Cannot open port");
105 | /* TODO: throw an exception */
106 | return NULL;
107 | }
108 | }
109 |
110 | /* Configure device */
111 | {
112 | struct termios cfg;
113 | LOGD("Configuring serial port");
114 | if (tcgetattr(fd, &cfg))
115 | {
116 | LOGE("tcgetattr() failed");
117 | close(fd);
118 | /* TODO: throw an exception */
119 | return NULL;
120 | }
121 |
122 | cfmakeraw(&cfg);
123 | cfsetispeed(&cfg, speed);
124 | cfsetospeed(&cfg, speed);
125 |
126 | if (tcsetattr(fd, TCSANOW, &cfg))
127 | {
128 | LOGE("tcsetattr() failed");
129 | close(fd);
130 | /* TODO: throw an exception */
131 | return NULL;
132 | }
133 | }
134 |
135 | /* Create a corresponding file descriptor */
136 | {
137 | jclass cFileDescriptor = (*env)->FindClass(env, "java/io/FileDescriptor");
138 | jmethodID iFileDescriptor = (*env)->GetMethodID(env, cFileDescriptor, "", "()V");
139 | jfieldID descriptorID = (*env)->GetFieldID(env, cFileDescriptor, "descriptor", "I");
140 | mFileDescriptor = (*env)->NewObject(env, cFileDescriptor, iFileDescriptor);
141 | (*env)->SetIntField(env, mFileDescriptor, descriptorID, (jint)fd);
142 | }
143 |
144 | return mFileDescriptor;
145 | }
146 |
147 | /*
148 | * Class: cedric_serial_SerialPort
149 | * Method: close
150 | * Signature: ()V
151 | */
152 | JNIEXPORT void JNICALL Java_android_1serialport_1api_SerialPort_close
153 | (JNIEnv *env, jobject thiz)
154 | {
155 | jclass SerialPortClass = (*env)->GetObjectClass(env, thiz);
156 | jclass FileDescriptorClass = (*env)->FindClass(env, "java/io/FileDescriptor");
157 |
158 | jfieldID mFdID = (*env)->GetFieldID(env, SerialPortClass, "mFd", "Ljava/io/FileDescriptor;");
159 | jfieldID descriptorID = (*env)->GetFieldID(env, FileDescriptorClass, "descriptor", "I");
160 |
161 | jobject mFd = (*env)->GetObjectField(env, thiz, mFdID);
162 | jint descriptor = (*env)->GetIntField(env, mFd, descriptorID);
163 |
164 | LOGD("close(fd = %d)", descriptor);
165 | close(descriptor);
166 | }
167 |
168 |
--------------------------------------------------------------------------------
/ComAssistant/jni/SerialPort.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class android_serialport_api_SerialPort */
4 |
5 | #ifndef _Included_android_serialport_api_SerialPort
6 | #define _Included_android_serialport_api_SerialPort
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: android_serialport_api_SerialPort
12 | * Method: open
13 | * Signature: (Ljava/lang/String;II)Ljava/io/FileDescriptor;
14 | */
15 | JNIEXPORT jobject JNICALL Java_android_1serialport_1api_SerialPort_open
16 | (JNIEnv *, jclass, jstring, jint, jint);
17 |
18 | /*
19 | * Class: android_serialport_api_SerialPort
20 | * Method: close
21 | * Signature: ()V
22 | */
23 | JNIEXPORT void JNICALL Java_android_1serialport_1api_SerialPort_close
24 | (JNIEnv *, jobject);
25 |
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 | #endif
30 |
--------------------------------------------------------------------------------
/ComAssistant/jni/gen_SerialPort_h.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | javah -o SerialPort.h -jni -classpath ../src android_serialport_api.SerialPort
3 |
4 |
--------------------------------------------------------------------------------
/ComAssistant/libs/armeabi-v7a/libserial_port.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/libs/armeabi-v7a/libserial_port.so
--------------------------------------------------------------------------------
/ComAssistant/libs/armeabi/libserial_port.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/libs/armeabi/libserial_port.so
--------------------------------------------------------------------------------
/ComAssistant/libs/x86/libserial_port.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/libs/x86/libserial_port.so
--------------------------------------------------------------------------------
/ComAssistant/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/ComAssistant/obj/local/armeabi-v7a/libserial_port.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/obj/local/armeabi-v7a/libserial_port.so
--------------------------------------------------------------------------------
/ComAssistant/obj/local/armeabi-v7a/objs/serial_port/SerialPort.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/obj/local/armeabi-v7a/objs/serial_port/SerialPort.o
--------------------------------------------------------------------------------
/ComAssistant/obj/local/armeabi/libserial_port.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/obj/local/armeabi/libserial_port.so
--------------------------------------------------------------------------------
/ComAssistant/obj/local/armeabi/objs/serial_port/SerialPort.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/obj/local/armeabi/objs/serial_port/SerialPort.o
--------------------------------------------------------------------------------
/ComAssistant/obj/local/x86/libserial_port.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/obj/local/x86/libserial_port.so
--------------------------------------------------------------------------------
/ComAssistant/obj/local/x86/objs/serial_port/SerialPort.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/obj/local/x86/objs/serial_port/SerialPort.o
--------------------------------------------------------------------------------
/ComAssistant/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembers class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembers class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers class * extends android.app.Activity {
30 | public void *(android.view.View);
31 | }
32 |
33 | -keepclassmembers enum * {
34 | public static **[] values();
35 | public static ** valueOf(java.lang.String);
36 | }
37 |
38 | -keep class * implements android.os.Parcelable {
39 | public static final android.os.Parcelable$Creator *;
40 | }
41 |
--------------------------------------------------------------------------------
/ComAssistant/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-21
12 |
--------------------------------------------------------------------------------
/ComAssistant/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComAssistant/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComAssistant/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComAssistant/res/values/baudrates.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - 50
6 | - 75
7 | - 110
8 | - 134
9 | - 150
10 | - 200
11 | - 300
12 | - 600
13 | - 1200
14 | - 1800
15 | - 2400
16 | - 4800
17 | - 9600
18 | - 19200
19 | - 38400
20 | - 57600
21 | - 115200
22 | - 230400
23 | - 460800
24 | - 500000
25 | - 576000
26 | - 921600
27 | - 1000000
28 | - 1152000
29 | - 1500000
30 | - 2000000
31 | - 2500000
32 | - 3000000
33 | - 3500000
34 | - 4000000
35 |
36 |
37 | - 50
38 | - 75
39 | - 110
40 | - 134
41 | - 150
42 | - 200
43 | - 300
44 | - 600
45 | - 1200
46 | - 1800
47 | - 2400
48 | - 4800
49 | - 9600
50 | - 19200
51 | - 38400
52 | - 57600
53 | - 115200
54 | - 230400
55 | - 460800
56 | - 500000
57 | - 576000
58 | - 921600
59 | - 1000000
60 | - 1152000
61 | - 1500000
62 | - 2000000
63 | - 2500000
64 | - 3000000
65 | - 3500000
66 | - 4000000
67 |
68 |
69 |
--------------------------------------------------------------------------------
/ComAssistant/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hello World, ComAssistantActivity!
5 | ComAssistant
6 |
7 |
--------------------------------------------------------------------------------
/ComAssistant/src/android_serialport_api/SerialPort.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package android_serialport_api;
18 |
19 | import java.io.File;
20 | import java.io.FileDescriptor;
21 | import java.io.FileInputStream;
22 | import java.io.FileOutputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 | import java.io.OutputStream;
26 |
27 | import android.util.Log;
28 |
29 | public class SerialPort {
30 |
31 | private static final String TAG = "SerialPort";
32 |
33 | /*
34 | * Do not remove or rename the field mFd: it is used by native method close();
35 | */
36 | private FileDescriptor mFd;
37 | private FileInputStream mFileInputStream;
38 | private FileOutputStream mFileOutputStream;
39 |
40 | public SerialPort(File device, int baudrate, int flags) throws SecurityException, IOException {
41 |
42 | /* Check access permission */
43 | if (!device.canRead() || !device.canWrite()) {
44 | try {
45 | /* Missing read/write permission, trying to chmod the file */
46 | Process su;
47 | su = Runtime.getRuntime().exec("/system/bin/su");
48 | String cmd = "chmod 666 " + device.getAbsolutePath() + "\n"
49 | + "exit\n";
50 | su.getOutputStream().write(cmd.getBytes());
51 | if ((su.waitFor() != 0) || !device.canRead()
52 | || !device.canWrite()) {
53 | throw new SecurityException();
54 | }
55 | } catch (Exception e) {
56 | e.printStackTrace();
57 | throw new SecurityException();
58 | }
59 | }
60 |
61 | mFd = open(device.getAbsolutePath(), baudrate, flags);
62 | if (mFd == null) {
63 | Log.e(TAG, "native open returns null");
64 | throw new IOException();
65 | }
66 | mFileInputStream = new FileInputStream(mFd);
67 | mFileOutputStream = new FileOutputStream(mFd);
68 | }
69 |
70 | // Getters and setters
71 | public InputStream getInputStream() {
72 | return mFileInputStream;
73 | }
74 |
75 | public OutputStream getOutputStream() {
76 | return mFileOutputStream;
77 | }
78 |
79 | // JNI
80 | private native static FileDescriptor open(String path, int baudrate, int flags);
81 | public native void close();
82 | static {
83 | System.loadLibrary("serial_port");
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/ComAssistant/src/android_serialport_api/SerialPortFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package android_serialport_api;
18 |
19 | import java.io.File;
20 | import java.io.FileReader;
21 | import java.io.IOException;
22 | import java.io.LineNumberReader;
23 | import java.util.Iterator;
24 | import java.util.Vector;
25 |
26 | import android.util.Log;
27 |
28 | public class SerialPortFinder {
29 |
30 | public class Driver {
31 | public Driver(String name, String root) {
32 | mDriverName = name;
33 | mDeviceRoot = root;
34 | }
35 | private String mDriverName;
36 | private String mDeviceRoot;
37 | Vector mDevices = null;
38 | public Vector getDevices() {
39 | if (mDevices == null) {
40 | mDevices = new Vector();
41 | File dev = new File("/dev");
42 | File[] files = dev.listFiles();
43 | int i;
44 | for (i=0; i mDrivers = null;
61 |
62 | Vector getDrivers() throws IOException {
63 | if (mDrivers == null) {
64 | mDrivers = new Vector();
65 | LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
66 | String l;
67 | while((l = r.readLine()) != null) {
68 | // Issue 3:
69 | // Since driver name may contain spaces, we do not extract driver name with split()
70 | String drivername = l.substring(0, 0x15).trim();
71 | String[] w = l.split(" +");
72 | if ((w.length >= 5) && (w[w.length-1].equals("serial"))) {
73 | Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length-4]);
74 | mDrivers.add(new Driver(drivername, w[w.length-4]));
75 | }
76 | }
77 | r.close();
78 | }
79 | return mDrivers;
80 | }
81 |
82 | public String[] getAllDevices() {
83 | Vector devices = new Vector();
84 | // Parse each driver
85 | Iterator itdriv;
86 | try {
87 | itdriv = getDrivers().iterator();
88 | while(itdriv.hasNext()) {
89 | Driver driver = itdriv.next();
90 | Iterator itdev = driver.getDevices().iterator();
91 | while(itdev.hasNext()) {
92 | String device = itdev.next().getName();
93 | String value = String.format("%s (%s)", device, driver.getName());
94 | devices.add(value);
95 | }
96 | }
97 | } catch (IOException e) {
98 | e.printStackTrace();
99 | }
100 | return devices.toArray(new String[devices.size()]);
101 | }
102 |
103 | public String[] getAllDevicesPath() {
104 | Vector devices = new Vector();
105 | // Parse each driver
106 | Iterator itdriv;
107 | try {
108 | itdriv = getDrivers().iterator();
109 | while(itdriv.hasNext()) {
110 | Driver driver = itdriv.next();
111 | Iterator itdev = driver.getDevices().iterator();
112 | while(itdev.hasNext()) {
113 | String device = itdev.next().getAbsolutePath();
114 | devices.add(device);
115 | }
116 | }
117 | } catch (IOException e) {
118 | e.printStackTrace();
119 | }
120 | return devices.toArray(new String[devices.size()]);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ComAssistant/src/com/bjw/ComAssistant/ComAssistantActivity.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/src/com/bjw/ComAssistant/ComAssistantActivity.java
--------------------------------------------------------------------------------
/ComAssistant/src/com/bjw/ComAssistant/MyFunc.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/src/com/bjw/ComAssistant/MyFunc.java
--------------------------------------------------------------------------------
/ComAssistant/src/com/bjw/ComAssistant/SerialHelper.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/src/com/bjw/ComAssistant/SerialHelper.java
--------------------------------------------------------------------------------
/ComAssistant/src/com/bjw/bean/AssistBean.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/src/com/bjw/bean/AssistBean.java
--------------------------------------------------------------------------------
/ComAssistant/src/com/bjw/bean/ComBean.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComAssistant/src/com/bjw/bean/ComBean.java
--------------------------------------------------------------------------------
/ComTest2/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/ComTest2/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/ComTest2/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | C:\Users\silencefun\AppData\Roaming\Subversion
35 |
36 |
37 |
38 |
39 |
40 | 1.8
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/ComTest2/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ComTest2/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/ComTest2/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/ComTest2/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | defaultConfig {
6 | applicationId "net.test.comtest2"
7 | minSdkVersion 19
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 |
13 | ndk {
14 | moduleName "serial_port"
15 | }
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | sourceSets.main {
25 | jniLibs.srcDir 'src/main/jniLibs'
26 | jni.srcDirs = [] //disable automatic ndk-build call
27 | }
28 |
29 |
30 | }
31 |
32 | dependencies {
33 | implementation fileTree(dir: 'libs', include: ['*.jar'])
34 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
35 | testImplementation 'junit:junit:4.12'
36 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
37 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
38 | }
39 |
--------------------------------------------------------------------------------
/ComTest2/app/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 |
--------------------------------------------------------------------------------
/ComTest2/app/src/androidTest/java/net/test/comtest2/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.test.comtest2;
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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.huansi.comtest2", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/java/android_serialport_api/SerialPort.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package android_serialport_api;
18 |
19 | import java.io.File;
20 | import java.io.FileDescriptor;
21 | import java.io.FileInputStream;
22 | import java.io.FileOutputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 | import java.io.OutputStream;
26 |
27 | import android.util.Log;
28 |
29 | public class SerialPort {
30 |
31 | private static final String TAG = "SerialPort";
32 |
33 | /*
34 | * Do not remove or rename the field mFd: it is used by native method close();
35 | */
36 | private FileDescriptor mFd;
37 | private FileInputStream mFileInputStream;
38 | private FileOutputStream mFileOutputStream;
39 |
40 | public SerialPort(File device, int baudrate, int flags) throws SecurityException, IOException {
41 |
42 |
43 |
44 | mFd = open(device.getAbsolutePath(), baudrate, flags);
45 | if (mFd == null) {
46 | Log.e(TAG, "native open returns null");
47 | throw new IOException();
48 | }
49 | mFileInputStream = new FileInputStream(mFd);
50 | mFileOutputStream = new FileOutputStream(mFd);
51 | }
52 |
53 | // Getters and setters
54 | public InputStream getInputStream() {
55 | return mFileInputStream;
56 | }
57 |
58 | public OutputStream getOutputStream() {
59 | return mFileOutputStream;
60 | }
61 |
62 | // JNI
63 | private native static FileDescriptor open(String path, int baudrate, int flags);
64 | public native void close();
65 | static {
66 | System.loadLibrary("serial_port");
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/java/android_serialport_api/SerialPortFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package android_serialport_api;
18 |
19 | import java.io.File;
20 | import java.io.FileReader;
21 | import java.io.IOException;
22 | import java.io.LineNumberReader;
23 | import java.util.Iterator;
24 | import java.util.Vector;
25 |
26 | import android.util.Log;
27 |
28 | public class SerialPortFinder {
29 |
30 | public class Driver {
31 | public Driver(String name, String root) {
32 | mDriverName = name;
33 | mDeviceRoot = root;
34 | }
35 | private String mDriverName;
36 | private String mDeviceRoot;
37 | Vector mDevices = null;
38 | public Vector getDevices() {
39 | if (mDevices == null) {
40 | mDevices = new Vector();
41 | File dev = new File("/dev");
42 | File[] files = dev.listFiles();
43 | int i;
44 | for (i=0; i mDrivers = null;
61 |
62 | Vector getDrivers() throws IOException {
63 | if (mDrivers == null) {
64 | mDrivers = new Vector();
65 | LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
66 | String l;
67 | while((l = r.readLine()) != null) {
68 | // Issue 3:
69 | // Since driver name may contain spaces, we do not extract driver name with split()
70 | String drivername = l.substring(0, 0x15).trim();
71 | String[] w = l.split(" +");
72 | if ((w.length >= 5) && (w[w.length-1].equals("serial"))) {
73 | Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length-4]);
74 | mDrivers.add(new Driver(drivername, w[w.length-4]));
75 | }
76 | }
77 | r.close();
78 | }
79 | return mDrivers;
80 | }
81 |
82 | public String[] getAllDevices() {
83 | Vector devices = new Vector();
84 | // Parse each driver
85 | Iterator itdriv;
86 | try {
87 | itdriv = getDrivers().iterator();
88 | while(itdriv.hasNext()) {
89 | Driver driver = itdriv.next();
90 | Iterator itdev = driver.getDevices().iterator();
91 | while(itdev.hasNext()) {
92 | String device = itdev.next().getName();
93 | String value = String.format("%s (%s)", device, driver.getName());
94 | devices.add(value);
95 | }
96 | }
97 | } catch (IOException e) {
98 | e.printStackTrace();
99 | }
100 | return devices.toArray(new String[devices.size()]);
101 | }
102 |
103 | public String[] getAllDevicesPath() {
104 | Vector devices = new Vector();
105 | // Parse each driver
106 | Iterator itdriv;
107 | try {
108 | itdriv = getDrivers().iterator();
109 | while(itdriv.hasNext()) {
110 | Driver driver = itdriv.next();
111 | Iterator itdev = driver.getDevices().iterator();
112 | while(itdev.hasNext()) {
113 | String device = itdev.next().getAbsolutePath();
114 | devices.add(device);
115 | }
116 | }
117 | } catch (IOException e) {
118 | e.printStackTrace();
119 | }
120 | return devices.toArray(new String[devices.size()]);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/java/net/test/comtest2/MyFunc.java:
--------------------------------------------------------------------------------
1 | package net.test.comtest2;
2 |
3 | /**
4 | * @author benjaminwan
5 | *����ת������
6 | */
7 | public class MyFunc {
8 | //-------------------------------------------------------
9 | // �ж�������ż����λ���㣬���һλ��1��Ϊ������Ϊ0��ż��
10 | static public int isOdd(int num)
11 | {
12 | return num & 0x1;
13 | }
14 | //-------------------------------------------------------
15 | static public int HexToInt(String inHex)//Hex�ַ���תint
16 | {
17 | return Integer.parseInt(inHex, 16);
18 | }
19 | //-------------------------------------------------------
20 | static public byte HexToByte(String inHex)//Hex�ַ���תbyte
21 | {
22 | return (byte)Integer.parseInt(inHex,16);
23 | }
24 | //-------------------------------------------------------
25 | static public String Byte2Hex(Byte inByte)//1�ֽ�ת2��Hex�ַ�
26 | {
27 | return String.format("%02x", inByte).toUpperCase();
28 | }
29 | //-------------------------------------------------------
30 | static public String ByteArrToHex(byte[] inBytArr)//�ֽ�����תתhex�ַ���
31 | {
32 | StringBuilder strBuilder=new StringBuilder();
33 | int j=inBytArr.length;
34 | for (int i = 0; i < j; i++)
35 | {
36 | strBuilder.append(Byte2Hex(inBytArr[i]));
37 | strBuilder.append(" ");
38 | }
39 | return strBuilder.toString();
40 | }
41 | //-------------------------------------------------------
42 | static public String ByteArrToHex(byte[] inBytArr,int offset,int byteCount)//�ֽ�����תתhex�ַ�������ѡ����
43 | {
44 | StringBuilder strBuilder=new StringBuilder();
45 | int j=byteCount;
46 | for (int i = offset; i < j; i++)
47 | {
48 | strBuilder.append(Byte2Hex(inBytArr[i]));
49 | }
50 | return strBuilder.toString();
51 | }
52 | //-------------------------------------------------------
53 | //תhex�ַ���ת�ֽ�����
54 | static public byte[] HexToByteArr(String inHex)//hex�ַ���ת�ֽ�����
55 | {
56 | int hexlen = inHex.length();
57 | byte[] result;
58 | if (isOdd(hexlen)==1)
59 | {//����
60 | hexlen++;
61 | result = new byte[(hexlen/2)];
62 | inHex="0"+inHex;
63 | }else {//ż��
64 | result = new byte[(hexlen/2)];
65 | }
66 | int j=0;
67 | for (int i = 0; i < hexlen; i+=2)
68 | {
69 | result[j]=HexToByte(inHex.substring(i,i+2));
70 | j++;
71 | }
72 | return result;
73 | }
74 | }
--------------------------------------------------------------------------------
/ComTest2/app/src/main/java/net/test/comtest2/been/AssistBean.java:
--------------------------------------------------------------------------------
1 | package net.test.comtest2.been;
2 |
3 | import java.io.Serializable;
4 |
5 |
6 | public class AssistBean implements Serializable{
7 | private static final long serialVersionUID = -5620661009186692227L;
8 | private boolean isTxt=true;
9 | private String SendTxtA="COMA",SendTxtB="COMB",SendTxtC="COMC",SendTxtD="COMD";
10 | private String SendHexA="AA",SendHexB="BB",SendHexC="CC",SendHexD="DD";
11 | public String sTimeA="500";
12 | public String sTimeB="500";
13 | public String sTimeC="500";
14 | public String sTimeD="500";
15 | public boolean isTxt()
16 | {
17 | return isTxt;
18 | }
19 | public void setTxtMode(boolean isTxt)
20 | {
21 | this.isTxt = isTxt;
22 | }
23 |
24 | public String getSendA()
25 | {
26 | if (isTxt)
27 | {
28 | return SendTxtA;
29 | } else
30 | {
31 | return SendHexA;
32 | }
33 | }
34 | public String getSendB()
35 | {
36 | if (isTxt)
37 | {
38 | return SendTxtB;
39 | } else
40 | {
41 | return SendHexB;
42 | }
43 | }
44 | public String getSendC()
45 | {
46 | if (isTxt)
47 | {
48 | return SendTxtC;
49 | } else
50 | {
51 | return SendHexC;
52 | }
53 | }
54 | public String getSendD()
55 | {
56 | if (isTxt)
57 | {
58 | return SendTxtD;
59 | } else
60 | {
61 | return SendHexD;
62 | }
63 | }
64 |
65 | public void setSendA(String sendA)
66 | {
67 | if (isTxt)
68 | {
69 | SendTxtA = sendA;
70 | } else
71 | {
72 | SendHexA = sendA;
73 | }
74 | }
75 |
76 | public void setSendB(String sendB)
77 | {
78 | if (isTxt)
79 | {
80 | SendTxtB = sendB;
81 | } else
82 | {
83 | SendHexB = sendB;
84 | }
85 | }
86 |
87 | public void setSendC(String sendC)
88 | {
89 | if (isTxt)
90 | {
91 | SendTxtC = sendC;
92 | } else
93 | {
94 | SendHexC = sendC;
95 | }
96 | }
97 |
98 | public void setSendD(String sendD)
99 | {
100 | if (isTxt)
101 | {
102 | SendTxtD = sendD;
103 | } else
104 | {
105 | SendHexD = sendD;
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/ComTest2/app/src/main/java/net/test/comtest2/been/ComBean.java:
--------------------------------------------------------------------------------
1 | package net.test.comtest2.been;
2 |
3 | import java.text.SimpleDateFormat;
4 |
5 | /**
6 | * Created by silencefun on 2018/1/20.
7 | */
8 |
9 | public class ComBean {
10 |
11 | public byte[] bRec=null;
12 | public String sRecTime="";
13 | public String sComPort="";
14 | public ComBean(String sPort,byte[] buffer,int size){
15 | sComPort=sPort;
16 | bRec=new byte[size];
17 | for (int i = 0; i < size; i++)
18 | {
19 | bRec[i]=buffer[i];
20 | }
21 | SimpleDateFormat sDateFormat = new SimpleDateFormat("hh:mm:ss");
22 | sRecTime = sDateFormat.format(new java.util.Date());
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/jni/android_serialport_api_SerialPort.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class android_serialport_api_SerialPort */
4 |
5 | #ifndef _Included_android_serialport_api_SerialPort
6 | #define _Included_android_serialport_api_SerialPort
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: android_serialport_api_SerialPort
12 | * Method: open
13 | * Signature: (Ljava/lang/String;II)Ljava/io/FileDescriptor;
14 | */
15 | JNIEXPORT jobject JNICALL Java_android_1serialport_1api_SerialPort_open
16 | (JNIEnv *, jclass, jstring, jint, jint);
17 |
18 | /*
19 | * Class: android_serialport_api_SerialPort
20 | * Method: close
21 | * Signature: ()V
22 | */
23 | JNIEXPORT void JNICALL Java_android_1serialport_1api_SerialPort_close
24 | (JNIEnv *, jobject);
25 |
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 | #endif
30 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/jniLibs/armeabi-v7a/libserial_port.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest2/app/src/main/jniLibs/armeabi-v7a/libserial_port.so
--------------------------------------------------------------------------------
/ComTest2/app/src/main/jniLibs/armeabi/libserial_port.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest2/app/src/main/jniLibs/armeabi/libserial_port.so
--------------------------------------------------------------------------------
/ComTest2/app/src/main/jniLibs/x86/libserial_port.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest2/app/src/main/jniLibs/x86/libserial_port.so
--------------------------------------------------------------------------------
/ComTest2/app/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest2/app/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/ComTest2/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/res/values/baudrates.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - 50
6 | - 75
7 | - 110
8 | - 134
9 | - 150
10 | - 200
11 | - 300
12 | - 600
13 | - 1200
14 | - 1800
15 | - 2400
16 | - 4800
17 | - 9600
18 | - 19200
19 | - 38400
20 | - 57600
21 | - 115200
22 | - 230400
23 | - 460800
24 | - 500000
25 | - 576000
26 | - 921600
27 | - 1000000
28 | - 1152000
29 | - 1500000
30 | - 2000000
31 | - 2500000
32 | - 3000000
33 | - 3500000
34 | - 4000000
35 |
36 |
37 | - 50
38 | - 75
39 | - 110
40 | - 134
41 | - 150
42 | - 200
43 | - 300
44 | - 600
45 | - 1200
46 | - 1800
47 | - 2400
48 | - 4800
49 | - 9600
50 | - 19200
51 | - 38400
52 | - 57600
53 | - 115200
54 | - 230400
55 | - 460800
56 | - 500000
57 | - 576000
58 | - 921600
59 | - 1000000
60 | - 1152000
61 | - 1500000
62 | - 2000000
63 | - 2500000
64 | - 3000000
65 | - 3500000
66 | - 4000000
67 |
68 |
69 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hello World, ComAssistantActivity!
5 | ComAssistant
6 |
7 |
--------------------------------------------------------------------------------
/ComTest2/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ComTest2/app/src/test/java/net/test/comtest2/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.test.comtest2;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/ComTest2/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.0'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/ComTest2/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 | android.useDeprecatedNdk=true
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/ComTest2/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest2/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/ComTest2/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jan 20 10:09:24 CST 2018
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-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/ComTest2/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/ComTest2/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/ComTest2/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/ComTest_SetN81/ComTest.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | add_library( # Sets the name of the library.
14 | native-lib
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).
20 | src/main/cpp/native-lib.c)
21 |
22 | # Searches for a specified prebuilt library and stores the path as a
23 | # variable. Because CMake includes system libraries in the search path by
24 | # default, you only need to specify the name of the public NDK library
25 | # you want to add. CMake verifies that the library exists before
26 | # completing its build.
27 |
28 | find_library( # Sets the name of the path variable.
29 | log-lib
30 |
31 | # Specifies the name of the NDK library that
32 | # you want CMake to locate.
33 | log )
34 |
35 | # Specifies libraries CMake should link to your target library. You
36 | # can link multiple libraries, such as libraries you define in this
37 | # build script, prebuilt third-party libraries, or system libraries.
38 |
39 | target_link_libraries( # Specifies the target library.
40 | native-lib
41 |
42 | # Links the target library to the log library
43 | # included in the NDK.
44 | ${log-lib} )
--------------------------------------------------------------------------------
/ComTest_SetN81/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | defaultConfig {
6 | applicationId "com.silencefun.comtest"
7 | minSdkVersion 19
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | externalNativeBuild {
13 | cmake {
14 | cppFlags ""
15 | }
16 | }
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | externalNativeBuild {
25 | cmake {
26 | path "CMakeLists.txt"
27 | }
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation fileTree(dir: 'libs', include: ['*.jar'])
33 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
34 | testImplementation 'junit:junit:4.12'
35 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
36 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
37 | }
38 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/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 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/androidTest/java/com/silencefun/comtest/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest;
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() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.silencefun.comtest", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/java/com/silencefun/comtest/MyFunc.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest;
2 |
3 | /**
4 | * @author benjaminwan
5 | *����ת������
6 | */
7 | public class MyFunc {
8 | //-------------------------------------------------------
9 | // �ж�������ż����λ���㣬���һλ��1��Ϊ������Ϊ0��ż��
10 | static public int isOdd(int num)
11 | {
12 | return num & 0x1;
13 | }
14 | //-------------------------------------------------------
15 | static public int HexToInt(String inHex)//Hex�ַ���תint
16 | {
17 | return Integer.parseInt(inHex, 16);
18 | }
19 | //-------------------------------------------------------
20 | static public byte HexToByte(String inHex)//Hex�ַ���תbyte
21 | {
22 | return (byte)Integer.parseInt(inHex,16);
23 | }
24 | //-------------------------------------------------------
25 | static public String Byte2Hex(Byte inByte)//1�ֽ�ת2��Hex�ַ�
26 | {
27 | return String.format("%02x", inByte).toUpperCase();
28 | }
29 | //-------------------------------------------------------
30 | static public String ByteArrToHex(byte[] inBytArr)//�ֽ�����תתhex�ַ���
31 | {
32 | StringBuilder strBuilder=new StringBuilder();
33 | int j=inBytArr.length;
34 | for (int i = 0; i < j; i++)
35 | {
36 | strBuilder.append(Byte2Hex(inBytArr[i]));
37 | strBuilder.append(" ");
38 | }
39 | return strBuilder.toString();
40 | }
41 | //-------------------------------------------------------
42 | static public String ByteArrToHex(byte[] inBytArr,int offset,int byteCount)//�ֽ�����תתhex�ַ�������ѡ����
43 | {
44 | StringBuilder strBuilder=new StringBuilder();
45 | int j=byteCount;
46 | for (int i = offset; i < j; i++)
47 | {
48 | strBuilder.append(Byte2Hex(inBytArr[i]));
49 | }
50 | return strBuilder.toString();
51 | }
52 | //-------------------------------------------------------
53 | //תhex�ַ���ת�ֽ�����
54 | static public byte[] HexToByteArr(String inHex)//hex�ַ���ת�ֽ�����
55 | {
56 | int hexlen = inHex.length();
57 | byte[] result;
58 | if (isOdd(hexlen)==1)
59 | {//����
60 | hexlen++;
61 | result = new byte[(hexlen/2)];
62 | inHex="0"+inHex;
63 | }else {//ż��
64 | result = new byte[(hexlen/2)];
65 | }
66 | int j=0;
67 | for (int i = 0; i < hexlen; i+=2)
68 | {
69 | result[j]=HexToByte(inHex.substring(i,i+2));
70 | j++;
71 | }
72 | return result;
73 | }
74 | }
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/java/com/silencefun/comtest/been/AssistBean.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest.been;
2 |
3 | import java.io.Serializable;
4 |
5 |
6 | public class AssistBean implements Serializable{
7 | private static final long serialVersionUID = -5620661009186692227L;
8 | private boolean isTxt=true;
9 | private String SendTxtA="COMA",SendTxtB="COMB",SendTxtC="COMC",SendTxtD="COMD";
10 | private String SendHexA="AA",SendHexB="BB",SendHexC="CC",SendHexD="DD";
11 | public String sTimeA="500";
12 | public String sTimeB="500";
13 | public String sTimeC="500";
14 | public String sTimeD="500";
15 | public boolean isTxt()
16 | {
17 | return isTxt;
18 | }
19 | public void setTxtMode(boolean isTxt)
20 | {
21 | this.isTxt = isTxt;
22 | }
23 |
24 | public String getSendA()
25 | {
26 | if (isTxt)
27 | {
28 | return SendTxtA;
29 | } else
30 | {
31 | return SendHexA;
32 | }
33 | }
34 | public String getSendB()
35 | {
36 | if (isTxt)
37 | {
38 | return SendTxtB;
39 | } else
40 | {
41 | return SendHexB;
42 | }
43 | }
44 | public String getSendC()
45 | {
46 | if (isTxt)
47 | {
48 | return SendTxtC;
49 | } else
50 | {
51 | return SendHexC;
52 | }
53 | }
54 | public String getSendD()
55 | {
56 | if (isTxt)
57 | {
58 | return SendTxtD;
59 | } else
60 | {
61 | return SendHexD;
62 | }
63 | }
64 |
65 | public void setSendA(String sendA)
66 | {
67 | if (isTxt)
68 | {
69 | SendTxtA = sendA;
70 | } else
71 | {
72 | SendHexA = sendA;
73 | }
74 | }
75 |
76 | public void setSendB(String sendB)
77 | {
78 | if (isTxt)
79 | {
80 | SendTxtB = sendB;
81 | } else
82 | {
83 | SendHexB = sendB;
84 | }
85 | }
86 |
87 | public void setSendC(String sendC)
88 | {
89 | if (isTxt)
90 | {
91 | SendTxtC = sendC;
92 | } else
93 | {
94 | SendHexC = sendC;
95 | }
96 | }
97 |
98 | public void setSendD(String sendD)
99 | {
100 | if (isTxt)
101 | {
102 | SendTxtD = sendD;
103 | } else
104 | {
105 | SendHexD = sendD;
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/java/com/silencefun/comtest/been/ComBean.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest.been;
2 |
3 | import java.text.SimpleDateFormat;
4 |
5 | /**
6 | * Created by silencefun on 2018/1/20.
7 | */
8 |
9 | public class ComBean {
10 |
11 | public byte[] bRec=null;
12 | public String sRecTime="";
13 | public String sComPort="";
14 | public ComBean(String sPort,byte[] buffer,int size){
15 | sComPort=sPort;
16 | bRec=new byte[size];
17 | for (int i = 0; i < size; i++)
18 | {
19 | bRec[i]=buffer[i];
20 | }
21 | SimpleDateFormat sDateFormat = new SimpleDateFormat("hh:mm:ss");
22 | sRecTime = sDateFormat.format(new java.util.Date());
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/java/com/silencefun/comtest/serialport/SerialPort.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.silencefun.comtest.serialport;
18 |
19 | import java.io.File;
20 | import java.io.FileDescriptor;
21 | import java.io.FileInputStream;
22 | import java.io.FileOutputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 | import java.io.OutputStream;
26 |
27 | import android.util.Log;
28 |
29 | public class SerialPort {
30 |
31 | private static final String TAG = "SerialPort";
32 |
33 | /*
34 | * Do not remove or rename the field mFd: it is used by native method close();
35 | */
36 | private FileDescriptor mFd;
37 | private FileInputStream mFileInputStream;
38 | private FileOutputStream mFileOutputStream;
39 |
40 | public SerialPort(File device, int baudrate, int dataBits, int stopBits, char parity) throws SecurityException, IOException {
41 |
42 |
43 | // mFd = open(device.getAbsolutePath(), baudrate, flags);
44 |
45 | mFd = open(device.getAbsolutePath(), baudrate,dataBits,stopBits,parity);
46 | if (mFd == null) {
47 | Log.e(TAG, "native open returns null");
48 | throw new IOException();
49 | }
50 | mFileInputStream = new FileInputStream(mFd);
51 | mFileOutputStream = new FileOutputStream(mFd);
52 | }
53 | public SerialPort(File device, int baudrate, int flags) throws SecurityException, IOException {
54 |
55 |
56 | // mFd = open(device.getAbsolutePath(), baudrate, flags);
57 |
58 | mFd = open(device.getAbsolutePath(), baudrate,8,2,'E');
59 | if (mFd == null) {
60 | Log.e(TAG, "native open returns null");
61 | throw new IOException();
62 | }
63 | mFileInputStream = new FileInputStream(mFd);
64 | mFileOutputStream = new FileOutputStream(mFd);
65 | }
66 | // Getters and setters
67 | public InputStream getInputStream() {
68 | return mFileInputStream;
69 | }
70 |
71 | public OutputStream getOutputStream() {
72 | return mFileOutputStream;
73 | }
74 |
75 | // JNI
76 | private native static FileDescriptor open(String path, int baudrate, int flags);
77 |
78 | // 调用JNI中 打开方法的声明
79 |
80 | /**
81 | * @param dataBits 类型 int数据位 取值 位7或8
82 | * @param parity char校验类型 取值N ,E, O,,S
83 | * @param stopBits 类型 int 停止位 取值1 或者 2
84 | * @return
85 | */
86 | private native static FileDescriptor open(String path, int baudrate, int dataBits, int stopBits, char parity);
87 |
88 | public native void close();
89 |
90 | static {
91 | System.loadLibrary("native-lib");
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/java/com/silencefun/comtest/serialport/SerialPortFinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2009 Cedric Priscal
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.silencefun.comtest.serialport;
18 |
19 | import java.io.File;
20 | import java.io.FileReader;
21 | import java.io.IOException;
22 | import java.io.LineNumberReader;
23 | import java.util.Iterator;
24 | import java.util.Vector;
25 |
26 | import android.util.Log;
27 |
28 | public class SerialPortFinder {
29 |
30 | public class Driver {
31 | public Driver(String name, String root) {
32 | mDriverName = name;
33 | mDeviceRoot = root;
34 | }
35 | private String mDriverName;
36 | private String mDeviceRoot;
37 | Vector mDevices = null;
38 | public Vector getDevices() {
39 | if (mDevices == null) {
40 | mDevices = new Vector();
41 | File dev = new File("/dev");
42 | File[] files = dev.listFiles();
43 | int i;
44 | for (i=0; i mDrivers = null;
61 |
62 | Vector getDrivers() throws IOException {
63 | if (mDrivers == null) {
64 | mDrivers = new Vector();
65 | LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
66 | String l;
67 | while((l = r.readLine()) != null) {
68 | // Issue 3:
69 | // Since driver name may contain spaces, we do not extract driver name with split()
70 | String drivername = l.substring(0, 0x15).trim();
71 | String[] w = l.split(" +");
72 | if ((w.length >= 5) && (w[w.length-1].equals("serial"))) {
73 | Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length-4]);
74 | mDrivers.add(new Driver(drivername, w[w.length-4]));
75 | }
76 | }
77 | r.close();
78 | }
79 | return mDrivers;
80 | }
81 |
82 | public String[] getAllDevices() {
83 | Vector devices = new Vector();
84 | // Parse each driver
85 | Iterator itdriv;
86 | try {
87 | itdriv = getDrivers().iterator();
88 | while(itdriv.hasNext()) {
89 | Driver driver = itdriv.next();
90 | Iterator itdev = driver.getDevices().iterator();
91 | while(itdev.hasNext()) {
92 | String device = itdev.next().getName();
93 | String value = String.format("%s (%s)", device, driver.getName());
94 | devices.add(value);
95 | }
96 | }
97 | } catch (IOException e) {
98 | e.printStackTrace();
99 | }
100 | return devices.toArray(new String[devices.size()]);
101 | }
102 |
103 | public String[] getAllDevicesPath() {
104 | Vector devices = new Vector();
105 | // Parse each driver
106 | Iterator itdriv;
107 | try {
108 | itdriv = getDrivers().iterator();
109 | while(itdriv.hasNext()) {
110 | Driver driver = itdriv.next();
111 | Iterator itdev = driver.getDevices().iterator();
112 | while(itdev.hasNext()) {
113 | String device = itdev.next().getAbsolutePath();
114 | devices.add(device);
115 | }
116 | }
117 | } catch (IOException e) {
118 | e.printStackTrace();
119 | }
120 | return devices.toArray(new String[devices.size()]);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/values/baudrates.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - 50
6 | - 75
7 | - 110
8 | - 134
9 | - 150
10 | - 200
11 | - 300
12 | - 600
13 | - 1200
14 | - 1800
15 | - 2400
16 | - 4800
17 | - 9600
18 | - 19200
19 | - 38400
20 | - 57600
21 | - 115200
22 | - 230400
23 | - 460800
24 | - 500000
25 | - 576000
26 | - 921600
27 | - 1000000
28 | - 1152000
29 | - 1500000
30 | - 2000000
31 | - 2500000
32 | - 3000000
33 | - 3500000
34 | - 4000000
35 |
36 |
37 | - 50
38 | - 75
39 | - 110
40 | - 134
41 | - 150
42 | - 200
43 | - 300
44 | - 600
45 | - 1200
46 | - 1800
47 | - 2400
48 | - 4800
49 | - 9600
50 | - 19200
51 | - 38400
52 | - 57600
53 | - 115200
54 | - 230400
55 | - 460800
56 | - 500000
57 | - 576000
58 | - 921600
59 | - 1000000
60 | - 1152000
61 | - 1500000
62 | - 2000000
63 | - 2500000
64 | - 3000000
65 | - 3500000
66 | - 4000000
67 |
68 |
69 | - N
70 | - O
71 | - E
72 |
73 |
74 |
75 | - 8
76 | - 7
77 |
78 |
79 | - 1
80 | - 2
81 |
82 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hello World, ComAssistantActivity!
5 | ComAssistant
6 |
7 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ComTest_SetN81/app/src/test/java/com/silencefun/comtest/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.silencefun.comtest;
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() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/ComTest_SetN81/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.0.0'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/ComTest_SetN81/build/android-profile/profile-2018-03-13-16-54-24-831.rawproto:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/build/android-profile/profile-2018-03-13-16-54-24-831.rawproto
--------------------------------------------------------------------------------
/ComTest_SetN81/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/ComTest_SetN81/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silencefun/ComTest/62867e6c0f729671b819443328f3acfbf3b2785f/ComTest_SetN81/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/ComTest_SetN81/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 05 15:00:23 CST 2018
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-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/ComTest_SetN81/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/ComTest_SetN81/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Mon Mar 05 15:00:23 CST 2018
11 | ndk.dir=F\:\\sdk\\ndk-bundle
12 | sdk.dir=F\:\\sdk
13 |
--------------------------------------------------------------------------------
/ComTest_SetN81/readme.md:
--------------------------------------------------------------------------------
1 | Android 串口调试工具 可以设定 N-8-1 奇偶校验 数据位 停止位
2 |
--------------------------------------------------------------------------------
/ComTest_SetN81/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ComTest
2 | Android 串口通信 调试工具 源码
3 | 包含了5个项目
4 | ComAssistant 是Eclipse 的项目
5 | ComTest2 是Android Studio 项目
6 | 这两个项目是直接 使用jni调用编译好的so文件
7 |
8 | AndroidStuido_3.0_COMTEST 是 Android Studio 3.0 使用 Cmake方式 完成串口调试工具 的实现
9 |
10 | ComTest_SetN81 是 增加 设定 N-8-1 (数据位停止位校验方式 Android Studio 3.0 使用 Cmake方式)的Demo 实现
11 |
12 | 附自己学习这个硬件串口通讯的一些记录,都在简书:
13 |
14 | Android 串口通信开发笔记01 https://www.jianshu.com/p/25abd940b1dd
15 |
16 | Android 串口通信笔记2 调试工具分析 工具类实现分析、项目实现 https://www.jianshu.com/p/d3d65230ecdb
17 |
18 | Android 串口通信开发笔记3:CMake 方式实现和 多对多的实现逻辑 https://www.jianshu.com/p/6a6c47a3b01b
19 |
20 | Android 串口开发 支持N-8-1(数据位停止位校验方式) 设定 https://www.jianshu.com/p/0868e90303be
21 |
22 | 2019年4月7日 12:12:15 更新
23 | Android Studio 新版的cmake可能是C++语法,在.cpp文件中 出现
24 | 类似 operator to 'Jnienv' instead of a pointer
25 | 查看了
26 | https://stackoverflow.com/questions/47504229/android-jni-cmake-member-reference-type-jnienv-aka-jnienv-is-not-a-point
27 | 解释,
28 |
29 | 并不怎么了解C与C++的差异,
30 | 解决办法为把扩展名.cpp改成.c
31 | 同样还有 在Cmakelist 中也要改成.c
32 |
33 | 其下目录有Eclipse 项目源码和Android Studio 源码 以及自己使用本机debug 密钥打包的 Android调试工具和 PC 端调试工具(一年多看了下几百个人转存和下载,都不能点个赞吗->_>),
34 | 百度云链接: https://pan.baidu.com/s/1nw37xu5 密码: qscc
35 |
--------------------------------------------------------------------------------