?
Solved

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

Posted on 2006-04-12
4
Medium Priority
?
201 Views
Last Modified: 2010-05-01
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

0
Comment
Question by:mSchmidt
  • 2
3 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16444508
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
 

Author Comment

by:mSchmidt
ID: 16444537
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
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 16446799
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question