SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET,
SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
+ SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
SR_CONF_NUM_LOGIC_CHANNELS | SR_CONF_GET,
};
*data = g_variant_new_uint64(devc->cur_samplerate);
break;
+ case SR_CONF_CAPTURE_RATIO:
+ *data = g_variant_new_uint64(devc->capture_ratio);
+ break;
+
case SR_CONF_NUM_LOGIC_CHANNELS:
*data = g_variant_new_uint32(g_slist_length(sdi->channels));
break;
}
return beaglelogic_set_triggerflags(devc);
+ case SR_CONF_CAPTURE_RATIO:
+ devc->capture_ratio = g_variant_get_uint64(data);
+ if (devc->capture_ratio > 100) {
+ devc->capture_ratio = 0;
+ return SR_ERR;
+ }
+ return SR_OK;
+
default:
return SR_ERR_NA;
}
/* Configure triggers & send header packet */
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 sr_datafeed_logic logic;
int trigger_offset;
+ int pre_trigger_samples;
uint32_t packetsize;
uint64_t bytes_remaining;
} else {
/* Check for trigger */
trigger_offset = soft_trigger_logic_check(devc->stl,
- logic.data, packetsize, NULL);
+ logic.data, packetsize, &pre_trigger_samples);
if (trigger_offset > -1) {
+ devc->bytes_read += pre_trigger_samples * logic.unitsize;
trigger_offset *= logic.unitsize;
logic.length = MIN(packetsize - trigger_offset,
bytes_remaining);