The ReadLine () method of the "lab note" SerialPort

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.