An open API service indexing awesome lists of open source software.

https://github.com/lynaisy/rxserialport

基于Rxjava2.x的串口通信library
https://github.com/lynaisy/rxserialport

android rxjava2 serial-ports serialport

Last synced: 5 months ago
JSON representation

基于Rxjava2.x的串口通信library

Awesome Lists containing this project

README

          

# RxSerialPort
基于Rxjava2.x的串口通信library
## 使用方法

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

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

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

发送数据

SerialPortSender.send(serialPortFileName,bytes);

关闭串口

SerialPortListener.stop(serialPortFileName);