From: Uwe Hermann Date: Fri, 3 May 2013 22:07:34 +0000 (+0200) Subject: uni-t-dmm: Add missing SR_CONF_LIMIT_MSEC support. X-Git-Tag: dsupstream~5 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c5ffac414899eb7f0e187b8eb9d61e381d40f0a6;p=libsigrok.git uni-t-dmm: Add missing SR_CONF_LIMIT_MSEC support. --- diff --git a/hardware/uni-t-dmm/api.c b/hardware/uni-t-dmm/api.c index 4a331dcc..5ffc6594 100644 --- a/hardware/uni-t-dmm/api.c +++ b/hardware/uni-t-dmm/api.c @@ -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); diff --git a/hardware/uni-t-dmm/protocol.c b/hardware/uni-t-dmm/protocol.c index 2963e659..ec05822b 100644 --- a/hardware/uni-t-dmm/protocol.c +++ b/hardware/uni-t-dmm/protocol.c @@ -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; } diff --git a/hardware/uni-t-dmm/protocol.h b/hardware/uni-t-dmm/protocol.h index 8cc30dbb..62759673 100644 --- a/hardware/uni-t-dmm/protocol.h +++ b/hardware/uni-t-dmm/protocol.h @@ -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];