uni-t-dmm: Add missing SR_CONF_LIMIT_MSEC support.

This commit is contained in:
Uwe Hermann 2013-05-04 00:07:34 +02:00
parent 29a27196a1
commit c5ffac4148
3 changed files with 14 additions and 1 deletions

View 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);

View 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;
}

View 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];