From: Martin Ling Date: Sun, 21 Apr 2013 12:44:34 +0000 (+0100) Subject: rigol-ds1xx2: create probe groups. X-Git-Tag: libsigrok-0.3.0~583 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3d3a601e803d4fe10e2f633b5f0e06104dcf9017;p=libsigrok.git rigol-ds1xx2: create probe groups. --- diff --git a/hardware/rigol-ds1xx2/api.c b/hardware/rigol-ds1xx2/api.c index 40865950..ce5d57c5 100644 --- a/hardware/rigol-ds1xx2/api.c +++ b/hardware/rigol-ds1xx2/api.c @@ -146,7 +146,30 @@ static void clear_helper(void *priv) { struct dev_context *devc; - devc = priv; + for (l = drvc->instances; l; l = l->next) { + if (!(sdi = l->data)) + continue; + + if (sdi->conn) + sr_serial_dev_inst_free(sdi->conn); + + g_slist_free(sdi->probe_groups); + + if (!(devc = sdi->priv)) + continue; + + g_free(devc->device); + g_free(devc->coupling[0]); + g_free(devc->coupling[1]); + g_free(devc->trigger_source); + g_free(devc->trigger_slope); + g_slist_free(devc->analog_groups[0].probes); + g_slist_free(devc->analog_groups[1].probes); + g_slist_free(devc->digital_group.probes); + close(devc->fd); + + sr_dev_inst_free(sdi); + } g_free(devc->coupling[0]); g_free(devc->coupling[1]); @@ -260,10 +283,14 @@ static int probe_port(const char *port, GSList **devices) devc->has_digital = has_digital; for (i = 0; i < 2; i++) { - if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, - i == 0 ? "CH1" : "CH2"))) + channel_name = (i == 0 ? "CH1" : "CH2"); + if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, channel_name))) return SR_ERR_MALLOC; sdi->probes = g_slist_append(sdi->probes, probe); + devc->analog_groups[i].name = channel_name; + devc->analog_groups[i].probes = g_slist_append(NULL, probe); + sdi->probe_groups = g_slist_append(sdi->probe_groups, + &devc->analog_groups[i]); } if (devc->has_digital) { @@ -275,6 +302,11 @@ static int probe_port(const char *port, GSList **devices) if (!probe) return SR_ERR_MALLOC; sdi->probes = g_slist_append(sdi->probes, probe); + devc->digital_group.probes = g_slist_append( + devc->digital_group.probes, probe); + devc->digital_group.name = "LA"; + sdi->probe_groups = g_slist_append(sdi->probe_groups, + &devc->digital_group); } } sdi->priv = devc; diff --git a/hardware/rigol-ds1xx2/protocol.h b/hardware/rigol-ds1xx2/protocol.h index 7419ab7b..ff345fd2 100644 --- a/hardware/rigol-ds1xx2/protocol.h +++ b/hardware/rigol-ds1xx2/protocol.h @@ -42,6 +42,10 @@ struct dev_context { /* Device features */ gboolean has_digital; + /* Probe groups */ + struct sr_probe_group analog_groups[2]; + struct sr_probe_group digital_group; + /* Acquisition settings */ GSList *enabled_analog_probes; GSList *enabled_digital_probes;