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
Receiving data from serial port
Page 1 of 14 Replies - 16379 Views - Last Post: 01 April 2009 - 10:31 AM
Replies To: Receiving data from serial port
#2
Re: Receiving data from serial port
Posted 01 December 2008 - 03:22 AM
Welcome!
Please post your code examples using -
There is a tutorial on the site - Serial Port Communication in VB.Net
Please post your code examples using -
There is a tutorial on the site - Serial Port Communication in VB.Net
#3
Re: Receiving data from serial port
Posted 01 April 2009 - 10:08 AM
n8wxs, on 1 Dec, 2008 - 02:22 AM, said:
Welcome!
Please post your code examples using -
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.
Please post your code examples using -
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
#4
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
#5
Re: Receiving data from serial port
Posted 01 April 2009 - 10:31 AM
badamsmt, 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
...
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
...
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|