MSComm Crashing program, with no error description just closes to Desktop...

Iam communicating with some bowling lane software using a Serial connection ( 9600 baud )

Code for starting communcation
    If frmAccuScore.LaneCom.PortOpen Then frmAccuScore.LaneCom.PortOpen = state
    frmAccuScore.LaneCom.InputLen = 1
    frmAccuScore.LaneCom.InputMode = comInputModeText
    frmAccuScore.LaneCom.CommPort = frmFront.setup_comPort
    Set frmAccuScore.cBuffer = New cCyclicBuffer
    Set frmAccuScore.tBuffer = New cCyclicBuffer
    frmAccuScore.cBuffer.create (100)
    frmAccuScore.tBuffer.create (100)
    If state Then
        frmAccuScore.LaneCom.PortOpen = state
        TermInitialize
        frmAccuScore.timCursor.enabled = True
    End If

Communication can run fine for like an hour but then the program crashes leaving me with nothing but the Desktop

Private Sub LaneCom_OnComm()
    Select Case LaneCom.CommEvent
    Case comEvReceive
        If nnTime.enabled And Not isAdvance Then
            nnTime.enabled = False
        End If
        Dim inp As String
        inp = LaneCom.input
        ReceivingData = True
        Call TermProcessInput(CByte(Asc(inp)))
        DoEvents
    end select
end sub

Does anyone have an idea what is happening or how i can figure out what is going wrong

mSchmidtAsked:
Who is Participating?
 
GrahamSkanRetiredCommented:
Yes. Just reading the buffer, as you do in your posted code, should empty it.

You could try varying the InputLen.

Also most comm. applications require a timer to monitor and pull the program out of stuck situations.
0
 
GrahamSkanRetiredCommented:
No idea what is happening. I suggest that you write a trace log to see what is happening.
Does the program loop (no response but consuming CPU time)?
Do ensure that you aren't supressing errors (e.g. On Error Resume Next)
0
 
mSchmidtAuthor Commented:
No idea what is happening. I suggest that you write a trace log to see what is happening.
I am doing this at the moment and i have also added some code to ensure that the Input buffer is emptied..
It seems that in peak moments the OnComm event will not be fired however data will be put in the Buffer meaning that the code i currently have takes only one byte from the buffer each time the event is fired...
My new code empties the Buffer everytime the oncomm event is fired..

Does the program loop (no response but consuming CPU time)? <-- It doesnt loop
Do ensure that you aren't supressing errors (e.g. On Error Resume Next) <-- Iam not
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.