Solved

Whats the Difference between Readline and readexisting

Posted on 2011-09-02
3
2,018 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 62

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now