]> sigrok.org Git - libsigrok.git/commitdiff
asix-sigma: Use monotonic time not wallclock time
authorGerhard Sittig <redacted>
Fri, 26 May 2017 17:36:01 +0000 (19:36 +0200)
committerUwe Hermann <redacted>
Fri, 26 May 2017 20:48:39 +0000 (22:48 +0200)
Switch from gettimeofday() to g_get_monotonic_time() calls.

This commit is based on work done by jry@ (but with reduced diff size).

src/hardware/asix-sigma/api.c
src/hardware/asix-sigma/protocol.c
src/hardware/asix-sigma/protocol.h

index 99c1ef143ffce470954745e4717d7813773aa45a..4b35ea333070b5bcb2d06cc49bfe198d6fe72cae 100644 (file)
@@ -388,7 +388,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
                           (devc->capture_ratio * 255) / 100, devc);
 
        /* Start acqusition. */
-       gettimeofday(&devc->start_tv, 0);
+       devc->start_time = g_get_monotonic_time();
        regval =  WMR_TRGRES | WMR_SDRAMWRITEEN;
 #if ASIX_SIGMA_WITH_TRIGGER
        regval |= WMR_TRGEN;
index 60c6a34843c6c415f55df1c02a78bb0f4d589e89..48de1b954ba4559d1de20f6355335212cffbb2f8 100644 (file)
@@ -1138,7 +1138,7 @@ static int sigma_capture_mode(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
        uint64_t running_msec;
-       struct timeval tv;
+       uint64_t current_time;
 
        devc = sdi->priv;
 
@@ -1146,9 +1146,8 @@ static int sigma_capture_mode(struct sr_dev_inst *sdi)
         * Check if the selected sampling duration passed. Sample count
         * limits are covered by this enforced timeout as well.
         */
-       gettimeofday(&tv, 0);
-       running_msec = (tv.tv_sec - devc->start_tv.tv_sec) * 1000 +
-                      (tv.tv_usec - devc->start_tv.tv_usec) / 1000;
+       current_time = g_get_monotonic_time();
+       running_msec = (current_time - devc->start_time) / 1000;
        if (running_msec >= devc->limit_msec)
                return download_capture(sdi);
 
index 388b44bc9f659e0b96838dce8f35fda368781357..7e5d8497ed0f03d20a048f39265fb6697e1a0532 100644 (file)
@@ -262,7 +262,7 @@ struct dev_context {
        uint64_t limit_msec;
        uint64_t limit_samples;
        uint64_t sent_samples;
-       struct timeval start_tv;
+       uint64_t start_time;
        int cur_firmware;
        int num_channels;
        int cur_channels;