rigol-ds: Handle digital channels correctly for MSO2000A series.

The handling of the digital channels for this series is somewhere
between that of the DS1000D series (PROTOCOL_V2) and the MSO1000Z
(PROTOCOL_V4).

The :LA command set is similar to that of V4, but the LA data has to be
requested with :WAV:SOUR:LA and arrives in interleaved form like V2.

None of these changes should affect other models. They only affect the
case of PROTOCOL_V3 with digital channels, which occurs only for the
MSO2000A series.
This commit is contained in:
Martin Ling 2017-05-17 00:04:07 +01:00
parent 364b09c2a9
commit 01dd7a4cc7
2 changed files with 28 additions and 15 deletions

View File

@ -1021,10 +1021,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
devc->analog_channels[ch->index] = ch->enabled; devc->analog_channels[ch->index] = ch->enabled;
} }
} else if (ch->type == SR_CHANNEL_LOGIC) { } else if (ch->type == SR_CHANNEL_LOGIC) {
/* Only one list entry for DS1000D series. All channels are retrieved /* Only one list entry for older protocols. All channels are
* together when this entry is processed. */ * retrieved together when this entry is processed. */
if (ch->enabled && ( if (ch->enabled && (
devc->model->series->protocol > PROTOCOL_V2 || devc->model->series->protocol > PROTOCOL_V3 ||
!some_digital)) !some_digital))
devc->enabled_channels = g_slist_append( devc->enabled_channels = g_slist_append(
devc->enabled_channels, ch); devc->enabled_channels, ch);
@ -1033,7 +1033,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
/* Turn on LA module if currently off. */ /* Turn on LA module if currently off. */
if (!devc->la_enabled) { if (!devc->la_enabled) {
if (rigol_ds_config_set(sdi, if (rigol_ds_config_set(sdi,
devc->model->series->protocol >= PROTOCOL_V4 ? devc->model->series->protocol >= PROTOCOL_V3 ?
":LA:STAT ON" : ":LA:DISP ON") != SR_OK) ":LA:STAT ON" : ":LA:DISP ON") != SR_OK)
return SR_ERR; return SR_ERR;
devc->la_enabled = TRUE; devc->la_enabled = TRUE;
@ -1042,7 +1042,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
if (ch->enabled != devc->digital_channels[ch->index]) { if (ch->enabled != devc->digital_channels[ch->index]) {
/* Enabled channel is currently disabled, or vice versa. */ /* Enabled channel is currently disabled, or vice versa. */
if (rigol_ds_config_set(sdi, if (rigol_ds_config_set(sdi,
devc->model->series->protocol >= PROTOCOL_V4 ? devc->model->series->protocol >= PROTOCOL_V3 ?
":LA:DIG%d:DISP %s" : ":DIG%d:TURN %s", ch->index, ":LA:DIG%d:DISP %s" : ":DIG%d:TURN %s", ch->index,
ch->enabled ? "ON" : "OFF") != SR_OK) ch->enabled ? "ON" : "OFF") != SR_OK)
return SR_ERR; return SR_ERR;
@ -1057,7 +1057,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
/* Turn off LA module if on and no digital channels selected. */ /* Turn off LA module if on and no digital channels selected. */
if (devc->la_enabled && !some_digital) if (devc->la_enabled && !some_digital)
if (rigol_ds_config_set(sdi, if (rigol_ds_config_set(sdi,
devc->model->series->protocol >= PROTOCOL_V4 ? devc->model->series->protocol >= PROTOCOL_V3 ?
":LA:STAT OFF" : ":LA:DISP OFF") != SR_OK) ":LA:STAT OFF" : ":LA:DISP OFF") != SR_OK)
return SR_ERR; return SR_ERR;

View File

@ -220,11 +220,19 @@ static int rigol_ds_check_stop(const struct sr_dev_inst *sdi)
if (devc->model->series->protocol != PROTOCOL_V3) if (devc->model->series->protocol != PROTOCOL_V3)
return SR_OK; return SR_OK;
if (ch->type == SR_CHANNEL_LOGIC) {
if (rigol_ds_config_set(sdi->conn, ":WAV:SOUR LA") != SR_OK)
return SR_ERR;
} else {
if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d", if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
ch->index + 1) != SR_OK) ch->index + 1) != SR_OK)
return SR_ERR; return SR_ERR;
}
/* Check that the number of samples will be accepted */ /* Check that the number of samples will be accepted */
if (rigol_ds_config_set(sdi, ":WAV:POIN %d", devc->analog_frame_size) != SR_OK) if (rigol_ds_config_set(sdi, ":WAV:POIN %d",
ch->type == SR_CHANNEL_LOGIC ?
devc->digital_frame_size :
devc->analog_frame_size) != SR_OK)
return SR_ERR; return SR_ERR;
if (sr_scpi_get_int(sdi->conn, "*ESR?", &tmp) != SR_OK) if (sr_scpi_get_int(sdi->conn, "*ESR?", &tmp) != SR_OK)
return SR_ERR; return SR_ERR;
@ -431,9 +439,14 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
rigol_ds_set_wait_event(devc, WAIT_NONE); rigol_ds_set_wait_event(devc, WAIT_NONE);
break; break;
case PROTOCOL_V3: case PROTOCOL_V3:
if (ch->type == SR_CHANNEL_LOGIC) {
if (rigol_ds_config_set(sdi->conn, ":WAV:SOUR LA") != SR_OK)
return SR_ERR;
} else {
if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d", if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
ch->index + 1) != SR_OK) ch->index + 1) != SR_OK)
return SR_ERR; return SR_ERR;
}
if (devc->data_source != DATA_SOURCE_LIVE) { if (devc->data_source != DATA_SOURCE_LIVE) {
if (rigol_ds_config_set(sdi, ":WAV:RES") != SR_OK) if (rigol_ds_config_set(sdi, ":WAV:RES") != SR_OK)
return SR_ERR; return SR_ERR;
@ -795,7 +808,7 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
/* Digital channel state. */ /* Digital channel state. */
if (devc->model->has_digital) { if (devc->model->has_digital) {
if (sr_scpi_get_bool(sdi->conn, if (sr_scpi_get_bool(sdi->conn,
devc->model->series->protocol >= PROTOCOL_V4 ? devc->model->series->protocol >= PROTOCOL_V3 ?
":LA:STAT?" : ":LA:DISP?", ":LA:STAT?" : ":LA:DISP?",
&devc->la_enabled) != SR_OK) &devc->la_enabled) != SR_OK)
return SR_ERR; return SR_ERR;
@ -803,7 +816,7 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
devc->la_enabled ? "enabled" : "disabled"); devc->la_enabled ? "enabled" : "disabled");
for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) { for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) {
cmd = g_strdup_printf( cmd = g_strdup_printf(
devc->model->series->protocol >= PROTOCOL_V4 ? devc->model->series->protocol >= PROTOCOL_V3 ?
":LA:DIG%d:DISP?" : ":DIG%d:TURN?", i); ":LA:DIG%d:DISP?" : ":DIG%d:TURN?", i);
res = sr_scpi_get_bool(sdi->conn, cmd, &devc->digital_channels[i]); res = sr_scpi_get_bool(sdi->conn, cmd, &devc->digital_channels[i]);
g_free(cmd); g_free(cmd);