Read all data from Serial Port (Com1, RS232)

How to read all the data from a serial port

Page 1 of 1

6 Replies - 35137 Views - Last Post: 02 November 2009 - 09:07 AM Rate Topic: -----

#1 opium_21002100  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-January 09

Read all data from Serial Port (Com1, RS232)

Posted 02 November 2009 - 03:36 AM

Hello all!

I am trying to make a program in vb 2005 to real all the data from a device connected on Serial Port (Com 1).
i did this:
Imports System
Imports System.IO.Ports

Public Class Form1
	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		SerialPort1.Open()
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		If SerialPort1.IsOpen Then
			With RichTextBox1
				.AppendText(SerialPort1.ReadLine & vbCrLf)
				.ScrollToCaret()
			End With
		End If
	SerialPort1.Close()
	End Sub

this code only give me the first line of the data that i will receive. If i try read existing nothing hapens. please help me:

the data storage on serial port device is like this:

410001+00000001
110002+00000010 21.102+25166290 22.102+32314650 31..10+00000000
110003+00001001 21.102+00000000 22.102+09988810 31..10+00000000
110004+00001002 21.102+06314750 22.102+09922750 31..10+00000000
110005+00001003 21.102+07009970 22.102+09975390 31..10+00000000

and this is how i want to reciveit.
when i lounch the program i only receive first line "410001+00000001" and after that i get on the device rs232 error
i am ataching all the project here. it is in vb 2005

Attached File(s)


This post has been edited by opium_21002100: 02 November 2009 - 06:12 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Read all data from Serial Port (Com1, RS232)

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,667
  • Joined: 23-August 08

Re: Read all data from Serial Port (Com1, RS232)

Posted 02 November 2009 - 05:58 AM

VB6 != VB2005. That's VB.NET. Moving there.
Was This Post Helpful? 0
  • +
  • -

#3 opium_21002100  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-January 09

Re: Read all data from Serial Port (Com1, RS232)

Post icon  Posted 02 November 2009 - 06:12 AM

Hello all!

I am trying to make a program in vb 2005 to real all the data from a device connected on Serial Port (Com 1).
i did this:
Imports System
Imports System.IO.Ports

Public Class Form1
	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		SerialPort1.Open()
	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		If SerialPort1.IsOpen Then
			With RichTextBox1
				.AppendText(SerialPort1.ReadLine & vbCrLf)
				.ScrollToCaret()
			End With
		End If
	SerialPort1.Close()
	End Sub

this code only give me the first line of the data that i will receive. If i try read existing nothing hapens. please help me:

the data storage on serial port device is like this:

410001+00000001
110002+00000010 21.102+25166290 22.102+32314650 31..10+00000000
110003+00001001 21.102+00000000 22.102+09988810 31..10+00000000
110004+00001002 21.102+06314750 22.102+09922750 31..10+00000000
110005+00001003 21.102+07009970 22.102+09975390 31..10+00000000

and this is how i want to reciveit.
when i lounch the program i only receive first line "410001+00000001" and after that i get on the device rs232 error
i am ataching all the project here. it is in vb 2005

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#4 opium_21002100  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-January 09

Re: Read all data from Serial Port (Com1, RS232)

Posted 02 November 2009 - 06:14 AM

MOVET TO VB NET
Was This Post Helpful? 0
  • +
  • -

#5 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: Read all data from Serial Port (Com1, RS232)

Posted 02 November 2009 - 06:15 AM

Hi,

First of all don't double post...

Now normally you would send a request to the device on your serial port and then it will return something.

(There is most probably a Programmed Chip on the Device that waits for commands, does some work and then returns the result)
Was This Post Helpful? 0
  • +
  • -

#6 opium_21002100  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-January 09

Re: Read all data from Serial Port (Com1, RS232)

Posted 02 November 2009 - 06:18 AM

i try to delete the others topics

the device is Leica TC1610, and i have a program on it that send the data to serial port. and i want to make a program to capute the data something like hyperterminal / capture text command.

This post has been edited by opium_21002100: 02 November 2009 - 06:22 AM

Was This Post Helpful? 0
  • +
  • -

#7 opium_21002100  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 12-January 09

Re: Read all data from Serial Port (Com1, RS232)

Posted 02 November 2009 - 09:07 AM

i tryied and this sample http://www.dreaminco...wtopic37361.htm and i get this:
=====
410001+00000001
w
======

without "===="\

can someone help me?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1