how to isolate GPS data into pieces?
I have the GPS data received as:
$GPRMC,040302.663,A,3939.7,N,10506.6,W,0.27,358.86,200804,,*1A
I want to isolate the GPS sentence into individual piece so I can display it into a textbox in a form with the following:
GPSTime:
Latitude:
Longitude:
Velocity:
Heading:
First thing is I need to detect the incoming text $GPRMC, if the $GPRMC is valid then use the data,
Who can I do that? I try to use the select case but it does not work.
Can anybody help me out?
Here is my code:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AxMSComm1.PortOpen = True
Button1.Text = "OPENED"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim gpsdata As String
Dim txtFilter As String
gpsdata = AxMSComm1.Input
TextBox1.Text = gpsdata
txtFilter = Mid(gpsdata, 1, 6)
Select Case (txtFilter)
Case "$GPRMC"
TextBox2.Text = Mid(gpsdata, 8, 6) 'GPS Time
TextBox3.Text = Mid(gpsdata, 21, 4) 'Latitude
TextBox4.Text = Mid(gpsdata, 30, 4) 'Longitude
'first, I want to make sure the above 3 boxes
'get the right data.
'More data (other 2 boxes)will be implement later on
'textbox5 - later
'textbox6 - later
End Select
End Sub
End Class
Re: how to isolate GPS data into pieces?
Re: how to isolate GPS data into pieces?
Yes, you can follow c0ding conventions ... if you do not have, talk to wossy. He gibs gud c0d.
BTW - You've just opened pandora's box :D
Re: how to isolate GPS data into pieces?
what is coding convention?
Re: how to isolate GPS data into pieces?
its the way you builld your life architecture. Check the link posted by BushMobile or talk to wossy.
Re: how to isolate GPS data into pieces?
Just split() on commas and select case the first element.
Also, find a good source of info on NMEA sentences like the one you posted.
Re: how to isolate GPS data into pieces?
Quote:
Originally Posted by cxiong
what is coding convention?
I nearly choked on my drink. :lol:
Re: how to isolate GPS data into pieces?
$gprmc,040302.663,a,3939.7,n,10506.6,w,0.27,358.86,200804,,*1a
time is the 2nd field
lat is 4th and 5th
long is 6th and 7th
speed is 8th
heading (from true north) is 9th.
You need to validate the checksum too, otherwise your data will be unreliable. I can't be bothered goin into detail on that because this is the wrong forum.