]> sigrok.org Git - libsigrok.git/commitdiff
uni-t-dmm: Add missing SR_CONF_LIMIT_MSEC support.
authorUwe Hermann <redacted>
Fri, 3 May 2013 22:07:34 +0000 (00:07 +0200)
committerUwe Hermann <redacted>
Fri, 3 May 2013 22:13:25 +0000 (00:13 +0200)
hardware/uni-t-dmm/api.c
hardware/uni-t-dmm/protocol.c
hardware/uni-t-dmm/protocol.h

index 4a331dccc071cad2f48c374f6601b7d99919a44b..5ffc6594d872e93be827438911c568a121549c88 100644 (file)
@@ -213,7 +213,6 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
 
        switch (id) {
        case SR_CONF_LIMIT_MSEC:
-               /* TODO: Not yet implemented. */
                if (g_variant_get_uint64(data) == 0) {
                        sr_err("Time limit cannot be 0.");
                        return SR_ERR;
@@ -267,6 +266,8 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
 
        devc->cb_data = cb_data;
 
+       devc->starttime = g_get_monotonic_time();
+
        /* Send header packet to the session bus. */
        std_session_send_df_header(cb_data, LOG_PREFIX);
 
index 2963e659279dc798446d9955c91ee0771b6395c8..ec05822bece93c312190524590a41ef57a0e81d6 100644 (file)
@@ -267,6 +267,7 @@ static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data)
        int ret;
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
+       int64_t time_ms;
 
        (void)fd;
        (void)revents;
@@ -283,6 +284,15 @@ static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data)
                sdi->driver->dev_acquisition_stop(sdi, cb_data);
        }
 
+       if (devc->limit_msec) {
+               time_ms = (g_get_monotonic_time() - devc->starttime) / 1000;
+               if (time_ms > (int64_t)devc->limit_msec) {
+                       sr_info("Requested time limit reached.");
+                       sdi->driver->dev_acquisition_stop(sdi, cb_data);
+                       return TRUE;
+               }
+       }
+
        return TRUE;
 }
 
index 8cc30dbb664eb788ffa826da2cadd38f65730bab..627596732fcb2a917ad7290914a8fa41b98d4147 100644 (file)
@@ -82,6 +82,8 @@ struct dev_context {
        /** The current number of already received samples. */
        uint64_t num_samples;
 
+       int64_t starttime;
+
        gboolean first_run;
 
        uint8_t protocol_buf[DMM_BUFSIZE];