Re: RS232 Anyone???

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: DraguVaso (pietercoucke_at_hotmail.com)
Date: 09/09/04


Date: Thu, 9 Sep 2004 16:52:32 +0200

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...
> 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...
> > 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
> > :-)
>
>


Quantcast