SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_VOLTAGE_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
+ SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
};
static const int32_t soft_trigger_matches[] = {
devc = sdi->priv;
*data = g_variant_new_uint64(devc->cur_samplerate);
break;
+ case SR_CONF_CAPTURE_RATIO:
+ if (!sdi)
+ return SR_ERR;
+ devc = sdi->priv;
+ *data = g_variant_new_uint64(devc->capture_ratio);
+ break;
case SR_CONF_VOLTAGE_THRESHOLD:
if (!sdi)
return SR_ERR;
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = g_variant_get_uint64(data);
break;
+ case SR_CONF_CAPTURE_RATIO:
+ devc->capture_ratio = g_variant_get_uint64(data);
+ if (devc->capture_ratio > 100) {
+ devc->capture_ratio = 0;
+ ret = SR_ERR;
+ } else
+ ret = SR_OK;
+ break;
case SR_CONF_VOLTAGE_THRESHOLD:
g_variant_get(data, "(dd)", &low, &high);
ret = SR_ERR_ARG;
memset(devc->channel_data, 0, sizeof(devc->channel_data));
if ((trigger = sr_session_trigger_get(sdi->session))) {
- devc->stl = soft_trigger_logic_new(sdi, trigger, 0);
+ int pre_trigger_samples = 0;
+ if (devc->limit_samples > 0)
+ pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100;
+ devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples);
+ if (devc->stl == NULL)
+ return SR_ERR_MALLOC;
devc->trigger_fired = FALSE;
} else
devc->trigger_fired = TRUE;
struct dev_context *devc;
size_t new_samples, num_samples;
int trigger_offset;
+ int pre_trigger_samples;
sdi = transfer->user_data;
devc = sdi->priv;
devc->sent_samples += new_samples;
} else {
trigger_offset = soft_trigger_logic_check(devc->stl,
- devc->convbuffer, new_samples * 2, NULL);
+ devc->convbuffer, new_samples * 2, &pre_trigger_samples);
if (trigger_offset > -1) {
+ devc->sent_samples += pre_trigger_samples;
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
num_samples = new_samples - trigger_offset;