# SerialPort **Repository Path**: mapleSeriesX/SerialPort ## Basic Information - **Project Name**: SerialPort - **Description**: Android 串口通信 --从串口接收数据 --发送数据到串口 Demo: --读取IC卡数据 --读取二维码数据 - **Primary Language**: Android - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2020-01-14 - **Last Updated**: 2021-04-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SerialPort #### Introduction Android serial communication --Receive data from the serial port --Send data to the serial port Demo: --Read IC card data --Read QR code data #### Software Architecture Observer mode Use Google's official serial communication interface: SerialPort, get root permissions, open the /dev/ttySxxx file through jni, set the baud rate, construct a FileDescriptor object by reflection, and return to Java. Java constructs a FileInputStream for receiving serial data, and constructs a FileOutputStream for writing serial data to achieve serial communication. Start a read data thread, wait for 50ms (data continuity) after reading the data from the serial port, and distribute the data through the interface. Start a data write thread, push data through the queue, block the queue to get data, and write the data to the serial port.   #### Contributions 1. Fork the warehouse 2. Create a new Feat_xxx branch 3. Submit the code 4. New Pull Request