]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds1xx2: create probe groups.
authorMartin Ling <redacted>
Sun, 21 Apr 2013 12:44:34 +0000 (13:44 +0100)
committerUwe Hermann <redacted>
Fri, 8 Nov 2013 00:03:17 +0000 (01:03 +0100)
hardware/rigol-ds1xx2/api.c
hardware/rigol-ds1xx2/protocol.h

index 40865950e9545f763b867684148aff055addadc0..ce5d57c57ac1db34cccd30e6de0c2465f56f4381 100644 (file)
@@ -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;
index 7419ab7b5f35b2bb7af837de9e2284f7785ad60a..ff345fd23059f532fb17b596149209cfaec1a858 100644 (file)
@@ -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;