MSComm and Available Events for OnComm 
Author Message
 MSComm and Available Events for OnComm

Greetings,

The OnComm events available within MSComm do not include the EV_RXCHAR comm
event which triggers when the input buffer determines when a specific
character has arrived.  In my application, I wait for such a character to
indicate the end of a message.  Can MSComm trap this?  If so, how?  If not,
any opinions why not?

Thanks.

Joe



Thu, 19 Apr 2001 03:00:00 GMT  
 MSComm and Available Events for OnComm
Joe,
    In dealing with the MSComm, the best way that I have found to deal with
looking for a character in a string is to use a while loop.  For example, I
am looking for a Chr$(13) on my input string.

Dim GotIt
    GotIt = 1

    While MSComm1.InBufferCount And GotIt
        If MSComm1.Input = Chr$(13) Then
            InData$ = InData$ + MSComm1.Input
            GotIt = 0
        Else
            InData$ = InData$ + MSComm1.Input
        End If
    Wend

GotIt is just a boolean to keep or throw me out of the loop. I use something
similar to this.  If you think that this will work for you, I can get the
actual thing when I go to work.  Hope this helps, if you need anything else

www.geocities.com/SiliconValley/Park/1904.

Tim Reed

Quote:

>Greetings,

>The OnComm events available within MSComm do not include the EV_RXCHAR comm
>event which triggers when the input buffer determines when a specific
>character has arrived.  In my application, I wait for such a character to
>indicate the end of a message.  Can MSComm trap this?  If so, how?  If not,
>any opinions why not?

>Thanks.

>Joe



Fri, 20 Apr 2001 03:00:00 GMT  
 MSComm and Available Events for OnComm
Hi,

MSComm cannot do this.  There are commercial controls that have this
feature, however...

IMO, you should not use it.  Rather, in OnComm you should buffer all
available data, and use Instr to determine if the required character is
present.  The overhead that this represents is actually quite low.  For
example

Private Sub MSComm1_OnComm()
Static Buffer As String
Dim Position As Integer
    If MSComm1.CommEvent = comEVReceive Then
        Buffer = Buffer & MSComm1.Input   'this "double-buffer" is good
        Position = Instr(Buffer, EndCharacter)
        If Position > 0 Then
            Process Buffer, Position     'you write this code
            If Position > Len(Buffer) Then
                Buffer = Mid$(Buffer, Instr(Buffer, Position+ 1)
            Else
                Buffer = ""
            End If
        End If
    End If
End Sub

For more detailed information on this and other serial communications
subjects, you may be interested in my book.  See below for information.

--
Richard Grier
Hard & Software
12962 West Louisiana Avenue
Lakewood, CO  80228
303-986-2179 (voice)
303-986-3143 (fax)
Author of Visual Basic Programmer's Guide to Serial Communications, 2nd
Edition (355 pages).
For information look on my homepage at
http://ourworld/compuserve.com/homepages/richard_grier.
Use the Books link to order.  For faster service contact the publisher at
http://www.mabry.com.



Fri, 20 Apr 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. MSCOMM: ONCOMM event

2. MSComm OnComm Event Not Firing In UserControl

3. MSCOMM OnComm event problems

4. MSComm-OnComm Event

5. No OnComm Evnt w/MSCOMM.VBX

6. msComm, oncomm and API question

7. Please help on ActiveX exe with MsComm OnComm

8. MSComm.OnComm won't fire---need help!

9. Please help on ActiveX exe with MsComm OnComm

10. MsComm32.ocx and the OnComm event

11. OnComm Event screwed or my modem?

12. OnComm Event Question

 

 
Powered by phpBB® Forum Software