This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:
Subject: cec-ctl: store the wallclock/monotonic clocks every minute Author: Hans Verkuil <[email protected]> Date: Thu Mar 10 13:07:37 2022 +0100 In order to compensate for drift between the wallclock and monotonic clock when logging, both clock timestamps are stored every hour when using the --store-pin option. But that's not often enough since the drift can be quite high (in the order of 1 ms per minute), so store this every minute, not every hour. Signed-off-by: Hans Verkuil <[email protected]> utils/cec-ctl/cec-ctl.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=88e5609bbe7909816b30bd55c6962ef559ba27f8 diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp index 30f77a156cca..5e47fdfc88da 100644 --- a/utils/cec-ctl/cec-ctl.cpp +++ b/utils/cec-ctl/cec-ctl.cpp @@ -394,7 +394,7 @@ std::string ts2s(__u64 ts) struct tm tm = *localtime(&t); last_secs = tm.tm_min * 60 + tm.tm_sec; last_t = t; - valid_until_t = t + 3600 - last_secs; + valid_until_t = t + 60 - last_secs; strftime(buf, sizeof(buf), "%a %b %e %T.000000", &tm); } secs = last_secs + t - last_t; @@ -877,7 +877,7 @@ static void monitor(const struct node &node, __u32 monitor_time, const char *sto fd_set ex_fds; int fd = node.fd; FILE *fstore = nullptr; - time_t t, start_hour; + time_t t, start_minute; if (options[OptMonitorAll]) monitor = CEC_MODE_MONITOR_ALL; @@ -934,8 +934,8 @@ static void monitor(const struct node &node, __u32 monitor_time, const char *sto printf("\n"); fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); - start_hour = time(nullptr); - t = start_hour + monitor_time; + start_minute = time(nullptr); + t = start_minute + monitor_time; while (1) { time_t now = time(nullptr); @@ -946,7 +946,21 @@ static void monitor(const struct node &node, __u32 monitor_time, const char *sto fflush(stdout); if (monitor_time && now >= t) break; - if (store_pin && now - start_hour > 3600) { + FD_ZERO(&rd_fds); + FD_ZERO(&ex_fds); + FD_SET(fd, &rd_fds); + FD_SET(fd, &ex_fds); + res = select(fd + 1, &rd_fds, nullptr, &ex_fds, &tv); + if (res < 0) + break; + if (store_pin && now - start_minute > 60 && + (FD_ISSET(fd, &rd_fds) || FD_ISSET(fd, &ex_fds))) { + /* + * The drift between the monotonic and wallclock + * time can be quite high (1 ms per minute), so + * report this once a minute to ensure a sane + * wallclock time when analyzing this later. + */ clock_gettime(CLOCK_MONOTONIC, &start_monotonic); gettimeofday(&start_timeofday, nullptr); fprintf(fstore, "# start_monotonic %lu.%09lu\n", @@ -954,15 +968,8 @@ static void monitor(const struct node &node, __u32 monitor_time, const char *sto fprintf(fstore, "# start_timeofday %lu.%06lu\n", start_timeofday.tv_sec, start_timeofday.tv_usec); fflush(fstore); - start_hour = now; + start_minute = now; } - FD_ZERO(&rd_fds); - FD_ZERO(&ex_fds); - FD_SET(fd, &rd_fds); - FD_SET(fd, &ex_fds); - res = select(fd + 1, &rd_fds, nullptr, &ex_fds, &tv); - if (res < 0) - break; if (FD_ISSET(fd, &rd_fds)) { struct cec_msg msg = { }; _______________________________________________ linuxtv-commits mailing list [email protected] https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
