Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Read all the data from a serial port

0.00/5 (No votes)
2 Nov 2009 1  
Read all the data from a serial port (Com1)

Introduction

What the article/code snippet does, why it's useful, the problem it solves etc.

i am trying to real all the data send from a device connected on serial port RS232 on my computer. this is only a part of a large project that i am working on. i want to capture all the data (text) from the device into a richtextbox. and after that to do somenting with the data.

but when i use the code below..... I get nothing. if instead of

//RichTextBox1.Text = SerialPort1.ReadExisting() ' i use

//RichTextBox1.Text = SerialPort1.ReadLine()

then i get only the first line of the data.

if i use hiperterminal the i gel all the data with function capture text. the data looks like this

110326+00000501 21.102+00000000 22.102+09017910 32..10+00000000

110327+00000502 21.102+36190750 22.102+09767930 32..10+00000000

but i get only the first line with my code. can someone help me?

to receive data from device i run a program on device that send data to me.

code

//Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

//SerialPort1.Open()

//RichTextBox1.Text = ""

//RichTextBox1.Text = SerialPort1.ReadExisting()

//SerialPort1.Close()

//End Sub

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here