Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Continuous comEvRing event on MSCOMM

Status
Not open for further replies.

ttmac

Technical User
Aug 16, 2002
105
IE
I have connected an Ericsson t28s mobile phone to a USB port. When the USB cable connected, it created a virtual USB to Serial Bridge that has been mapped to COM5.

I have connected to the phone using Hyperterminal and am able to interact with it using AT commands.

The code below is from the MSDN ONCOMM Event for event driven data reception. The only change that I have made is to change the port to COM5.

When I run the code I am getting a continuous comEvRing event.

How can I solve this problem? or can it be solved?

Code:
      Private Sub Form_Load()
         Form1.Caption = "App2"
         With MSComm1
            .CommPort = 5
            .Handshaking = 2 - comRTS
            .RThreshold = 1
            .RTSEnable = True
            .Settings = "9600,n,8,1"
            .SThreshold = 1
            .PortOpen = True
            ' Leave all other settings as default values.
         End With
         Text1.Text = ""
      End Sub

      Private Sub Form_Unload(Cancel As Integer)
         MSComm1.PortOpen = False
      End Sub

      Private Sub MSComm1_OnComm()
         Dim InBuff As String

         Select Case MSComm1.CommEvent
         ' Handle each event or error by placing
         ' code below each case statement.

         ' This template is found in the Example
         ' section of the OnComm event Help topic
         ' in VB Help.

         ' Errors
            Case comEventBreak   ' A Break was received.
            Case comEventCDTO    ' CD (RLSD) Timeout.
            Case comEventCTSTO   ' CTS Timeout.
            Case comEventDSRTO   ' DSR Timeout.
            Case comEventFrame   ' Framing Error.
            Case comEventOverrun ' Data Lost.
            Case comEventRxOver  ' Receive buffer overflow.
            Case comEventRxParity   ' Parity Error.
            Case comEventTxFull  ' Transmit buffer full.
            Case comEventDCB     ' Unexpected error retrieving DCB]

         ' Events
            Case comEvCD   ' Change in the CD line.
            Case comEvCTS  ' Change in the CTS line.
            Case comEvDSR  ' Change in the DSR line.
            Case comEvRing ' Change in the Ring Indicator.
            Case comEvReceive ' Received RThreshold # of chars.
               InBuff = MSComm1.Input
               Call HandleInput(InBuff)
            Case comEvSend ' There are SThreshold number of
                           ' characters in the transmit buffer.
            Case comEvEOF  ' An EOF character was found in the
                           ' input stream.
         End Select

      End Sub

      Sub HandleInput(InBuff As String)
         ' This is where you will process your input. This
         ' includes trapping characters, parsing strings,
         ' separating data fields, etc. For this case, you
         ' are simply going to display the data in the TextBox.
         Text1.SelStart = Len(Text1.Text)
         Text1.SelText = InBuff
      End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top