Serial2 problems in 6.5

Chester Wilson

Member
Licensed User
Here is some code which worked fine under 6.3 and falls over under 6.5. It uses serial2. Has anybody else had this problem?

I trimmed it to a minimum. Under 6.3 it reads the GPS on the serial line at good speed and smoothly. Under 6.5 it does it in fits and starts.

The full programme compiled under 6.5 just gets the error in GPSGetChar, as listed below. Under 6.3 it works fine. (This is on the PDA, an HP iPaq 212a. On the PC it runs without any trouble at all. This is still true after a hard reset on the PDA.)

Any ideas please?

- - - - - - - - - - - - - - - - - - - - - - - - - - -
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

i = Chr(GPS(GPSBufferPointer))
GPSBufferPointer = GPSBufferPointer + 1
If i <> Chr(0) Then ok = True ' Ignore nulls
Loop

Return i

ErrorGetChar:
Msgbox("Error in GPSGetChar") 'This is where it dies in 6.5 -
' not on the cut down version of the programme, but on the full one which
' is rather too big to put up on this forum!
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
GPSBufferLength = ArrayLen(GPS())
'Not always the same as i !
End If

Return GPSBufferLength


GetBufErr:
If Charting = False Then
Msgbox("You have become disconnected from the GPS")
Serial2.PortOpen = False
AppClose
Return 0
End If
End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Sub GPSFlushBuffer
n = 100 ' Just in case!
i = 1000
Do While (i >= 100) AND (n > 0)
i = GPSGetBuffer
n = n - 1
Loop
GPSLinePointer = 0
End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - -

I will be interested in your ideas. It has taken me a couple of days to sort out that this seems to be a 6.5 bug - including the hard reset of the PDA unfortunately!

Chester Wilson.
 

agraham

Expert
Licensed User
I trimmed it to a minimum. Under 6.3 it reads the GPS on the serial line at good speed and smoothly. Under 6.5 it does it in fits and starts.
Is this on the device with an optimised compiled app? Is it the same when run from the device IDE?

The full programme compiled under 6.5 just gets the error in GPSGetChar. Under 6.3 it works fine
Optimised compiled? Can you confirm that the same compiled exe runs differently under 6.3 and 6.5? What is the error message if you remove the ErrorLabel statement?

I cannot explain the differences you note between 6.3 and 6.5. I have done a lot of serial port work under 6.5 developing my SerialEx library, which is an enhanced Serial2 library using the Serial2 code as a base, and my GPSSerial library which behaves virtually identically to the GPSDriver library but for for devices without a built-in GPS. They both use the same underlying .NET serial port class as Serial2 - and in fact make greater demands of it, particularly GPSSerial. I did not find any unexpected behaviour of the serial port while I was developing and testing these so am at loss to explain your problem :confused:
 
Top