summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2022-10-26 12:13:59 -0500
committerJason Reiss <jreiss@multitech.com>2022-10-26 12:13:59 -0500
commit25065e728b18fe174dd5f06396276f22ddb04ee2 (patch)
treeee681cc30ac8c1814c218ae9bca359b4734a9553
parent34d28eb28f6931f55a46fdcc6c1b5ba9d5e4cfe4 (diff)
downloadlora_gateway_mtac_full-25065e728b18fe174dd5f06396276f22ddb04ee2.tar.gz
lora_gateway_mtac_full-25065e728b18fe174dd5f06396276f22ddb04ee2.tar.bz2
lora_gateway_mtac_full-25065e728b18fe174dd5f06396276f22ddb04ee2.zip
gps: move cnt_diff check after calculation5.0.20
-rw-r--r--libloragw/src/loragw_gps.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libloragw/src/loragw_gps.c b/libloragw/src/loragw_gps.c
index de0d495..d02e23a 100644
--- a/libloragw/src/loragw_gps.c
+++ b/libloragw/src/loragw_gps.c
@@ -640,6 +640,11 @@ int lgw_gps_sync(struct tref *ref, uint32_t count_us, struct timespec utc, struc
CHECK_NULL(ref);
+ /* calculate the slope */
+
+ cnt_diff = (double)(count_us - ref->count_us) / (double)(TS_CPS); /* uncorrected by xtal_err */
+ utc_diff = (double)(utc.tv_sec - (ref->utc).tv_sec) + (1E-9 * (double)(utc.tv_nsec - (ref->utc).tv_nsec));
+
if (cnt_diff == 0.0 || last_count_us == count_us) {
// no pps change from SX1301, invalidate system reference time
ref->systime = 0;
@@ -649,11 +654,6 @@ int lgw_gps_sync(struct tref *ref, uint32_t count_us, struct timespec utc, struc
last_count_us = count_us;
- /* calculate the slope */
-
- cnt_diff = (double)(count_us - ref->count_us) / (double)(TS_CPS); /* uncorrected by xtal_err */
- utc_diff = (double)(utc.tv_sec - (ref->utc).tv_sec) + (1E-9 * (double)(utc.tv_nsec - (ref->utc).tv_nsec));
-
/* detect aberrant points by measuring if slope limits are exceeded */
if (utc_diff != 0) { // prevent divide by zero
slope = cnt_diff/utc_diff;