TSCH: keep track of max/min observed drift and log it periodically

This commit is contained in:
Simon Duquennoy 2018-05-25 12:33:30 -07:00
parent 347ccab765
commit 3d88ba35dd
3 changed files with 11 additions and 1 deletions

View File

@ -109,7 +109,9 @@ timesync_learn_drift_ticks(uint32_t time_delta_asn, int32_t drift_ticks)
TSCH_LOG_ADD(tsch_log_message,
snprintf(log->message, sizeof(log->message),
"drift %ld", tsch_adaptive_timesync_get_drift_ppm()));
"drift %ld (min/max delta seen: %"PRId32"/%"PRId32")",
tsch_adaptive_timesync_get_drift_ppm(),
min_drift_seen, max_drift_seen));
}
/*---------------------------------------------------------------------------*/
/* Either reset or update the neighbor's drift */
@ -136,6 +138,8 @@ tsch_timesync_update(struct tsch_neighbor *n, uint16_t time_delta_asn, int32_t d
compensated_ticks += drift_correction;
}
}
min_drift_seen = MIN(drift_correction, min_drift_seen);
max_drift_seen = MAX(drift_correction, max_drift_seen);
}
/*---------------------------------------------------------------------------*/
/* Error-accumulation free compensation algorithm */

View File

@ -160,6 +160,8 @@ static struct ctimer keepalive_timer;
unsigned long tx_count;
unsigned long rx_count;
unsigned long sync_count;
int32_t min_drift_seen;
int32_t max_drift_seen;
/* TSCH processes and protothreads */
PT_THREAD(tsch_scan(struct pt *pt));
@ -648,6 +650,8 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
tx_count = 0;
rx_count = 0;
sync_count = 0;
min_drift_seen = 0;
max_drift_seen = 0;
/* Start sending keep-alives now that tsch_is_associated is set */
tsch_schedule_keepalive();

View File

@ -175,6 +175,8 @@ extern rtimer_clock_t tsch_timing[tsch_ts_elements_count];
extern unsigned long tx_count;
extern unsigned long rx_count;
extern unsigned long sync_count;
extern int32_t min_drift_seen;
extern int32_t max_drift_seen;
/* TSCH processes */
PROCESS_NAME(tsch_process);