Im a hobiest in all that is microcontrolers, pcs, carpcs........ ok i star last year in pic basic pro (microcontroler language) made nice things on that.
Now im to put this vb to work with a gps usb receiver to get: lat, long, speed, n of sats,... but can do it. Can you vb masters help me?
'Reads GPS
Public Sub ReadGPSInfo(ByVal sData As String, Optional CommaSys As Boolean = True)
Static Ltry As Double 'Last Time we tried to reconnect GPS
Static Buff As String 'Buffer of Data
Dim Nb As Long 'Number of Bytes
Dim b() As Byte 'Array of Bytes
Dim DT() As String 'GPS Fields
On Error Resume Next
'If nothing to do
If sData = "" Then
Exit Sub
Else
'<<<<<<<<<<< ADD BY MSCAR >>>>>>>>>>>>>>>
'GPSLog sData ' log to a file
'>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<
'Process Line of Data
If Left(sData, 1) = "$" Then
DT = Split(sData, ",")
'Save latest messages to Log in case somebody wants it later
'NMEAMSGs.Remove DT(0)
'NMEAMSGs.Add sData, DT(0)
Select Case DT(0)
Case "$GPRMC"
'Get Lat, Long, Speed and Heading
GPS.Lat = CDbl(Left(DT(3), InStr(1, DT(3), ".") - 1))
GPS.Lon = CDbl(Left(DT(5), InStr(1, DT(5), ".") - 1))
If CommaSys Then
'Prepare for Conversions
If CommaSys Then DT(3) = Replace(DT(3), ".", ",")
If CommaSys Then DT(5) = Replace(DT(5), ".", ",")
If CommaSys Then DT(7) = Replace(DT(7), ".", ",")
If CommaSys Then DT(8) = Replace(DT(8), ".", ",")
'Get Lat/Long
GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ",") - 2)) / 60#)
GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ",") + -2)) / 60#)
Else
GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ".") - 2)) / 60#)
GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ".") + -2)) / 60#)
End If
If DT(4) = "S" Then GPS.Lat = -GPS.Lat
If DT(6) = "W" Then GPS.Lon = -GPS.Lon
GPS.Speed = CDbl(DT(7))
If GPS.Speed > 3 Then GPS.Hdg = CInt(DT(8))
'If set time from GPS then
'If GPSTime And GPS.Valid Then
' 'Check for Inverted Date format (stupid GPSs in US date format -- nonstandard)
' DT(0) = "": DT(0) = UseVars("gpsusadate")
' If LCase(DT(0)) = "true" Then DT(9) = Mid(DT(9), 3, 2) + Left(DT(9), 2) + Mid(DT(9), 5)
'
' 'If time OR date is wrong, set it correctly from GPS
' If Format(DateAdd("h", TimeZone, Now), "HHMM") <> Left(DT(1), 4) Or Format(DateAdd("h", TimeZone, Now), "DDMMYY") <> DT(9) Then
' DT(1) = Format(DateAdd("h", -TimeZone, Mid(DT(9), 3, 2) + "/" + Left(DT(9), 2) + "/" + Mid(DT(9), 5, 2) + " " + Left(DT(1), 2) + ":" + Mid(DT(1), 3, 2) + ":" + Mid(DT(1), 5, 2)), "MM/DD/YY HH:MM:SS")
' Date = Left(DT(1), 8)
' Time = Mid(DT(1), 10)
' End If
'End If
Case "$GPGGA"
'Get Altitude and Sat Count
If CommaSys Then DT(9) = Replace(DT(9), ".", ",")
GPS.Alt = CDbl(DT(9))
GPS.Sats = CInt(DT(7))
GPS.Valid = (Val(DT(6)) > 0)
End Select
End If
End If
End Sub
I want to parch the data and display as a normal gps displays. but is a all mess i think this lines are no good.
GPS.Lat = CDbl(Left(DT(3), InStr(1, DT(3), ".") - 1))
GPS.Lon = CDbl(Left(DT(5), InStr(1, DT(5), ".") - 1))
If CommaSys Then
'Prepare for Conversions
If CommaSys Then DT(3) = Replace(DT(3), ".", ",")
If CommaSys Then DT(5) = Replace(DT(5), ".", ",")GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ",") - 2)) / 60#)
GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ",") + -2)) / 60#)
Else
GPS.Lat = GPS.Lat \ 100# + (CDbl(Mid(DT(3), InStr(1, DT(3), ".") - 2)) / 60#)
GPS.Lon = GPS.Lon \ 100# + (CDbl(Mid(DT(5), InStr(1, DT(5), ".") + -2)) / 60#)
what thas this lines do? please comment them.
Thanks for the help
Edited by Jaan, 02 July 2009 - 07:00 AM.
Please use code tags when you are posting your codes!


Sign In
Create Account

Back to top









