bugGPSD - Bugs: bug #54831, JSON timestamp jumps backwards due...

 
 

bug #54831: JSON timestamp jumps backwards due to small negative values (<1ms) in UBX_NAV_PVT's 'nano' field

Submitted by:  None
Submitted on:  Fri 12 Oct 2018 12:47:04 PM UTC  
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 04 Dec 2018 08:37:46 PM UTC, comment #1:

Fixed, right?

Gary E. Miller <garyemiller>
Project Administrator
Fri 12 Oct 2018 12:47:04 PM UTC, original submission:

'gpspipe -w' output:
{"class":"TPV","device":"/dev/ttymxc4","mode":3,"time":"2018-10-09T07:21:42.600Z","ept":0.005,"lat":-43.942400300,"lon":108.588128400,"alt":27.281,"epx":0.621,"epy":0.621,"epv":1.419,"track":0.0000,"speed":0.016,"climb":-0.145,"eps":-0.01,"epc":14.19}
{"class":"TPV","device":"/dev/ttymxc4","mode":3,"time":"2018-10-09T07:21:42.800Z","ept":0.005,"lat":-43.942400300,"lon":108.588128400,"alt":27.252,"epx":0.621,"epy":0.621,"epv":1.419,"track":0.0000,"speed":0.025,"climb":-0.145,"eps":-0.01,"epc":14.19}
{"class":"TPV","device":"/dev/ttymxc4","mode":3,"time":"2018-10-09T07:21:42.000Z","ept":0.005,"lat":-43.942400300,"lon":108.588128300,"alt":27.220,"epx":0.621,"epy":0.621,"epv":1.418,"track":0.0000,"speed":0.016,"climb":-0.160,"eps":-0.01,"epc":14.18}
{"class":"TPV","device":"/dev/ttymxc4","mode":3,"time":"2018-10-09T07:21:43.200Z","ept":0.005,"lat":-43.942400300,"lon":108.588128100,"alt":27.190,"epx":0.621,"epy":0.621,"epv":1.418,"track":0.0000,"speed":0.032,"climb":-0.150,"eps":0.02,"epc":14.18}
{"class":"TPV","device":"/dev/ttymxc4","mode":3,"time":"2018-10-09T07:21:43.400Z","ept":0.005,"lat":-43.942400200,"lon":108.588128100,"alt":27.162,"epx":0.621,"epy":0.621,"epv":1.418,"track":0.0000,"speed":0.017,"climb":-0.140,"eps":0.01,"epc":14.18}

The 42.800 -> 42.000 -> 43.200 time warp is caused by the UBX_NAV_PVT message's 'nano' values being within 1ms of the second boundary.
Everything's fine until the TPV timestamp is printed with unix_to_iso8601() where the fractional part is greater than 999ms so the snprintf(.."%.3f") results in '1.000' ... and then the '1' is discarded.

Minimal patch below addresses this case:

diff --git a/gpsutils.c b/gpsutils.c
index 3070ca5..ce9b739 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -513,6 +513,17 @@ char *unix_to_iso8601(timestamp_t fixtime,

fractional = modf(fixtime, &integral);
intfixtime = (time_t) integral;
+
+ /*
+ * Do not mess casually with the number of decimal digits in the
+ * format! Most GPSes report over serial links at 0.01s or 0.001s
+ * precision.
+ */
+ (void)snprintf(fractstr, sizeof(fractstr), "%.3f", fractional);
+ /* Rounding up detection (i.e 1 > fractional > 0.999) */
+ if (fractstr[0] == '1')
+ intfixtime++;
+
#ifdef HAVE_GMTIME_R
(void)gmtime_r(&intfixtime, &when);
#else
@@ -521,12 +532,6 @@ char *unix_to_iso8601(timestamp_t fixtime,
#endif

(void)strftime(timestr, sizeof(timestr), "%Y-%m-%dT%H:%M:%S", &when);
- /*
- * Do not mess casually with the number of decimal digits in the
- * format! Most GPSes report over serial links at 0.01s or 0.001s
- * precision.
- */
- (void)snprintf(fractstr, sizeof(fractstr), "%.3f", fractional);
/* add fractional part, ignore leading 0; "0.2" -> ".2" */
(void)snprintf(isotime, len, "%s%sZ",timestr, strchr(fractstr,'.'));
return isotime;

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by garyemiller (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    No changes have been made to this item

    Back to the top


    Powered by Savane 3.4