Solved

Whats the Difference between Readline and readexisting

Posted on 2011-09-02
3
1,958 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

757 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

18 Experts available now in Live!

Get 1:1 Help Now