Implement High Resolution mode and Peak Detection settings.
Beautify the code by reordering the Trigger Source settings
definitions.
/** The device supports run-length encoding (RLE). */
SR_CONF_RLE,
+ /** Trigger source. */
+ SR_CONF_TRIGGER_SOURCE,
+
/** The device supports setting trigger slope. */
SR_CONF_TRIGGER_SLOPE,
/** The device supports setting a pattern for the logic trigger. */
SR_CONF_TRIGGER_PATTERN,
+ /** High resolution mode. */
+ SR_CONF_HIGH_RESOLUTION,
+
+ /** Peak detection. */
+ SR_CONF_PEAK_DETECTION,
+
/** The device supports averaging. */
SR_CONF_AVERAGING,
*/
SR_CONF_AVG_SAMPLES,
- /** Trigger source. */
- SR_CONF_TRIGGER_SOURCE,
-
/** Horizontal trigger position. */
SR_CONF_HORIZ_TRIGGERPOS,
case SR_CONF_TRIGGER_PATTERN:
*data = g_variant_new_string(state->trigger_pattern);
break;
+ case SR_CONF_HIGH_RESOLUTION:
+ *data = g_variant_new_boolean(state->high_resolution);
+ break;
+ case SR_CONF_PEAK_DETECTION:
+ *data = g_variant_new_boolean(state->peak_detection);
+ break;
case SR_CONF_HORIZ_TRIGGERPOS:
*data = g_variant_new_double(state->horiz_triggerpos);
break;
const struct scope_config *model;
struct scope_state *state;
double tmp_d, tmp_d2;
- gboolean update_sample_rate;
+ gboolean update_sample_rate, tmp_bool;
if (!sdi)
return SR_ERR_ARG;
devc->frame_limit = g_variant_get_uint64(data);
ret = SR_OK;
break;
- case SR_CONF_TRIGGER_SOURCE:
- if ((idx = std_str_idx(data, *model->trigger_sources, model->num_trigger_sources)) < 0)
- return SR_ERR_ARG;
- g_snprintf(command, sizeof(command),
- (*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SOURCE],
- (*model->trigger_sources)[idx]);
- if (sr_scpi_send(sdi->conn, command) != SR_OK ||
- sr_scpi_get_opc(sdi->conn) != SR_OK)
- return SR_ERR;
- state->trigger_source = idx;
- ret = SR_OK;
- break;
case SR_CONF_VDIV:
if (!cg)
return SR_ERR_CHANNEL_GROUP;
state->horiz_triggerpos = tmp_d;
ret = SR_OK;
break;
+ case SR_CONF_TRIGGER_SOURCE:
+ if ((idx = std_str_idx(data, *model->trigger_sources, model->num_trigger_sources)) < 0)
+ return SR_ERR_ARG;
+ g_snprintf(command, sizeof(command),
+ (*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SOURCE],
+ (*model->trigger_sources)[idx]);
+ if (sr_scpi_send(sdi->conn, command) != SR_OK ||
+ sr_scpi_get_opc(sdi->conn) != SR_OK)
+ return SR_ERR;
+ state->trigger_source = idx;
+ ret = SR_OK;
+ break;
case SR_CONF_TRIGGER_SLOPE:
if ((idx = std_str_idx(data, *model->trigger_slopes, model->num_trigger_slopes)) < 0)
return SR_ERR_ARG;
MAX_ANALOG_CHANNEL_COUNT + MAX_DIGITAL_CHANNEL_COUNT);
ret = SR_OK;
break;
+ case SR_CONF_HIGH_RESOLUTION:
+ tmp_bool = g_variant_get_boolean(data);
+ g_snprintf(command, sizeof(command),
+ (*model->scpi_dialect)[SCPI_CMD_SET_HIGH_RESOLUTION],
+ tmp_bool ? "AUTO" : "OFF");
+ if (sr_scpi_send(sdi->conn, command) != SR_OK ||
+ sr_scpi_get_opc(sdi->conn) != SR_OK)
+ return SR_ERR;
+ /* High Resolution mode automatically switches off Peak Detection. */
+ if (tmp_bool) {
+ g_snprintf(command, sizeof(command),
+ (*model->scpi_dialect)[SCPI_CMD_SET_PEAK_DETECTION],
+ "OFF");
+ if (sr_scpi_send(sdi->conn, command) != SR_OK ||
+ sr_scpi_get_opc(sdi->conn) != SR_OK)
+ return SR_ERR;
+ state->peak_detection = FALSE;
+ }
+ state->high_resolution = tmp_bool;
+ ret = SR_OK;
+ break;
+ case SR_CONF_PEAK_DETECTION:
+ tmp_bool = g_variant_get_boolean(data);
+ g_snprintf(command, sizeof(command),
+ (*model->scpi_dialect)[SCPI_CMD_SET_PEAK_DETECTION],
+ tmp_bool ? "AUTO" : "OFF");
+ if (sr_scpi_send(sdi->conn, command) != SR_OK ||
+ sr_scpi_get_opc(sdi->conn) != SR_OK)
+ return SR_ERR;
+ /* Peak Detection automatically switches off High Resolution mode. */
+ if (tmp_bool) {
+ g_snprintf(command, sizeof(command),
+ (*model->scpi_dialect)[SCPI_CMD_SET_HIGH_RESOLUTION],
+ "OFF");
+ if (sr_scpi_send(sdi->conn, command) != SR_OK ||
+ sr_scpi_get_opc(sdi->conn) != SR_OK)
+ return SR_ERR;
+ state->high_resolution = FALSE;
+ }
+ state->peak_detection = tmp_bool;
+ ret = SR_OK;
+ break;
case SR_CONF_COUPLING:
if (!cg)
return SR_ERR_CHANNEL_GROUP;
[SCPI_CMD_SET_VERTICAL_SCALE] = ":CHAN%d:SCAL %s",
[SCPI_CMD_GET_DIG_POD_STATE] = ":POD%d:STAT?",
[SCPI_CMD_SET_DIG_POD_STATE] = ":POD%d:STAT %d",
+ [SCPI_CMD_GET_TRIGGER_SOURCE] = ":TRIG:A:SOUR?",
+ [SCPI_CMD_SET_TRIGGER_SOURCE] = ":TRIG:A:SOUR %s",
[SCPI_CMD_GET_TRIGGER_SLOPE] = ":TRIG:A:EDGE:SLOP?",
[SCPI_CMD_SET_TRIGGER_SLOPE] = ":TRIG:A:TYPE EDGE;:TRIG:A:EDGE:SLOP %s",
[SCPI_CMD_GET_TRIGGER_PATTERN] = ":TRIG:A:PATT:SOUR?",
":TRIG:A:PATT:COND \"TRUE\";" \
":TRIG:A:PATT:MODE OFF;" \
":TRIG:A:PATT:SOUR \"%s\"",
- [SCPI_CMD_GET_TRIGGER_SOURCE] = ":TRIG:A:SOUR?",
- [SCPI_CMD_SET_TRIGGER_SOURCE] = ":TRIG:A:SOUR %s",
+ [SCPI_CMD_GET_HIGH_RESOLUTION] = ":ACQ:HRES?",
+ [SCPI_CMD_SET_HIGH_RESOLUTION] = ":ACQ:HRES %s",
+ [SCPI_CMD_GET_PEAK_DETECTION] = ":ACQ:PEAK?",
+ [SCPI_CMD_SET_PEAK_DETECTION] = ":ACQ:PEAK %s",
[SCPI_CMD_GET_DIG_CHAN_STATE] = ":LOG%d:STAT?",
[SCPI_CMD_SET_DIG_CHAN_STATE] = ":LOG%d:STAT %d",
[SCPI_CMD_GET_VERTICAL_OFFSET] = ":CHAN%d:POS?",
[SCPI_CMD_SET_VERTICAL_SCALE] = ":CHAN%d:SCAL %s",
[SCPI_CMD_GET_DIG_POD_STATE] = ":LOG%d:STAT?",
[SCPI_CMD_SET_DIG_POD_STATE] = ":LOG%d:STAT %d",
+ [SCPI_CMD_GET_TRIGGER_SOURCE] = ":TRIG:A:SOUR?",
+ [SCPI_CMD_SET_TRIGGER_SOURCE] = ":TRIG:A:SOUR %s",
[SCPI_CMD_GET_TRIGGER_SLOPE] = ":TRIG:A:EDGE:SLOP?",
[SCPI_CMD_SET_TRIGGER_SLOPE] = ":TRIG:A:TYPE EDGE;:TRIG:A:EDGE:SLOP %s",
[SCPI_CMD_GET_TRIGGER_PATTERN] = ":TRIG:A:PATT:SOUR?",
":TRIG:A:PATT:COND \"TRUE\";" \
":TRIG:A:PATT:MODE OFF;" \
":TRIG:A:PATT:SOUR \"%s\"",
- [SCPI_CMD_GET_TRIGGER_SOURCE] = ":TRIG:A:SOUR?",
- [SCPI_CMD_SET_TRIGGER_SOURCE] = ":TRIG:A:SOUR %s",
+ [SCPI_CMD_GET_HIGH_RESOLUTION] = ":ACQ:HRES?",
+ [SCPI_CMD_SET_HIGH_RESOLUTION] = ":ACQ:HRES %s",
+ [SCPI_CMD_GET_PEAK_DETECTION] = ":ACQ:PEAK?",
+ [SCPI_CMD_SET_PEAK_DETECTION] = ":ACQ:PEAK %s",
[SCPI_CMD_GET_DIG_CHAN_STATE] = ":LOG%d:STAT?",
[SCPI_CMD_SET_DIG_CHAN_STATE] = ":LOG%d:STAT %d",
[SCPI_CMD_GET_VERTICAL_OFFSET] = ":CHAN%d:POS?", /* Might not be supported on RTB200x... */
SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_PATTERN | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_HIGH_RESOLUTION | SR_CONF_GET | SR_CONF_SET,
+ SR_CONF_PEAK_DETECTION | SR_CONF_GET | SR_CONF_SET,
};
static const uint32_t devopts_cg_analog[] = {
MAX_ANALOG_CHANNEL_COUNT + MAX_DIGITAL_CHANNEL_COUNT);
g_free(tmp_str);
+ if (sr_scpi_get_string(sdi->conn,
+ (*config->scpi_dialect)[SCPI_CMD_GET_HIGH_RESOLUTION],
+ &tmp_str) != SR_OK)
+ return SR_ERR;
+ if (!strcmp("OFF", tmp_str))
+ state->high_resolution = FALSE;
+ else
+ state->high_resolution = TRUE;
+ g_free(tmp_str);
+
+ if (sr_scpi_get_string(sdi->conn,
+ (*config->scpi_dialect)[SCPI_CMD_GET_PEAK_DETECTION],
+ &tmp_str) != SR_OK)
+ return SR_ERR;
+ if (!strcmp("OFF", tmp_str))
+ state->peak_detection = FALSE;
+ else
+ state->peak_detection = TRUE;
+ g_free(tmp_str);
+
if (hmo_update_sample_rate(sdi) != SR_OK)
return SR_ERR;
int trigger_slope;
char trigger_pattern[MAX_ANALOG_CHANNEL_COUNT + MAX_DIGITAL_CHANNEL_COUNT];
+ gboolean high_resolution;
+ gboolean peak_detection;
+
uint64_t sample_rate;
};
"Pattern", NULL},
{SR_CONF_RLE, SR_T_BOOL, "rle",
"Run length encoding", NULL},
+ {SR_CONF_TRIGGER_SOURCE, SR_T_STRING, "triggersource",
+ "Trigger source", NULL},
{SR_CONF_TRIGGER_SLOPE, SR_T_STRING, "triggerslope",
"Trigger slope", NULL},
{SR_CONF_TRIGGER_PATTERN, SR_T_STRING, "triggerpattern",
"Trigger pattern", NULL},
+ {SR_CONF_HIGH_RESOLUTION, SR_T_BOOL, "highresolution",
+ "High resolution", NULL},
+ {SR_CONF_PEAK_DETECTION, SR_T_BOOL, "peakdetection",
+ "Peak detection", NULL},
{SR_CONF_AVERAGING, SR_T_BOOL, "averaging",
"Averaging", NULL},
{SR_CONF_AVG_SAMPLES, SR_T_UINT64, "avg_samples",
"Number of samples to average over", NULL},
- {SR_CONF_TRIGGER_SOURCE, SR_T_STRING, "triggersource",
- "Trigger source", NULL},
{SR_CONF_HORIZ_TRIGGERPOS, SR_T_FLOAT, "horiz_triggerpos",
"Horizontal trigger position", NULL},
{SR_CONF_BUFFERSIZE, SR_T_UINT64, "buffersize",
SCPI_CMD_GET_HORIZONTAL_DIV,
SCPI_CMD_GET_VERTICAL_SCALE,
SCPI_CMD_SET_VERTICAL_SCALE,
+ SCPI_CMD_GET_TRIGGER_SOURCE,
+ SCPI_CMD_SET_TRIGGER_SOURCE,
SCPI_CMD_GET_TRIGGER_SLOPE,
SCPI_CMD_SET_TRIGGER_SLOPE,
SCPI_CMD_GET_TRIGGER_PATTERN,
SCPI_CMD_SET_TRIGGER_PATTERN,
- SCPI_CMD_GET_TRIGGER_SOURCE,
- SCPI_CMD_SET_TRIGGER_SOURCE,
+ SCPI_CMD_GET_HIGH_RESOLUTION,
+ SCPI_CMD_SET_HIGH_RESOLUTION,
+ SCPI_CMD_GET_PEAK_DETECTION,
+ SCPI_CMD_SET_PEAK_DETECTION,
SCPI_CMD_GET_COUPLING,
SCPI_CMD_SET_COUPLING,
SCPI_CMD_GET_HORIZ_TRIGGERPOS,