In the recent small project, the single-chip computer interrupt priority problem, the serial port sends to the host computer The data sometimes may appear to send the data interrupted interrupts the question.
So, in the upper machine is prone to errors, the original reading method is read () method, repeated changes in the format of sending data is still not improved.
Later said that the host computer to replace the reading mode ReadLine () problem has been resolved, and never miss, the problem may be due to the ReadLine method of its own characteristics bar.
ReadLine will always wait there, knowing that the line feed "\ r \ n" is received, so when the complete data is not received, there will always be waiting for the arrival of the data, not abandon.
Even if the data sending process of the lower computer is interrupted by other interrupts.
ReadLine returns a string, so the receive variable should also be a string variable, then decompose the packet, and the rest of the process is the same.
The ReadLine () method of the "lab note" SerialPort