From: Martin Ling Date: Thu, 16 Jan 2014 23:25:59 +0000 (+0000) Subject: rigol-ds: Enable/disable LA pod when (de)selecting digital channels. X-Git-Tag: libsigrok-0.3.0~253 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=04e8e01ec6e5f293cde7d53e63fd29f0740af4a3;p=libsigrok.git rigol-ds: Enable/disable LA pod when (de)selecting digital channels. --- diff --git a/hardware/rigol-ds/api.c b/hardware/rigol-ds/api.c index 2089865a..7f21c888 100644 --- a/hardware/rigol-ds/api.c +++ b/hardware/rigol-ds/api.c @@ -823,9 +823,16 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR; } } else if (probe->type == SR_PROBE_LOGIC) { - if (probe->enabled) + if (probe->enabled) { devc->enabled_digital_probes = g_slist_append( devc->enabled_digital_probes, probe); + /* Turn on LA module if currently off. */ + if (!devc->la_enabled) { + if (set_cfg(sdi, ":LA:DISP ON") != SR_OK) + return SR_ERR; + devc->la_enabled = TRUE; + } + } if (probe->enabled != devc->digital_channels[probe->index]) { /* Enabled channel is currently disabled, or vice versa. */ if (set_cfg(sdi, ":DIG%d:TURN %s", probe->index, @@ -838,6 +845,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (!devc->enabled_analog_probes && !devc->enabled_digital_probes) return SR_ERR; + /* Turn off LA module if on and no digital probes selected. */ + if (devc->la_enabled && !devc->enabled_digital_probes) + if (set_cfg(sdi, ":LA:DISP OFF") != SR_OK) + return SR_ERR; + if (devc->data_source == DATA_SOURCE_LIVE) { if (set_cfg(sdi, ":RUN") != SR_OK) return SR_ERR; diff --git a/hardware/rigol-ds/protocol.c b/hardware/rigol-ds/protocol.c index 69bb151e..55d437b4 100644 --- a/hardware/rigol-ds/protocol.c +++ b/hardware/rigol-ds/protocol.c @@ -697,7 +697,11 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi) /* Digital channel state. */ if (devc->model->has_digital) { - sr_dbg("Current digital channel state:"); + if (get_cfg_string(sdi, ":LA:DISP?", &t_s) != SR_OK) + return SR_ERR; + devc->la_enabled = !strcmp(t_s, "ON") ? TRUE : FALSE; + sr_dbg("Logic analyzer %s, current digital channel state:", + devc->la_enabled ? "enabled" : "disabled"); for (i = 0; i < 16; i++) { cmd = g_strdup_printf(":DIG%d:TURN?", i); res = get_cfg_string(sdi, cmd, &t_s); diff --git a/hardware/rigol-ds/protocol.h b/hardware/rigol-ds/protocol.h index f0bf04f2..e19ac490 100644 --- a/hardware/rigol-ds/protocol.h +++ b/hardware/rigol-ds/protocol.h @@ -111,6 +111,7 @@ struct dev_context { /* Device settings */ gboolean analog_channels[MAX_ANALOG_PROBES]; gboolean digital_channels[MAX_DIGITAL_PROBES]; + gboolean la_enabled; float timebase; float vdiv[MAX_ANALOG_PROBES]; int vert_reference[MAX_ANALOG_PROBES];