(When it comes to serial programming, we have to mention JNI and the file descriptor class in Java API: filedescriptor. Next, I will analyze and explain some knowledge points and implementation source code of JNI, filedescriptor and serial port respectively. Here we mainly refer to open source projects.
? ? Basic knowledge of serial port programming: for serial port programming, we only need to make a series of settings for the serial port, and then open the serial port. We can refer to the source code of serial port debugging assistant to learn these operations. In Java, if you want to realize the read-write function of the serial port, you only need to operate the file device class: filedescriptor, and the driver completes other things. Of course, if you want to know, you have to look at the driver code. We do not intend to explain the driver here, but simply describe the implementation of the application layer.
Android serial programming principle and Implementation (with source code) docx)