From: Gerhard Sittig Date: Sun, 31 May 2020 09:22:07 +0000 (+0200) Subject: sw_limits: start msec timeout period only after start() call X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=17ed72cc44f82c646c5e628670d1e5e02b897d81;p=libsigrok.git sw_limits: start msec timeout period only after start() call When application code used the common SW limits API, the call sequence of init() then set() then check() already kept expiring, which is rather unexpected. The timeout period should only start when start() is called, check() should not signal expiration before the start() call. The specific use case is the combination of an msecs timeout and capture ratio when triggers are used. The post-trigger period only starts when the trigger match was seen, even though its length is already known when the acquisition starts. It's desirable to run the start() call for the post-trigger timeout late, and not terminate the acquisition before the trigger match. --- diff --git a/src/sw_limits.c b/src/sw_limits.c index 37c28667..9d80c06b 100644 --- a/src/sw_limits.c +++ b/src/sw_limits.c @@ -43,9 +43,7 @@ */ SR_PRIV void sr_sw_limits_init(struct sr_sw_limits *limits) { - limits->limit_samples = 0; - limits->limit_frames = 0; - limits->limit_msec = 0; + memset(limits, 0, sizeof(*limits)); } /** @@ -153,7 +151,7 @@ SR_PRIV gboolean sr_sw_limits_check(struct sr_sw_limits *limits) } } - if (limits->limit_msec) { + if (limits->limit_msec && limits->start_time) { guint64 now; now = g_get_monotonic_time(); if (now > limits->start_time &&