static const int hwcaps[] = {
SR_HWCAP_MULTIMETER,
SR_HWCAP_LIMIT_SAMPLES,
+ SR_HWCAP_LIMIT_MSEC,
SR_HWCAP_CONTINUOUS,
0,
};
sr_dbg("Setting sample limit to %" PRIu64 ".",
devc->limit_samples);
break;
+ case SR_HWCAP_LIMIT_MSEC:
+ devc->limit_msec = *(const uint64_t *)value;
+ sr_dbg("Setting time limit to %" PRIu64 "ms.",
+ devc->limit_msec);
+ break;
default:
sr_err("Unknown capability: %d.", hwcap);
return SR_ERR;
* quit without acquiring any new samples.
*/
devc->num_samples = 0;
+ devc->starttime = g_get_monotonic_time();
/* Send header packet to the session bus. */
sr_dbg("Sending SR_DF_HEADER.");
{
struct sr_dev_inst *sdi;
struct dev_context *devc;
+ int64_t time;
int ret;
(void)fd;
return TRUE;
}
+ if (devc->limit_msec) {
+ time = (g_get_monotonic_time() - devc->starttime) / 1000;
+ if (time > (int64_t)devc->limit_msec) {
+ sr_info("Requested time limit reached, stopping.");
+ sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ return TRUE;
+ }
+ }
+
return TRUE;
}
/** The current sampling limit (in number of samples). */
uint64_t limit_samples;
+ /** The time limit (in milliseconds). */
+ uint64_t limit_msec;
+
/** Opaque pointer passed in by the frontend. */
void *cb_data;
/** The current number of already received samples. */
uint64_t num_samples;
+ int64_t starttime;
+
struct sr_serial_dev_inst *serial;
uint8_t buf[DMM_BUFSIZE];