I am developing a application using maptools and BlueTools in order to connect to a GPS using Bluetools and then pass the data on to maptools for use in application.
I have in part based my code on the FindandConnect example found with bluetools as follows
Private Sub ReadCallback(ByVal result As IAsyncResult)
Dim buffer() As Byte
Dim len As Integer
'nmeaparser below is GpsToolsNET.NmeaParser
' result is always a BlueToolsAsyncResult object
Dim blueAsyncResult As BlueToolsAsyncResult = result
' We passed on buffer as custom object, you can pass on any object here. We passed the stream object
Dim stream As ServiceStream = blueAsyncResult.AsyncState
' The buffer used for reading can be found in the result object.
buffer = blueAsyncResult.Buffer
' EndRead() must always be called!
' If stream has been closed due to an error, we'll have an excpetion here
len = stream.EndRead(result)
Dim str As String
Dim enc As New System.Text.ASCIIEncoding
str = enc.GetString(buffer, 0, len)
' Start new async read
stream.BeginRead(m_buffer, 0, m_buffer.Length, New AsyncCallback(AddressOf ReadCallback), m_stream)
Catch ex As ObjectDisposedException
' Thrown if stream has been closed.
The application connectss fine with the GPS , the service is started and data is being received but it the nature of the received data which has me worried.
When I examine the 'str' being passsed to the nmeaparser it doesnt always start at the beginning of the NMEA string which should be a $ etc.Is this observation correct? - does the buffer length need adjusting? ?
It appears to be randomly starting somewhere mid nmea string.
Do I need to correct this?
If so - how do I ensure a proper NMEA string is being sent to the maptools nmea parser consistently.
I'm connecting to the GPS ok and sometimes the application works fine yet other times it struggles.
Whilst trying to debug the application I discovered the above and I am wondering if it could be the source of my problems.