static const uint32_t devopts[] = {
SR_CONF_CONTINUOUS,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
SR_CONF_DATA_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
};
channel_names[i]);
devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc;
- devc->limit_samples = 0;
+ sr_sw_limits_init(&devc->limits);
devc->data_source = DEFAULT_DATA_SOURCE;
devices = g_slist_append(devices, sdi);
}
devc = sdi->priv;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
- *data = g_variant_new_uint64(devc->limit_samples);
- break;
+ case SR_CONF_LIMIT_MSEC:
+ return sr_sw_limits_config_get(&devc->limits, key, data);
case SR_CONF_DATA_SOURCE:
- if (devc->data_source == DATA_SOURCE_LIVE)
- *data = g_variant_new_string("Live");
- else
- *data = g_variant_new_string("Memory");
+ *data = g_variant_new_string(data_sources[devc->data_source]);
break;
default:
return SR_ERR_NA;
switch (key) {
case SR_CONF_LIMIT_SAMPLES:
- devc->limit_samples = g_variant_get_uint64(data);
- break;
+ case SR_CONF_LIMIT_MSEC:
+ return sr_sw_limits_config_set(&devc->limits, key, data);
case SR_CONF_DATA_SOURCE:
if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0)
return SR_ERR_ARG;
devc = sdi->priv;
usb = sdi->conn;
- devc->num_samples = 0;
+ sr_sw_limits_acquisition_start(&devc->limits);
devc->packet_len = 0;
/* Configure serial port parameters on USB-UART interface
}
}
- /* We count packets even if the temperature was invalid. This way
- * a sample limit on "Memory" data source still works: unused
- * memory slots come through as "----" measurements. */
- devc->num_samples++;
- if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
+ /*
+ * We count packets even if the measurement was invalid. This way
+ * a sample limit on "Memory" data source still works: Unused
+ * memory slots come through as "----" measurements.
+ */
+ sr_sw_limits_update_samples_read(&devc->limits, 1);
+ if (sr_sw_limits_check(&devc->limits))
sr_dev_acquisition_stop(sdi);
}