From 0038b64fe4c98a2cabfcd55470a5eec5dec3bd72 Mon Sep 17 00:00:00 2001 From: yimiao Date: Wed, 22 Dec 2021 11:59:01 +0800 Subject: [PATCH] =?UTF-8?q?[desc]:=E6=B7=BB=E5=8A=A0=E4=B8=B2=E5=8F=A3?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20[author]:wangyimiao?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/commonlibtest/DemoActivity.java | 8 +- app/src/main/res/layout/activity_main.xml | 12 ++ commonLib/build.gradle | 13 ++ .../com/common/commonlib/CommonApplication.kt | 2 - .../com/common/commonlib/serialport/Cmd.java | 9 ++ .../commonlib/serialport/DataUtils.java | 139 ++++++++++++++++++ .../commonlib/serialport/SerialPortUtil.java | 113 ++++++++++++++ 7 files changed, 293 insertions(+), 3 deletions(-) create mode 100644 commonLib/src/main/java/com/common/commonlib/serialport/Cmd.java create mode 100644 commonLib/src/main/java/com/common/commonlib/serialport/DataUtils.java create mode 100644 commonLib/src/main/java/com/common/commonlib/serialport/SerialPortUtil.java diff --git a/app/src/main/java/com/common/commonlibtest/DemoActivity.java b/app/src/main/java/com/common/commonlibtest/DemoActivity.java index 27d5150..1afb0c6 100644 --- a/app/src/main/java/com/common/commonlibtest/DemoActivity.java +++ b/app/src/main/java/com/common/commonlibtest/DemoActivity.java @@ -14,6 +14,7 @@ import com.common.commonlib.net.callback.RequestNoResultCallBack; import com.common.commonlib.net.callback.RequestResultCallBack; import com.common.commonlib.net.interceptor.RequestHeadInterceptor; import com.common.commonlib.net.interceptor.ResponseHeadInterceptor; +import com.common.commonlib.serialport.SerialPortUtil; import com.common.commonlib.utils.BaseUtils; import com.common.commonlib.utils.FTPUtils; import com.common.commonlib.utils.MMKVUtils; @@ -133,7 +134,12 @@ public class DemoActivity extends AppCompatActivity { binding.mmkv.setOnClickListener(l -> { MMKVUtils.INSTANCE.put("key", 100, "aa"); int value = MMKVUtils.INSTANCE.getInt("key", "bb"); - Toast.makeText(DemoActivity.this, ""+value, Toast.LENGTH_SHORT).show(); + Toast.makeText(DemoActivity.this, "" + value, Toast.LENGTH_SHORT).show(); + }); + + binding.port.setOnClickListener(l -> { + SerialPortUtil serialPortUtil = new SerialPortUtil(); + serialPortUtil.openSerialPort(); }); } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5914f02..e813bf9 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -106,4 +106,16 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.9" /> +