mscomm & CommEvent 
Author Message
 mscomm & CommEvent

I have a Protek 506 meter which sends variable length data ending with
a chr$(13) when queried by sending any character.
I can read the meter if I set the InBufferCount to the number of
characters I KNOW the meter is sending (since I can read the display
and count the characters). This works so I know the meter is sending
data (including the char$(13)).

But the following code works *on occasion* only.

If it decides to work then I can click the startcommandbutton over and
over and it will correctly update the display. But if it doesn't work
(which is most of the time) then only Control Break gets me out of the
loop of the "If MSComm1.CommEvent =2".

Shouldn't this code (good or not) work? Is there another way with
variable length input? What gives? Help. etc.

Rob

Private Sub StartCommandButton_Click()

    Text2.Text = "Starting"
    MSComm1.CommPort = 3
    MSComm1.Settings = "1200,N,7,2"
    MSComm1.PortOpen = True

    MSComm1.InputLen = 0
    MSComm1.RThreshold = 1

    MSComm1.Output = "a"
    x$ = ""
    instring$ = ""
    While x$ <> Chr$(13)
        If MSComm1.CommEvent = 2 Then
            x$ = MSComm1.Input
            instring$ = instring$ + x$
            End If
    Wend

    Text1.Text = instring$
    MSComm1.PortOpen = False
    Text2.Text = "Done"
End Sub



Mon, 17 Aug 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. MSComm.CommEvent

2. MSComm.CommEvent

3. CommEvent howto??

4. CommEvent Usage

5. CommEvent "EOF", can I disable it?

6. mscomm1.commEvent read locks the mouse

7. CommEvent problem

8. MSComm & Winsock

9. MSComm & Loops

10. MSComm & Carrier detect

11. Unicode & mscomm.input

12. MScomm & IRMan

 

 
Powered by phpBB® Forum Software