# RxSerialPort **Repository Path**: zmwcodediy/RxSerialPort ## Basic Information - **Project Name**: RxSerialPort - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-07-01 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## 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);