Click to See Complete Forum and Search --> : Serial Communication
spiritgate
January 27th, 2009, 11:06 PM
Hi guys, I want to know how to use serial communication in VB. I saw a serial port icon in the component section. I want to know the api of the serial port. Hope anyone can teach me or any websites that teach this thx!
dglienna
January 27th, 2009, 11:39 PM
Download the 101 Samples for your version of VB.Net
' This function attempts to open the passed Comm Port. If it is
' available, it returns True, else it returns False. To determine
' availability a Try-Catch block is used.
Private Function IsPortAvailable(ByVal ComPort As Integer) As Boolean
Try
CommPort.Open(ComPort, 115200, 8, RS232.DataParity.Parity_None, _
RS232.DataStopBit.StopBit_1, 4096)
' If it makes it to here, then the Comm Port is available.
CommPort.Close()
Return True
Catch
' If it gets here, then the attempt to open the Comm Port
' was unsuccessful.
Return False
End Try
End Function
spiritgate
January 27th, 2009, 11:59 PM
what does it mean by download 101 sample? where to download?
spiritgate
January 28th, 2009, 12:05 AM
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.PortName = "COM1"
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = IO.Ports.StopBits.One
SerialPort1.Open()
SerialPort1.RtsEnable = True
i = SerialPort1.CtsHolding
Label1.Text = "Successfully Connected!"
If (SerialPort1.RtsEnable) Then
SerialPort1.Write("1")
Label3.Text = i
SerialPort1.WriteLine("1")
End If
Label2.Text = SerialPort1.WriteBufferSize
'Label2.Text = SerialPort1.ReadByte
SerialPort1.Close()
This is what i wrote. Because the VB studio component have serial port, so ?I use it to do the serial communication. Like this correct to open the serial and write to the serial thanks!
DaBoonDockSaint
January 28th, 2009, 11:54 AM
Sure glad you asked this question I been goofing around with doing stuff like this too my question is how do you control the stream using a buffer?
dglienna
January 28th, 2009, 12:05 PM
what does it mean by download 101 sample? where to download?
Sample programs to help people understand how VS works.
http://msdn.microsoft.com/en-us/bb330936.aspx
Oblio
January 28th, 2009, 05:25 PM
see my (dbasnett) here http://www.vbforums.com/showthread.php?t=530790
dglienna
January 28th, 2009, 07:17 PM
Do you have the 2008 version?
spiritgate
January 28th, 2009, 11:52 PM
ya I have 2008 version, oblio, I tried the program but it still doesnt work
dglienna
January 29th, 2009, 01:19 AM
Well, download the samples, and TRY some of them. Take our word for it that every one works.
Step thru it line by line (pressing F10) to see HOW it works.
The code that I posted was from the samples, and works.
It checks the COM ports, and sends AT to each to test for modem.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.