Solved

Whats the Difference between Readline and readexisting

Posted on 2011-09-02
3
2,141 Views
Last Modified: 2012-08-13
I have setup a com port read property and trying to send a signal from my external device to my PC. When I use the com port readline I cannot see anything over the com port, however when I use the readexisting I can see the data over the com port. Whats the difference?
0
Comment
Question by:cmdolcet
3 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 63 total points
ID: 36476850
ReadExisting gets any data that is lying in the receive buffer.

ReadLine waits until it detects an end of line value in the data. If data has been received but there was no end of line code in the data, Readline returns nothing. This makes it easier to read text line by line, because the system takes care of identifying the end of each line.

If the type of data you receive is not made of  text, ReadLine is useless. It might never trigger, because the com port might never receive end of line values. And if it does (usually values 13 and/or 10), they won't really represent and and of line, they are probably only those values in binary data.
0
 

Author Comment

by:cmdolcet
ID: 36477889
I know my data end of line is a CR would this be the same?
0
 
LVL 63

Assisted Solution

by:Fernando Soto
Fernando Soto earned 62 total points
ID: 36477947
Hi cmdolcet;

The SerialPort.ReadLine Method expects to see a NewLine to mark the end of the string. The new line is a sequence of two characters, \r\n, which represents a Cr and Lf NOT just a CR and is the reason why you are not seeing any response on the line.

Fernando
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question