4 Replies - 19145 Views - Last Post: 01 April 2009 - 10:31 AM Rate Topic: -----

#1 raajeshjt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-November 08

Receiving data from serial port

Posted 30 November 2008 - 11:13 PM

Hi i was not getting o/p properly when i tried to receive data from serial port using the following code. Can u help me?





Public Class form1


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If SerialPort1.IsOpen Then

Dim data As String = SerialPort1.ReadExisting()
Try
TextBox1.Text = data
Catch
'do nothing
End Try
End If
End Sub

Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
SerialPort1.Close()
SerialPort1.PortName = "COM3"
SerialPort1.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "COM3")
End Try

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub
End Class

Is This A Good Question/Topic? 0
  • +

Replies To: Receiving data from serial port

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Receiving data from serial port

Posted 01 December 2008 - 03:22 AM

Welcome!

Please post your code examples using - :code:

There is a tutorial on the site - Serial Port Communication in VB.Net
Was This Post Helpful? 0
  • +
  • -

#3 badamsmt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-April 09

Re: Receiving data from serial port

Posted 01 April 2009 - 10:08 AM

View Postn8wxs, on 1 Dec, 2008 - 02:22 AM, said:

Welcome!

Please post your code examples using - :code:

There is a tutorial on the site - Serial Port Communication in VB.Net



The zip file associated with the sample code link seems to be damaged or invalid.

This post has been edited by badamsmt: 01 April 2009 - 10:10 AM

Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Receiving data from serial port

Posted 01 April 2009 - 10:30 AM

@badamsmt What program are you using to open this file? I just downloaded and opened it just fine
Was This Post Helpful? 0
  • +
  • -

#5 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Receiving data from serial port

Posted 01 April 2009 - 10:31 AM

View Postbadamsmt, on 1 Apr, 2009 - 09:08 AM, said:

The zip file associated with the sample code link seems to be damaged or invalid.

I just extracted this from the download I just did:

Quote

Imports System
Imports System.Text
Imports System.Drawing
Imports System.IO.Ports
Imports System.Windows.Forms
'*****************************************************************************************
' LICENSE INFORMATION
'*****************************************************************************************
' PCCom.SerialCommunication Version 1.0.0.0
' Class file for managing serial port communication
'
' Copyright © 2007
' Richard L. McCutchen
' Email: richard@psychocoder.net
' Created: 20OCT07
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
'*****************************************************************************************


Public Class CommManager
#Region "Manager Enums"
''' <summary>
''' enumeration to hold our transmission types
''' </summary>
Public Enum TransmissionType
Text
Hex
End Enum

''' <summary>
''' enumeration to hold our message types
''' </summary>
Public Enum MessageType
Incoming
Outgoing
Normal
Warning
[Error]
End Enum
#End Region
...

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1