RS232 Anyone??? | | |
I'm trying to use the RS232 class that was in the Platform SDK (i think).
Has anyone else used this with events successfully? Here's what i've got:
======================
Public WithEvents bbsPort As Rs232 = New Rs232
With bbsPort
.BaudRate = baud
.DataBit = dataBits
.Parity = parity
.Port = comPort
.StopBit = stopBits
Try
.Open()
Catch ex As Exception
StopServerToolStripMenuItem.PerformClick()
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End With
'The port opens okay because if I have another application using the port I
get the exception message "Unable to open COM1"
Public Sub ReadComPort(ByVal Source As Rs232, ByVal DataBuffer() As Byte)
Handles bbsPort.DataReceived
MsgBox("DataReceived")
End Sub
=======================
Two questions I have are: I know I can communicate because I can talk to
the serial device with Hyperterminal. When I try it with my app, the event
is never fired. So I must be doing something wrong. Any help is
desperately needed & appreciated.
Second question: There doesn't seem to be a way to set flow control. Has
anyone added flow control capabilities to this class?
Thanks. | | | | re: RS232 Anyone???
Nevermind....I just found out that VB 2005 supports the serial ports.
Changed my code and all works fine now...
"Terry Olsen" <tolsen64@hotmail.com> wrote in message
news:%23CxG6e5kEHA.3912@TK2MSFTNGP12.phx.gbl...[color=blue]
> I'm trying to use the RS232 class that was in the Platform SDK (i think).
> Has anyone else used this with events successfully? Here's what i've got:
> ======================
> Public WithEvents bbsPort As Rs232 = New Rs232
>
> With bbsPort
> .BaudRate = baud
> .DataBit = dataBits
> .Parity = parity
> .Port = comPort
> .StopBit = stopBits
> Try
> .Open()
> Catch ex As Exception
> StopServerToolStripMenuItem.PerformClick()
> MsgBox(ex.Message, MsgBoxStyle.Critical)
> End Try
> End With
>
> 'The port opens okay because if I have another application using the port
> I get the exception message "Unable to open COM1"
>
> Public Sub ReadComPort(ByVal Source As Rs232, ByVal DataBuffer() As Byte)
> Handles bbsPort.DataReceived
> MsgBox("DataReceived")
> End Sub
> =======================
>
> Two questions I have are: I know I can communicate because I can talk to
> the serial device with Hyperterminal. When I try it with my app, the
> event is never fired. So I must be doing something wrong. Any help is
> desperately needed & appreciated.
>
> Second question: There doesn't seem to be a way to set flow control. Has
> anyone added flow control capabilities to this class?
>
> Thanks.
>
>[/color] | | | | re: RS232 Anyone???
2005 is not released yet, so if your planning this for a production target
you may be leaving yourself with a problem if they take out the support on
the release version.
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Terry Olsen" <tolsen64@hotmail.com> wrote in message
news:uiBBnC7kEHA.3608@TK2MSFTNGP09.phx.gbl...[color=blue]
> Nevermind....I just found out that VB 2005 supports the serial ports.
> Changed my code and all works fine now...
>
>
> "Terry Olsen" <tolsen64@hotmail.com> wrote in message
> news:%23CxG6e5kEHA.3912@TK2MSFTNGP12.phx.gbl...[color=green]
> > I'm trying to use the RS232 class that was in the Platform SDK (i[/color][/color]
think).[color=blue][color=green]
> > Has anyone else used this with events successfully? Here's what i've[/color][/color]
got:[color=blue][color=green]
> > ======================
> > Public WithEvents bbsPort As Rs232 = New Rs232
> >
> > With bbsPort
> > .BaudRate = baud
> > .DataBit = dataBits
> > .Parity = parity
> > .Port = comPort
> > .StopBit = stopBits
> > Try
> > .Open()
> > Catch ex As Exception
> > StopServerToolStripMenuItem.PerformClick()
> > MsgBox(ex.Message, MsgBoxStyle.Critical)
> > End Try
> > End With
> >
> > 'The port opens okay because if I have another application using the[/color][/color]
port[color=blue][color=green]
> > I get the exception message "Unable to open COM1"
> >
> > Public Sub ReadComPort(ByVal Source As Rs232, ByVal DataBuffer() As[/color][/color]
Byte)[color=blue][color=green]
> > Handles bbsPort.DataReceived
> > MsgBox("DataReceived")
> > End Sub
> > =======================
> >
> > Two questions I have are: I know I can communicate because I can talk[/color][/color]
to[color=blue][color=green]
> > the serial device with Hyperterminal. When I try it with my app, the
> > event is never fired. So I must be doing something wrong. Any help is
> > desperately needed & appreciated.
> >
> > Second question: There doesn't seem to be a way to set flow control.[/color][/color]
Has[color=blue][color=green]
> > anyone added flow control capabilities to this class?
> >
> > Thanks.
> >
> >[/color]
>
>[/color] | | | | re: RS232 Anyone???
Hi Terry,
[color=blue]
> 2005 is not released yet, so if your planning this for a production target
> you may be leaving yourself with a problem if they take out the support on
> the release version.
>[/color]
A very good answer to Terry and in general.
:-)
Cor | | | | re: RS232 Anyone???
It's a personal project.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:u5Y%23NI%23kEHA.3984@TK2MSFTNGP14.phx.gbl...[color=blue]
> 2005 is not released yet, so if your planning this for a production target
> you may be leaving yourself with a problem if they take out the support on
> the release version.
>[/color] | | | | re: RS232 Anyone???
The logic stands, however, its obviously your call.
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Terry Olsen" <tolsen64@hotmail.com> wrote in message
news:esH1JzBlEHA.556@tk2msftngp13.phx.gbl...[color=blue]
> It's a personal project.
>
> "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in[/color]
message[color=blue]
> news:u5Y%23NI%23kEHA.3984@TK2MSFTNGP14.phx.gbl...[color=green]
> > 2005 is not released yet, so if your planning this for a production[/color][/color]
target[color=blue][color=green]
> > you may be leaving yourself with a problem if they take out the support[/color][/color]
on[color=blue][color=green]
> > the release version.
> >[/color]
>
>[/color] | | | | re: RS232 Anyone???
Hi Terry,
I'm planning to make anapplication that has to communicate with an SMS
Modem. I kind of drawned in the lots of bad RS232 code I foudn and tested.
I'm also tempted to do it in VS 2005 because I heard it was integrated
there. Does your code works fine? And did you use the VS 2005 Beta 1 or the
VS 2005 Express Edition? Is it possible to make a working Service with it
that uses RS232?
If you woudl be so kind to paste your code that would be very helpfulltoo
:-)
Thanks a lot in advance,
Pieter
"Terry Olsen" <tolsen64@hotmail.com> wrote in message
news:uiBBnC7kEHA.3608@TK2MSFTNGP09.phx.gbl...[color=blue]
> Nevermind....I just found out that VB 2005 supports the serial ports.
> Changed my code and all works fine now...
>
>
> "Terry Olsen" <tolsen64@hotmail.com> wrote in message
> news:%23CxG6e5kEHA.3912@TK2MSFTNGP12.phx.gbl...[color=green]
> > I'm trying to use the RS232 class that was in the Platform SDK (i[/color][/color]
think).[color=blue][color=green]
> > Has anyone else used this with events successfully? Here's what i've[/color][/color]
got:[color=blue][color=green]
> > ======================
> > Public WithEvents bbsPort As Rs232 = New Rs232
> >
> > With bbsPort
> > .BaudRate = baud
> > .DataBit = dataBits
> > .Parity = parity
> > .Port = comPort
> > .StopBit = stopBits
> > Try
> > .Open()
> > Catch ex As Exception
> > StopServerToolStripMenuItem.PerformClick()
> > MsgBox(ex.Message, MsgBoxStyle.Critical)
> > End Try
> > End With
> >
> > 'The port opens okay because if I have another application using the[/color][/color]
port[color=blue][color=green]
> > I get the exception message "Unable to open COM1"
> >
> > Public Sub ReadComPort(ByVal Source As Rs232, ByVal DataBuffer() As[/color][/color]
Byte)[color=blue][color=green]
> > Handles bbsPort.DataReceived
> > MsgBox("DataReceived")
> > End Sub
> > =======================
> >
> > Two questions I have are: I know I can communicate because I can talk[/color][/color]
to[color=blue][color=green]
> > the serial device with Hyperterminal. When I try it with my app, the
> > event is never fired. So I must be doing something wrong. Any help is
> > desperately needed & appreciated.
> >
> > Second question: There doesn't seem to be a way to set flow control.[/color][/color]
Has[color=blue][color=green]
> > anyone added flow control capabilities to this class?
> >
> > Thanks.
> >
> >[/color]
>
>[/color] | | | | re: RS232 Anyone???
I'm using the Express version Beta 1 downloadable from Microsoft.
I don't have too much in the way of functionality yet as my time to work on
it is very limited. But it's pretty straight forward. When you install the
Express version, you also get the MSDN library that goes with it..so it's
all in the docs. But here are some snippets of what I have so far...it
receives input from the COM port using a ReceivedEvent and throws up a
messagebox with the received character.
Imports System.IO.Ports
Public WithEvents bbsPort As SerialPort = New SerialPort
For Each sp As String In My.Computer.Ports.SerialPortNames
If IsPortAvailable(sp) Then cboComPort.Items.Add(sp)
Next
Public Function IsPortAvailable(ByVal port As String) As Boolean
' 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.
Try
bbsPort.PortName = port
bbsPort.Open()
' If it makes it to here, then the Comm Port is available.
bbsPort.Close()
Return True
Catch
' If it gets here, then the attempt to open the Comm Port
' was unsuccessful.
Return False
End Try
End Function
With bbsPort
.BaudRate = baud
.DataBits = dataBits
.Parity = parity
.PortName = comPort
.StopBits = stopBits
.Handshake = flowControl
.ReceivedBytesThreshold = 1
Try
.Open()
Catch ex As Exception
StopServerToolStripMenuItem.PerformClick()
MsgBox(ex.Message, MsgBoxStyle.Critical, "Telnet2BBS")
End Try
End With
Public Sub ReadComPort(ByVal Sender As Object, ByVal e As
System.IO.Ports.SerialReceivedEventArgs) Handles bbsPort.ReceivedEvent
Try
MsgBox(Chr(bbsPort.ReadByte))
Catch ex As Exception
Exit Sub
End Try
End Sub
"DraguVaso" <pietercoucke@hotmail.com> wrote in message
news:%235qe0dYlEHA.2020@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi Terry,
>
> I'm planning to make anapplication that has to communicate with an SMS
> Modem. I kind of drawned in the lots of bad RS232 code I foudn and tested.
>
> I'm also tempted to do it in VS 2005 because I heard it was integrated
> there. Does your code works fine? And did you use the VS 2005 Beta 1 or
> the
> VS 2005 Express Edition? Is it possible to make a working Service with it
> that uses RS232?
>
> If you woudl be so kind to paste your code that would be very helpfulltoo
> :-)[/color] | | | | re: RS232 Anyone???
Thanks! I'm gona try to download it and play a bit arround!
:-)
"Terry Olsen" <tolsen64@hotmail.com> wrote in message
news:OfpNFPclEHA.3876@TK2MSFTNGP15.phx.gbl...[color=blue]
> I'm using the Express version Beta 1 downloadable from Microsoft.
>
> I don't have too much in the way of functionality yet as my time to work[/color]
on[color=blue]
> it is very limited. But it's pretty straight forward. When you install[/color]
the[color=blue]
> Express version, you also get the MSDN library that goes with it..so it's
> all in the docs. But here are some snippets of what I have so far...it
> receives input from the COM port using a ReceivedEvent and throws up a
> messagebox with the received character.
>
>
> Imports System.IO.Ports
> Public WithEvents bbsPort As SerialPort = New SerialPort
>
> For Each sp As String In My.Computer.Ports.SerialPortNames
> If IsPortAvailable(sp) Then cboComPort.Items.Add(sp)
> Next
>
> Public Function IsPortAvailable(ByVal port As String) As Boolean
> ' 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.
> Try
> bbsPort.PortName = port
> bbsPort.Open()
> ' If it makes it to here, then the Comm Port is available.
> bbsPort.Close()
> Return True
> Catch
> ' If it gets here, then the attempt to open the Comm Port
> ' was unsuccessful.
> Return False
> End Try
> End Function
>
> With bbsPort
> .BaudRate = baud
> .DataBits = dataBits
> .Parity = parity
> .PortName = comPort
> .StopBits = stopBits
> .Handshake = flowControl
> .ReceivedBytesThreshold = 1
> Try
> .Open()
> Catch ex As Exception
> StopServerToolStripMenuItem.PerformClick()
> MsgBox(ex.Message, MsgBoxStyle.Critical, "Telnet2BBS")
> End Try
> End With
>
> Public Sub ReadComPort(ByVal Sender As Object, ByVal e As
> System.IO.Ports.SerialReceivedEventArgs) Handles bbsPort.ReceivedEvent
> Try
> MsgBox(Chr(bbsPort.ReadByte))
> Catch ex As Exception
> Exit Sub
> End Try
> End Sub
>
> "DraguVaso" <pietercoucke@hotmail.com> wrote in message
> news:%235qe0dYlEHA.2020@TK2MSFTNGP09.phx.gbl...[color=green]
> > Hi Terry,
> >
> > I'm planning to make anapplication that has to communicate with an SMS
> > Modem. I kind of drawned in the lots of bad RS232 code I foudn and[/color][/color]
tested.[color=blue][color=green]
> >
> > I'm also tempted to do it in VS 2005 because I heard it was integrated
> > there. Does your code works fine? And did you use the VS 2005 Beta 1 or
> > the
> > VS 2005 Express Edition? Is it possible to make a working Service with[/color][/color]
it[color=blue][color=green]
> > that uses RS232?
> >
> > If you woudl be so kind to paste your code that would be very[/color][/color]
helpfulltoo[color=blue][color=green]
> > :-)[/color]
>
>[/color] |  | Similar Visual Basic .NET bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,414 network members.
|