If there is no valid fix reported by the RMC message, then calculation
of the PPS time stamp is pointless.  This patch simplifies the logic by
returning early in this case.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 ts2phc_nmea_master.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ts2phc_nmea_master.c b/ts2phc_nmea_master.c
index e89c2c7..b8f7014 100644
--- a/ts2phc_nmea_master.c
+++ b/ts2phc_nmea_master.c
@@ -172,6 +172,11 @@ static int ts2phc_nmea_master_getppstime(struct 
ts2phc_master *master,
 
        pthread_mutex_unlock(&m->mutex);
 
+       if (!fix_valid) {
+               pr_debug("nmea: no valid rmc fix");
+               return -1;
+       }
+
        delay_t1 = rmc;
        pr_debug("nmea delay: %" PRId64 " ns",
                 tmv_to_nanoseconds(tmv_sub(delay_t2, delay_t1)));
@@ -200,7 +205,7 @@ static int ts2phc_nmea_master_getppstime(struct 
ts2phc_master *master,
        }
        ts->tv_sec += tai_offset;
 
-       return fix_valid ? lstab_error : -1;
+       return lstab_error;
 }
 
 struct ts2phc_master *ts2phc_nmea_master_create(struct config *cfg, const char 
*dev)
-- 
2.20.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to