I am working on an app that requires excellent time accuracy. I have an external GPS feeding the system at up to 10Hz, and I need to get the time of each update. It has to be accurate to within 10ms, or else I may end up with two records of the same time number. Well, that is exactly what it happening.
Using Erel's code from the GPS Tutorial, https://www.b4x.com/android/forum/threads/gps-tutorial.6592/#content I added a simple line to observe GPS time (attached as a .zip, too).
I am finding that the internal GPS will ALWAYS get a reading at the even full second, and that the external GPS will ALWAYS read to the 1/10th of a second. Well, after logging this data, I will see four or five entries, all with the last two digits of the GPS time reading 00. This means that the routine is seeing a GPS location change in that time, and it does indeed log the different GPS positions, but the time does not indicate a change for these updates. I know that this is not correct. My question is, how do I get resolution on those last two digits?
BTW, this same thing happens if you try to read DateTime.Now, as well.
Using Erel's code from the GPS Tutorial, https://www.b4x.com/android/forum/threads/gps-tutorial.6592/#content I added a simple line to observe GPS time (attached as a .zip, too).
B4X:
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: GPS
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#End Region
Sub Process_Globals
Dim GPS1 As GPS
End Sub
Sub Globals
Dim lblLon As Label
Dim lblLat As Label
Dim lblElev As Label
Dim lblSpeed As Label
Dim lblTime As Label
Dim lblSatellites As Label
Private lblNMEA As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
GPS1.Initialize("GPS")
End If
Activity.LoadLayout("1")
End Sub
Sub Activity_Resume
If GPS1.GPSEnabled = False Then
ToastMessageShow("Please enable the GPS device.", True)
StartActivity(GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
Else
GPS1.Start(0, 0) 'Listen to GPS with no filters.
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
GPS1.Stop
End Sub
Sub GPS_LocationChanged (Location1 As Location)
lblLat.Text = "Lat = " & Location1.ConvertToMinutes(Location1.Latitude)
lblLon.Text = "Lon = " & Location1.ConvertToMinutes(Location1.Longitude)
lblElev.Text = "Elevation = " & Location1.Altitude
lblSpeed.Text = "Speed = " & Location1.Speed
lblTime.Text = "Time = " & Location1.Time
End Sub
Sub GPS_UserEnabled (Enabled As Boolean)
ToastMessageShow("GPS device enabled = " & Enabled, True)
End Sub
Sub GPS_GpsStatus (Satellites As List)
lblSatellites.Text = "Satellites:" & CRLF
For i = 0 To Satellites.Size - 1
Dim Satellite As GPSSatellite
Satellite = Satellites.Get(i)
lblSatellites.Text = lblSatellites.Text & CRLF & Satellite.Prn & _
" " & Satellite.Snr & " " & Satellite.UsedInFix & " " & Satellite.Azimuth _
& " " & Satellite.Elevation
Next
End Sub
I am finding that the internal GPS will ALWAYS get a reading at the even full second, and that the external GPS will ALWAYS read to the 1/10th of a second. Well, after logging this data, I will see four or five entries, all with the last two digits of the GPS time reading 00. This means that the routine is seeing a GPS location change in that time, and it does indeed log the different GPS positions, but the time does not indicate a change for these updates. I know that this is not correct. My question is, how do I get resolution on those last two digits?
BTW, this same thing happens if you try to read DateTime.Now, as well.