Giter VIP home page Giter VIP logo

android-serialport-api's Introduction

Android-SerialPort-API

Gradle 引用

  1. 在根build.gradle中添加
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. 子module添加依赖
dependencies {
        implementation 'com.github.licheedev:Android-SerialPort-API:2.0.0'
}

修改su路径

// su默认路径为 "/system/bin/su"
// 可通过此方法修改
SerialPort.setSuPath("/system/xbin/su");

可选配置数据位、校验位、停止位

实现方式参考

https://juejin.im/post/5c010a19e51d456ac27b40fc

// 默认8N1(8数据位、无校验位、1停止位)
SerialPort serialPort = SerialPort.newBuilder(path, baudrate).build();

// 7E2(7数据位、偶校验、2停止位)
SerialPort serialPort = SerialPort //
    .newBuilder(path, baudrate) // 串口地址地址,波特率
    .parity(2) // 校验位;0:无校验位(NONE,默认);1:奇校验位(ODD);2:偶校验位(EVEN)
    .dataBits(7) // 数据位,默认8;可选值为5~8
    .stopBits(2) // 停止位,默认1;1:1位停止位;2:2位停止位
    .build();

android-serialport-api's People

Contributors

jzwzz avatar licheedev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.