From 400e93873555693262fdcf6c2d1542e88c5e630e Mon Sep 17 00:00:00 2001 From: Jakob Eriksson Date: Thu, 6 Aug 2020 10:54:30 -0500 Subject: [PATCH 1/5] added timestamp facility --- lib/tlog/play.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/tlog/play.c b/lib/tlog/play.c index 0d2ac34b..6532b619 100644 --- a/lib/tlog/play.c +++ b/lib/tlog/play.c @@ -708,6 +708,7 @@ tlog_play_init(struct tlog_errs **perrs, return grc; } +bool tlog_print_timestamp = false; /** * Read playback input, interpreting user input. * @@ -892,6 +893,9 @@ tlog_play_run_read_input(struct tlog_errs **perrs, bool *pquit) case '\x7f': tlog_play_speed = (struct timespec){1, 0}; break; + case 'T': + tlog_print_timestamp = !tlog_print_timestamp; + break; case '}': tlog_timespec_fp_mul(&tlog_play_speed, &accel, &new_speed); @@ -985,6 +989,13 @@ tlog_play_run(struct tlog_errs **perrs, int *psignal) /* Handle pausing, unless ignoring timing */ if (tlog_play_paused && !(tlog_play_goto_active || tlog_play_skip)) { do { + if(tlog_print_timestamp) { + int hour = pkt.timestamp.tv_sec/3600; + int min = (pkt.timestamp.tv_sec-hour*3600)/60; + int sec = (pkt.timestamp.tv_sec-hour*3600-min*60); + printf("\r\nPaused at %02ld:%02ld:%02ld\r\n",hour,min,sec); + } + rc = clock_nanosleep(CLOCK_MONOTONIC, 0, &tlog_timespec_max, NULL); } while (rc == 0); From 7743c43ecfdcc34433e76bc6d2dbde04ae61e864 Mon Sep 17 00:00:00 2001 From: Jakob Eriksson Date: Thu, 6 Aug 2020 10:58:02 -0500 Subject: [PATCH 2/5] better location --- lib/tlog/play.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tlog/play.c b/lib/tlog/play.c index 6532b619..84e93b12 100644 --- a/lib/tlog/play.c +++ b/lib/tlog/play.c @@ -459,6 +459,9 @@ struct tlog_timestr_parser tlog_play_timestr_parser; struct timespec tlog_play_local_last_ts; /** Recording's time of packet output last */ struct timespec tlog_play_pkt_last_ts; +/** Should output timestamp on pause */ +bool tlog_print_timestamp = false; + /** True if playback state was initialized succesfully */ bool tlog_play_initialized = false; @@ -708,7 +711,6 @@ tlog_play_init(struct tlog_errs **perrs, return grc; } -bool tlog_print_timestamp = false; /** * Read playback input, interpreting user input. * From a1097d52b21eae6ae50b2bf64d92a85022a073ca Mon Sep 17 00:00:00 2001 From: Jakob Eriksson Date: Thu, 6 Aug 2020 10:58:59 -0500 Subject: [PATCH 3/5] better location --- lib/tlog/play.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/tlog/play.c b/lib/tlog/play.c index 84e93b12..f3b50882 100644 --- a/lib/tlog/play.c +++ b/lib/tlog/play.c @@ -462,7 +462,6 @@ struct timespec tlog_play_pkt_last_ts; /** Should output timestamp on pause */ bool tlog_print_timestamp = false; - /** True if playback state was initialized succesfully */ bool tlog_play_initialized = false; From b20a1dcf2703528b8647606ae6c3cf5425f0e30f Mon Sep 17 00:00:00 2001 From: Jakob Eriksson Date: Thu, 6 Aug 2020 11:01:21 -0500 Subject: [PATCH 4/5] whitespace --- lib/tlog/play.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/tlog/play.c b/lib/tlog/play.c index f3b50882..fce401a6 100644 --- a/lib/tlog/play.c +++ b/lib/tlog/play.c @@ -895,8 +895,8 @@ tlog_play_run_read_input(struct tlog_errs **perrs, bool *pquit) tlog_play_speed = (struct timespec){1, 0}; break; case 'T': - tlog_print_timestamp = !tlog_print_timestamp; - break; + tlog_print_timestamp = !tlog_print_timestamp; + break; case '}': tlog_timespec_fp_mul(&tlog_play_speed, &accel, &new_speed); @@ -990,12 +990,12 @@ tlog_play_run(struct tlog_errs **perrs, int *psignal) /* Handle pausing, unless ignoring timing */ if (tlog_play_paused && !(tlog_play_goto_active || tlog_play_skip)) { do { - if(tlog_print_timestamp) { - int hour = pkt.timestamp.tv_sec/3600; - int min = (pkt.timestamp.tv_sec-hour*3600)/60; - int sec = (pkt.timestamp.tv_sec-hour*3600-min*60); - printf("\r\nPaused at %02ld:%02ld:%02ld\r\n",hour,min,sec); - } + if(tlog_print_timestamp) { + int hour = pkt.timestamp.tv_sec/3600; + int min = (pkt.timestamp.tv_sec-hour*3600)/60; + int sec = (pkt.timestamp.tv_sec-hour*3600-min*60); + printf("\r\nPaused at %02ld:%02ld:%02ld\r\n",hour,min,sec); + } rc = clock_nanosleep(CLOCK_MONOTONIC, 0, &tlog_timespec_max, NULL); From 7854a956a70bc32227e4ac3efbf56bfc2d5cfb33 Mon Sep 17 00:00:00 2001 From: Jakob Eriksson Date: Thu, 6 Aug 2020 11:02:44 -0500 Subject: [PATCH 5/5] better format string --- lib/tlog/play.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tlog/play.c b/lib/tlog/play.c index fce401a6..a5a8aeb0 100644 --- a/lib/tlog/play.c +++ b/lib/tlog/play.c @@ -994,7 +994,7 @@ tlog_play_run(struct tlog_errs **perrs, int *psignal) int hour = pkt.timestamp.tv_sec/3600; int min = (pkt.timestamp.tv_sec-hour*3600)/60; int sec = (pkt.timestamp.tv_sec-hour*3600-min*60); - printf("\r\nPaused at %02ld:%02ld:%02ld\r\n",hour,min,sec); + printf("\r\nPaused at %02d:%02d:%02d\r\n",hour,min,sec); } rc = clock_nanosleep(CLOCK_MONOTONIC, 0,