android RS232串口怎样用?

有没有哪位android大神,能够提供一下RS232串口的详细使用设置过程?太难啦,要崩溃啦

就是用android studio写一个app,要用到RS232串口,

与电脑端连接

设置波特率 什么的 进行通信

Google有源码级别的串口通讯https://gitee.com/vince2git/android-serialport-api,你可以参考一下。

具体波特率设置,要保证电脑端和手机端设置的参数一样。

google有自带的串口操作的方法,该方法由jni实现,so的名字为libnative_serialport.so,其中实现了

private native int open(String strTtyName, int nBaud);
private native int close(int nFd);
private native int read(int nFd, byte[] jByBuf, int nOffset, int nBufMaxLen, int tout) ;
private native int write(int nFd, byte[] jByWriteBuf, int nWriteLen );

等四个方法,具体使用与windows串口操作流程一致