Re: RS232 Anyone???

From: Terry Olsen (tolsen64_at_hotmail.com)
Date: 09/08/04


Date: Wed, 8 Sep 2004 10:49:18 -0600

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



Relevant Pages

  • Re: RS232 Anyone???
    ... I'm gona try to download it and play a bit arround! ... > Public Function IsPortAvailable(ByVal port As String) As Boolean ... > Catch ex As Exception ... > Public Sub ReadComPort(ByVal Sender As Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Bug with W2K3, SP1, Windows Firewall and FTP
    ... add program not add port. ... I'm confuse as well:) between the advanced tab and exception tab. ... port in the Exceptions and checking the FTP Server in the Advanced ... I decided to try adding a port 21 in the firewall exception list just to ...
    (microsoft.public.inetserver.iis.ftp)
  • Problems with dynamic port binding to consume web service
    ... I'm trying to create an application which use a dynamic web port to call ... Uncaught exception has suspended an ... pepLookup, Guid portId, XLANGMessage msg, Segment seg, String opname, String ... IList toPromote, Boolean ignoreRoutingFailure) ...
    (microsoft.public.biztalk.general)
  • Re: Change RDP Port in XP Firewall
    ... > Windows Firewall for the new exception. ... > box, using the new port, from my XP Home box. ... is in fact UNCHECKED in the Windows Firewall Exception ...
    (microsoft.public.windowsxp.work_remotely)
  • Re: Bug with W2K3, SP1, Windows Firewall and FTP
    ... list and exception is allowed (of coz tight to the scope of your exception ... inetinfo.exe without any port restriction..... ... I decided to try adding a port 21 in the firewall exception list just to ... I found this on the inetinfo thingy, but he unchecks the FTP service from ...
    (microsoft.public.inetserver.iis.ftp)