Android (Linux) Real-time Monitoring of serial port data, android Real-time Monitoring
Previously, when I was working on the WinCE on-board solution, I had a small tool, TraceMonitor, used to display the debugging information of the application programs on the WinCE system, especially in the real-car debugging, displays the serial data between the CAN box and the host. Because it is necessary to seize the market opportunity, it is often necessary to cooperate with the CAN decoding box manufacturer to debug the automotive terminal software before the new car goes public. TraceMonitor may be useful at this time. When you encounter a problem that you cannot tell which side of the problem is, you can see the data clearly. Sometimes the client's machine encounters an abnormal feature of the original car. You can also directly run the tool to capture serial data in real time and provide it to us to analyze the cause of the problem. However, this tool requires special processing by business applications, which is not universal and implemented at the application layer. It may affect the performance, but it is not as good as it is. Once I debugged RK3188 Android car navigation with GYP, and the car terminal never received the data. The hardware engineer said that the CAN box would certainly be sent, and it had to be around for a long time, at last, we can only connect the USB to the serial port board to the computer to see that there is data, but the frame format is incorrect. If there is a tool on Android that can capture serial data in real time, it will be much easier.
As mentioned in the previous article "use of Android (Linux) line rules", the line rules are used to adjust the Android underlying serial communication framework, unexpectedly, you can easily monitor the data sent and received by the serial port in the driver, and then write an application for display. Just do what you want, and try some gadgets to make it easier for you and others.
The implementation is not complex. First, write a character to drive bonovo_mon, which is used to cache the data sent and received in the line procedure. The ComMon application uses FileInputStream to read and display the data of character devices. For ease of use, it provides functions such as data frame Filtering, hexadecimal display, data storage, and sending and storing data to a specified mailbox, which is much more powerful than TraceMonitor in WinCE, it can monitor all data on the communication serial port, and the Business APP does not need to perform any special processing, and the request cache data is registered with the line procedure only when the character-driven bonovo_mon is opened, therefore, when you do not run ComMon, the system will have almost no impact.
The ComMon interface and main functions are as follows.