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
- Host: GitHub
- URL: https://github.com/lynaisy/rxserialport
- Owner: lynaisy
- Created: 2018-03-01T09:55:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-17T02:46:07.000Z (over 8 years ago)
- Last Synced: 2024-04-07T03:54:51.784Z (about 2 years ago)
- Topics: android, rxjava2, serial-ports, serialport
- Language: Java
- Homepage:
- Size: 133 KB
- Stars: 12
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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);