All learning summary: GreyZhang/g_serial: Some serial learning notes which may be usefull in embedded system debugging. (github.com)
Before, the reading and display of serial port information has been realized with the help of pyserial.In fact, adding a log file record is also very simple.If you just add the most primitive log information, you can record it directly in a file.Here, I implemented a simple attempt.
In the design, I did not try to write all after opening the file once, but used the method of continuously opening the file and appending.Because, when using other serial port tools, I also have some attempts to view the log file. I think it is also very good if the log file can be continuously refreshed and new data can be seen continuously.
In this way, while recording continuously, we can view the recorded content with the help of editors such as VS Code that load and refresh quickly.
I used Arduino's serial port monitoring tools a lot before, on the one hand, because the serial port monitoring tools I have come into contact with may not be many, on the other hand, Arduino's serial port monitoring tools have completely satisfied my personal needs.need.That way, I have no other drive to find and use more tools.The important thing about my use of Arduino's serial monitoring tool is that it supports the display of timestamp information, so it is very helpful for me to understand the timing interval of the actions executed by the software.If, the log file has such information, then this is also very good.
I have also used putty, an open source software, for a long time.It is also used to record the log, which is more convenient.But what I am not very satisfied with using this tool is that it is inconvenient to add timestamp information in the log file.I read the instructions on the Internet, explaining that such a function is not easy to do.However, another solution is given on the website.I didn't study why it's not good to do it, maybe in some scenarios, such implementation is challenging.But for me, the amount of data I need is not large, maybe not very fast, and it is very useful to simply read the system time as a reference.
For this reason, the above design is made.
Of course, this is just a casual handwriting, and the design is not very good.The main problem is that there is a lot of repetitive code. In fact, the processing of timestamps can be isolated into a special function.However, simple testing or temporary use, in the case of such a simple code, is also possible.Here, I not only added a write, but also added a print process.In fact, it is very simple. I want to see the effect of the Arduino serial port monitoring tool in the process of printing.
In this way, the effect of printing and displaying is available.
Looking at the log information again, it basically meets my expectations.If such a function is integrated into my development workflow later, it will still be of some help to my work efficiency and quality.