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_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_AVERAGING | SR_CONF_GET | SR_CONF_SET,
SR_CONF_AVG_SAMPLES | SR_CONF_GET | SR_CONF_SET,
case SR_CONF_LIMIT_MSEC:
*data = g_variant_new_uint64(devc->limit_msec);
break;
+ case SR_CONF_LIMIT_FRAMES:
+ *data = g_variant_new_uint64(devc->limit_frames);
+ break;
case SR_CONF_AVERAGING:
*data = g_variant_new_boolean(devc->avg);
break;
devc->limit_msec = g_variant_get_uint64(data);
devc->limit_samples = 0;
break;
+ case SR_CONF_LIMIT_FRAMES:
+ devc->limit_frames = g_variant_get_uint64(data);
+ break;
case SR_CONF_AVERAGING:
devc->avg = g_variant_get_boolean(data);
sr_dbg("%s averaging", devc->avg ? "Enabling" : "Disabling");
std_session_send_df_header(sdi);
- if (SAMPLES_PER_FRAME > 0)
+ if (devc->limit_frames > 0)
std_session_send_frame_begin(sdi);
/* We use this timestamp to decide how many more samples to send. */
static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
+ struct dev_context *devc;
+
sr_session_source_remove(sdi->session, -1);
- if (SAMPLES_PER_FRAME > 0)
+ devc = sdi->priv;
+ if (devc->limit_frames > 0)
std_session_send_frame_end(sdi);
std_session_send_df_end(sdi);
if (samples_todo == 0)
return G_SOURCE_CONTINUE;
-#if (SAMPLES_PER_FRAME > 0) /* Avoid "comparison < 0 always false" warning. */
- /* Never send more samples than a frame can fit... */
- samples_todo = MIN(samples_todo, SAMPLES_PER_FRAME);
- /* ...or than we need to finish the current frame. */
- samples_todo = MIN(samples_todo, SAMPLES_PER_FRAME - devc->sent_frame_samples);
-#endif
+ if (devc->limit_frames) {
+ /* Never send more samples than a frame can fit... */
+ samples_todo = MIN(samples_todo, SAMPLES_PER_FRAME);
+ /* ...or than we need to finish the current frame. */
+ samples_todo = MIN(samples_todo,
+ SAMPLES_PER_FRAME - devc->sent_frame_samples);
+ }
/* Calculate the actual time covered by this run back from the sample
* count, rounded towards zero. This avoids getting stuck on a too-low
devc->sent_frame_samples += samples_todo;
devc->spent_us += todo_us;
-#if (SAMPLES_PER_FRAME > 0) /* Avoid "comparison >= 0 always true" warning. */
- if (devc->sent_frame_samples >= SAMPLES_PER_FRAME) {
+ if (devc->limit_frames && devc->sent_frame_samples >= SAMPLES_PER_FRAME) {
std_session_send_frame_end(sdi);
devc->sent_frame_samples = 0;
+ devc->limit_frames--;
+ if (!devc->limit_frames) {
+ sr_dbg("Requested number of frames reached.");
+ sr_dev_acquisition_stop(sdi);
+ }
}
-#endif
if ((devc->limit_samples > 0 && devc->sent_samples >= devc->limit_samples)
|| (limit_us > 0 && devc->spent_us >= limit_us)) {
}
sr_dbg("Requested number of samples reached.");
sr_dev_acquisition_stop(sdi);
- } else {
-#if (SAMPLES_PER_FRAME > 0)
+ } else if (devc->limit_frames) {
if (devc->sent_frame_samples == 0)
std_session_send_frame_begin(sdi);
-#endif
}
return G_SOURCE_CONTINUE;
/* Size of the analog pattern space per channel. */
#define ANALOG_BUFSIZE 4096
/* This is a development feature: it starts a new frame every n samples. */
-#define SAMPLES_PER_FRAME 0
+#define SAMPLES_PER_FRAME 1000UL
/* Logic patterns we can generate. */
enum logic_pattern_type {
uint64_t cur_samplerate;
uint64_t limit_samples;
uint64_t limit_msec;
+ uint64_t limit_frames;
uint64_t sent_samples;
uint64_t sent_frame_samples; /* Number of samples that were sent for current frame. */
int64_t start_us;