8000 GitHub - jcanchen/RxSerialPort: 基于Rxjava2.x的串口通信library
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jcanchen/RxSerialPort

 
 

Repository files navigation

RxSerialPort

基于Rxjava2.x的串口通信library

使用方法

打开并监听串口,accept方法会一直保持回调,直到手动关闭串口

    try {
        SerialPortListener.statListen("/dev/ttyS3", 9600, 0)
                .subscribeOn(Schedulers.io())
                .subscribe(new Consumer<byte[]>() {
                    @Override
                    public void accept(byte[] bytes) throws Exception {
                        //todo 实现业务逻辑
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {

                    }
                });
    } catch (Exception e) {
        e.printStackTrace();
    }

发送数据

SerialPortSender.send(serialPortFileName,bytes);

关闭串口

SerialPortListener.stop(serialPortFileName);

About

基于Rxjava2.x的串口通信library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 51.1%
  • C 43.3%
  • Makefile 5.0%
  • Shell 0.6%
0