ailll / androidserialport Goto Github PK
View Code? Open in Web Editor NEWAndroid Serial Port , 基本的Android 串口通信库
License: Apache License 2.0
Android Serial Port , 基本的Android 串口通信库
License: Apache License 2.0
实在是对android不熟 ,不太会生成so文件
有没有一个API是监听串口断开和连接状态的?
因设备断开后BufferedReader.read会一直阻塞,所以无法用于判断。
有没有更好的方式知道已经断开了?
Process su = Runtime.getRuntime().exec(mSuPath);
String cmd = "chmod 666 " + device.getAbsolutePath() + "\n" + "exit\n";
su.getOutputStream().write(cmd.getBytes());
建议通过标志位决定是否需要进行提权操作
/**
* @param device 串口设备文件
* @param baudrate 波特率,一般是9600
* @param flags 传0就好
* @param parity 奇偶校验,0 None, 1 Odd, 2 Even
* @param dataBits 数据位,5 - 8
* @param stopBit 停止位,1 或 2
*/
public SerialPort(File device, int baudrate, int flags, int parity, int dataBits, int stopBit) throws SecurityException, IOException {}
开发的项目需要配置串口
from SerialPortFinder.java line 95
File dev = new File("/dev");
I always get null as result of dev
my log show:
type=1400 audit(0.0:49408): avc: denied { read } for name="/" dev="tmpfs" ino=4097 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=dir permissive=0
What should I do?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.