static const uint32_t devopts[] = {
SR_CONF_OSCILLOSCOPE,
SR_CONF_LIMIT_SAMPLES | SR_CONF_SET,
- SR_CONF_LIMIT_FRAMES | SR_CONF_SET,
+ SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
SR_CONF_SAMPLERATE | SR_CONF_GET,
SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_NUM_HDIV | SR_CONF_GET,
"GND",
};
+static const char *coupling_options_rth100x[] = {
+ "ACL", // AC with 1 MOhm termination
+ "DCL", // DC with 1 MOhm termination
+};
+
static const char *scope_trigger_slopes[] = {
"POS",
"NEG",
"D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15",
};
+/* RTH1002 */
+static const char *an2_dig8_isol_trigger_sources[] = {
+ "CH1", "CH2",
+ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+};
+
+/* RTH1004 */
+static const char *an4_dig8_isol_trigger_sources[] = {
+ "CH1", "CH2", "CH3", "CH4",
+ "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+};
+
/* HMO Compact4 */
static const char *an4_dig8_trigger_sources[] = {
"CH1", "CH2", "CH3", "CH4",
{ 2, 1 },
{ 5, 1 },
{ 10, 1 },
+ { 20, 1 },
+ { 50, 1 },
};
+/*
+ * It feels a little hacky to use a single table yet use different item
+ * count values here. But it simplifies maintenance, reduces redundancy
+ * by avoiding several vdivs[] table versions of mostly identical content,
+ * still references which declare models' capabilities remain readable.
+ */
+#define VDIVS_COUNT_UPTO_10V (ARRAY_SIZE(vdivs) - 2)
+#define VDIVS_COUNT_UPTO_50V (ARRAY_SIZE(vdivs))
static const char *scope_analog_channel_names[] = {
"CH1", "CH2", "CH3", "CH4",
.num_timebases = ARRAY_SIZE(timebases_hmo_compact),
.vdivs = &vdivs,
- .num_vdivs = ARRAY_SIZE(vdivs),
+ .num_vdivs = VDIVS_COUNT_UPTO_10V,
.num_ydivs = 8,
.num_timebases = ARRAY_SIZE(timebases),
.vdivs = &vdivs,
- .num_vdivs = ARRAY_SIZE(vdivs),
+ .num_vdivs = VDIVS_COUNT_UPTO_10V,
.num_ydivs = 8,
.num_timebases = ARRAY_SIZE(timebases),
.vdivs = &vdivs,
- .num_vdivs = ARRAY_SIZE(vdivs),
+ .num_vdivs = VDIVS_COUNT_UPTO_10V,
.num_ydivs = 8,
.num_timebases = ARRAY_SIZE(timebases_hmo_compact),
.vdivs = &vdivs,
- .num_vdivs = ARRAY_SIZE(vdivs),
+ .num_vdivs = VDIVS_COUNT_UPTO_10V,
.num_ydivs = 8,
.num_timebases = ARRAY_SIZE(timebases),
.vdivs = &vdivs,
- .num_vdivs = ARRAY_SIZE(vdivs),
+ .num_vdivs = VDIVS_COUNT_UPTO_10V,
.num_ydivs = 8,
.num_timebases = ARRAY_SIZE(timebases),
.vdivs = &vdivs,
- .num_vdivs = ARRAY_SIZE(vdivs),
+ .num_vdivs = VDIVS_COUNT_UPTO_50V,
.num_ydivs = 8,
.num_timebases = ARRAY_SIZE(timebases),
.vdivs = &vdivs,
- .num_vdivs = ARRAY_SIZE(vdivs),
+ .num_vdivs = VDIVS_COUNT_UPTO_50V,
.num_ydivs = 8,
.num_timebases = ARRAY_SIZE(timebases),
.vdivs = &vdivs,
- .num_vdivs = ARRAY_SIZE(vdivs),
+ .num_vdivs = VDIVS_COUNT_UPTO_10V,
.num_ydivs = 8,
.num_timebases = ARRAY_SIZE(timebases),
.vdivs = &vdivs,
- .num_vdivs = ARRAY_SIZE(vdivs),
+ .num_vdivs = VDIVS_COUNT_UPTO_10V,
.num_ydivs = 8,
.timebases = &timebases,
.num_timebases = ARRAY_SIZE(timebases),
+ .vdivs = &vdivs,
+ .num_vdivs = VDIVS_COUNT_UPTO_10V,
+
+ .num_ydivs = 8,
+
+ .scpi_dialect = &rohde_schwarz_log_not_pod_scpi_dialect,
+ },
+ {
+ .name = {"RTH1002", NULL},
+ .analog_channels = 2,
+ .digital_channels = 8,
+
+ .analog_names = &scope_analog_channel_names,
+ .digital_names = &scope_digital_channel_names,
+
+ .devopts = &devopts,
+ .num_devopts = ARRAY_SIZE(devopts),
+
+ .devopts_cg_analog = &devopts_cg_analog,
+ .num_devopts_cg_analog = ARRAY_SIZE(devopts_cg_analog),
+
+ .devopts_cg_digital = &devopts_cg_digital,
+ .num_devopts_cg_digital = ARRAY_SIZE(devopts_cg_digital),
+
+ .coupling_options = &coupling_options_rth100x,
+ .num_coupling_options = ARRAY_SIZE(coupling_options_rth100x),
+
+ .logic_threshold = &logic_threshold,
+ .num_logic_threshold = ARRAY_SIZE(logic_threshold),
+ .logic_threshold_for_pod = TRUE,
+
+ .trigger_sources = &an2_dig8_isol_trigger_sources,
+ .num_trigger_sources = ARRAY_SIZE(an2_dig8_isol_trigger_sources),
+
+ .trigger_slopes = &scope_trigger_slopes,
+ .num_trigger_slopes = ARRAY_SIZE(scope_trigger_slopes),
+
+ .timebases = &timebases,
+ .num_timebases = ARRAY_SIZE(timebases),
+
+ .vdivs = &vdivs,
+ .num_vdivs = ARRAY_SIZE(vdivs),
+
+ .num_ydivs = 8,
+
+ .scpi_dialect = &rohde_schwarz_log_not_pod_scpi_dialect,
+ },
+ {
+ .name = {"RTH1004", NULL},
+ .analog_channels = 4,
+ .digital_channels = 8,
+
+ .analog_names = &scope_analog_channel_names,
+ .digital_names = &scope_digital_channel_names,
+
+ .devopts = &devopts,
+ .num_devopts = ARRAY_SIZE(devopts),
+
+ .devopts_cg_analog = &devopts_cg_analog,
+ .num_devopts_cg_analog = ARRAY_SIZE(devopts_cg_analog),
+
+ .devopts_cg_digital = &devopts_cg_digital,
+ .num_devopts_cg_digital = ARRAY_SIZE(devopts_cg_digital),
+
+ .coupling_options = &coupling_options_rth100x,
+ .num_coupling_options = ARRAY_SIZE(coupling_options_rth100x),
+
+ .logic_threshold = &logic_threshold,
+ .num_logic_threshold = ARRAY_SIZE(logic_threshold),
+ .logic_threshold_for_pod = TRUE,
+
+ .trigger_sources = &an4_dig8_isol_trigger_sources,
+ .num_trigger_sources = ARRAY_SIZE(an4_dig8_isol_trigger_sources),
+
+ .trigger_slopes = &scope_trigger_slopes,
+ .num_trigger_slopes = ARRAY_SIZE(scope_trigger_slopes),
+
+ .timebases = &timebases,
+ .num_timebases = ARRAY_SIZE(timebases),
+
.vdivs = &vdivs,
.num_vdivs = ARRAY_SIZE(vdivs),
if (sr_scpi_get_string(scpi, command, &tmp_str) != SR_OK)
return SR_ERR;
- if (array_float_get(tmp_str, ARRAY_AND_SIZE(vdivs), &j) != SR_OK) {
+ if (array_float_get(tmp_str, *(config->vdivs), config->num_vdivs, &j) != SR_OK) {
g_free(tmp_str);
sr_err("Could not determine array index for vertical div scale.");
return SR_ERR;
unsigned int i, j, group;
struct sr_channel *ch;
struct dev_context *devc;
+ const char *cg_name;
int ret;
devc = sdi->priv;
ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
(*scope_models[model_index].analog_names)[i]);
- devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
-
- devc->analog_groups[i]->name = g_strdup(
- (char *)(*scope_models[model_index].analog_names)[i]);
+ cg_name = (*scope_models[model_index].analog_names)[i];
+ devc->analog_groups[i] = sr_channel_group_new(sdi, cg_name, NULL);
devc->analog_groups[i]->channels = g_slist_append(NULL, ch);
-
- sdi->channel_groups = g_slist_append(sdi->channel_groups,
- devc->analog_groups[i]);
}
/* Add digital channel groups. */
ret = SR_OK;
for (i = 0; i < scope_models[model_index].digital_pods; i++) {
- devc->digital_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
+ devc->digital_groups[i] = sr_channel_group_new(sdi, NULL, NULL);
if (!devc->digital_groups[i]) {
ret = SR_ERR_MALLOC;
break;
}
devc->digital_groups[i]->name = g_strdup_printf("POD%d", i + 1);
- sdi->channel_groups = g_slist_append(sdi->channel_groups,
- devc->digital_groups[i]);
}
if (ret != SR_OK)
return ret;
(void)fd;
(void)revents;
- data = NULL;
-
if (!(sdi = cb_data))
return TRUE;
*/
switch (ch->type) {
case SR_CHANNEL_ANALOG:
+ data = NULL;
if (sr_scpi_get_block(sdi->conn, NULL, &data) != SR_OK) {
if (data)
g_byte_array_free(data, TRUE);
/* Truncate acquisition if a smaller number of samples has been requested. */
if (devc->samples_limit > 0 && analog.num_samples > devc->samples_limit)
analog.num_samples = devc->samples_limit;
- analog.encoding = &encoding;
- analog.meaning = &meaning;
- analog.spec = &spec;
-
- encoding.unitsize = sizeof(float);
- encoding.is_signed = TRUE;
- encoding.is_float = TRUE;
-#ifdef WORDS_BIGENDIAN
- encoding.is_bigendian = TRUE;
-#else
- encoding.is_bigendian = FALSE;
-#endif
/* TODO: Use proper 'digits' value for this device (and its modes). */
- encoding.digits = 2;
- encoding.is_digits_decimal = FALSE;
- encoding.scale.p = 1;
- encoding.scale.q = 1;
- encoding.offset.p = 0;
- encoding.offset.q = 1;
+ sr_analog_init(&analog, &encoding, &meaning, &spec, 2);
+ encoding.is_signed = TRUE;
if (state->analog_channels[ch->index].probe_unit == 'V') {
meaning.mq = SR_MQ_VOLTAGE;
meaning.unit = SR_UNIT_VOLT;
meaning.mq = SR_MQ_CURRENT;
meaning.unit = SR_UNIT_AMPERE;
}
- meaning.mqflags = 0;
meaning.channels = g_slist_append(NULL, ch);
- /* TODO: Use proper 'digits' value for this device (and its modes). */
- spec.spec_digits = 2;
packet.payload = &analog;
sr_session_send(sdi, &packet);
devc->num_samples = data->len / sizeof(float);
data = NULL;
break;
case SR_CHANNEL_LOGIC:
+ data = NULL;
if (sr_scpi_get_block(sdi->conn, NULL, &data) != SR_OK) {
if (data)
g_byte_array_free(data, TRUE);