More on GPS / Serial 2 problem
Thanks, Andrew. There are a couple of problems. One I'll put in a second post.
(1) the .dll required seems to exist on the PDA, but not on the PC, which adds to the interest of debugging!
(2) I am using serial2, having not known about your serialEx. There were no troubles under 6.3 of basic4ppc, but thr programme crashes under 6.5. I have added debugging bits to the code, and it appears that something is getting written over that shouldn't. Going back to 6.3 lets it work ok. As always, it could always be something in my programme writing where it shouldn't, but here is the code including the debugging bits in case you have any ideas:
(It appears that something to do with the pointer for the array GPS has gone awry . . .)
Sub GPSGetChar
'Returns the next character from the GPS, or chr(0) if none available
ErrorLabel(ErrorGetChar)
ok = False
Do While ok = False
If GPSBufferPointer >= GPSBufferLength Then
i = GPSGetBuffer
If i <= 0 Then Return Chr(0)
End If
If GPSBufferLength > 0 Then
j = ArrayLen(GPS()) & " " & GPSBufferPointer
If GPSBufferPointer = 0 Then
j = j & "*" 'DEBUG Gets to here
i = GPS(0)
Else
j = j & "^" 'DEBUG not to here
i = gps(gpsbufferpointer)
End If
j = j & "!" 'DEBUG nor to here.
i = Chr(i)
j = j & "!"
i = Chr(GPS(GPSBufferPointer)) '(original line)
GPSBufferPointer = GPSBufferPointer + 1
Else
i = Chr(0)
End If
If i <> Chr(0) Then ok = True ' Ignore nulls
Loop
Return i
ErrorGetChar:
Msgbox("Error in GPSGetChar (" & j & ")")
Serial2.PortOpen = False
AppClose
End Sub
Sub GPSGetBuffer
'Gets a new bufferful from the GPS
' Returns the character count in the buffer (0 if none available)
GPSBufferPointer = 0
GPSBufferLength = 0
ErrorLabel(GetBufErr)
i = Serial2.InBufferCount
If i > 0 Then
GPS() = Serial2.InputArray
i = gps(0) 'DEBUG This does not cause a crash.
GPSBufferLength = ArrayLen(GPS()) 'Not always the same as i !
Else
GPSBufferLength = 0
End If
Return GPSBufferLength
GetBufErr:
If Charting = False Then
Msgbox("You have become disconnected from the GPS")
Serial2.PortOpen = False
AppClose
End If
Return 0
End Sub