Hello, I have a program that connects to an electronic
device and communicates via the serial port. Data comes
"real time" from the electronic device and my program reads this
data from the serial port.
My program works fine for a while and then stops reading the data
from the serial port. The time it takes before it stops reading
data is variable. I've been unable to determine any trends. I've
also tested that their is data still being transfered from the
electronic device by using a break out box. The code is rather
short, so I will paste it.
If anyone can see what I'm doing wrong, I would greatly appreciate
it. Thanks a ton!
Code.........
Rem For Polling PS680 in "INLINE Mode" (B8 = On)
Rem Also must set PS680 command = "INLINEHSK DTR"
$CPU 80386
$COM 15000
$ERROR ALL ON
$DEBUG MAP ON
$DEBUG PBDEBUG ON
Rem
Close ':ON ERROR GOTO ERROUTINE
Key OFF: Cls
Rem LOCATE 16,18,1:PRINT "PRESS 'Q' AT ANY TIME TO QUIT DATA COLLECTION"
Y% = 1
I% = 1
Open "COM1:1200,N,8,1" For Random As #2
Open "CALLDATA" For Append As #3
DELAY 3
Rem
Rem ********* BEGIN DATA COLLECTION ***********
Rem
MAIN:
For Z = 1 To 20000
If Loc(2) > 20 Then
I% = 1
Y% = 1
Line Input #2, INPUTRECORD$
Print #3, INPUTRECORD$
Print INPUTRECORD$
ElseIf INSTAT Then
GoSub KEYBOARD
Else
I% = I% + 1
Rem ** 30 SECONDS WITHOUT A call record **
If Y% > 10 Then
GoTo REST
Else
DELAY 3
End If
End If
Y% = Y% + 1
Rem ** 1000 Calls max at one time **
If Y% > 1000 Then
GoTo REST
End If
Next Z
REST:
Close
Cls
LOCATE 16, 21, 1: Print "PRESS ANY KEY TO TERMINATE AUTO-POLLING"
SLEEP 60
Rem 3600 = 1 HOUR ********
Rem
If INSTAT Then
GoTo ENDAUTOPOLL
Else
End If
Close: System
ENDAUTOPOLL:
INK$ = INKEY$
If INK$ = Chr$(81) Then
Open "DUMMY" For Output As #1
Else
Open "DUMMY" For Output As #1
End If
Close: System
KEYBOARD:
INK$ = INKEY$
If INK$ = Chr$(81) Then
Print #2, Chr$(27); Chr$(27); Chr$(27)
Open "DUMMY" For Output As #1
Close: System
Else
End If
Return
ERROUTINE:
If Err = 57 Then Resume Next
ERRMSG$ = "CAN'T RESUME AT " + Str$(Erl) + " ERR CODE = " + Str$(Err)
Print ERRMSG$
Close: End
------------------
device and communicates via the serial port. Data comes
"real time" from the electronic device and my program reads this
data from the serial port.
My program works fine for a while and then stops reading the data
from the serial port. The time it takes before it stops reading
data is variable. I've been unable to determine any trends. I've
also tested that their is data still being transfered from the
electronic device by using a break out box. The code is rather
short, so I will paste it.
If anyone can see what I'm doing wrong, I would greatly appreciate
it. Thanks a ton!
Code.........
Rem For Polling PS680 in "INLINE Mode" (B8 = On)
Rem Also must set PS680 command = "INLINEHSK DTR"
$CPU 80386
$COM 15000
$ERROR ALL ON
$DEBUG MAP ON
$DEBUG PBDEBUG ON
Rem
Close ':ON ERROR GOTO ERROUTINE
Key OFF: Cls
Rem LOCATE 16,18,1:PRINT "PRESS 'Q' AT ANY TIME TO QUIT DATA COLLECTION"
Y% = 1
I% = 1
Open "COM1:1200,N,8,1" For Random As #2
Open "CALLDATA" For Append As #3
DELAY 3
Rem
Rem ********* BEGIN DATA COLLECTION ***********
Rem
MAIN:
For Z = 1 To 20000
If Loc(2) > 20 Then
I% = 1
Y% = 1
Line Input #2, INPUTRECORD$
Print #3, INPUTRECORD$
Print INPUTRECORD$
ElseIf INSTAT Then
GoSub KEYBOARD
Else
I% = I% + 1
Rem ** 30 SECONDS WITHOUT A call record **
If Y% > 10 Then
GoTo REST
Else
DELAY 3
End If
End If
Y% = Y% + 1
Rem ** 1000 Calls max at one time **
If Y% > 1000 Then
GoTo REST
End If
Next Z
REST:
Close
Cls
LOCATE 16, 21, 1: Print "PRESS ANY KEY TO TERMINATE AUTO-POLLING"
SLEEP 60
Rem 3600 = 1 HOUR ********
Rem
If INSTAT Then
GoTo ENDAUTOPOLL
Else
End If
Close: System
ENDAUTOPOLL:
INK$ = INKEY$
If INK$ = Chr$(81) Then
Open "DUMMY" For Output As #1
Else
Open "DUMMY" For Output As #1
End If
Close: System
KEYBOARD:
INK$ = INKEY$
If INK$ = Chr$(81) Then
Print #2, Chr$(27); Chr$(27); Chr$(27)
Open "DUMMY" For Output As #1
Close: System
Else
End If
Return
ERROUTINE:
If Err = 57 Then Resume Next
ERRMSG$ = "CAN'T RESUME AT " + Str$(Erl) + " ERR CODE = " + Str$(Err)
Print ERRMSG$
Close: End
------------------
Comment