]> sigrok.org Git - libsigrok.git/blobdiff - hardware/sysclk-lwla/api.c
sysclk-lwla: Make use of the probe index again.
[libsigrok.git] / hardware / sysclk-lwla / api.c
index 444b6a1bfe66ead2d65232ccd5a4ff99e67439fe..05010275c7db664b7652071149892c2e25cde032 100644 (file)
@@ -65,7 +65,7 @@ static GSList *gen_probe_list(int num_probes)
 
        for (i = num_probes; i > 0; --i) {
                /* The LWLA series simply number probes from CH1 to CHxx. */
-               g_ascii_formatd(name, sizeof name, "CH%.0f", i);
+               g_snprintf(name, sizeof(name), "CH%d", i);
 
                probe = sr_probe_new(i - 1, SR_PROBE_LOGIC, TRUE, name);
                list = g_slist_prepend(list, probe);
@@ -81,16 +81,24 @@ static GSList *scan(GSList *options)
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
        struct sr_usb_dev_inst *usb;
+       struct sr_config *src;
+       const char *conn;
        int device_index;
 
-       (void)options;
-
-       devices = NULL;
        drvc = di->priv;
        drvc->instances = NULL;
-       device_index = 0;
+       conn = USB_VID_PID;
 
-       usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_VID_PID);
+       for (node = options; node != NULL; node = node->next) {
+               src = node->data;
+               if (src->key == SR_CONF_CONN) {
+                       conn = g_variant_get_string(src->data, NULL);
+                       break;
+               }
+       }
+       usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn);
+       devices = NULL;
+       device_index = 0;
 
        for (node = usb_devices; node != NULL; node = node->next) {
                usb = node->data;
@@ -349,18 +357,17 @@ static int configure_probes(const struct sr_dev_inst *sdi)
        devc->trigger_edge_mask = 0;
        devc->trigger_values = 0;
 
-       for (node = sdi->probes, probe_bit = 1;
-                       node != NULL;
-                       node = node->next, probe_bit <<= 1) {
-
-               if (probe_bit >= ((uint64_t)1 << NUM_PROBES)) {
-                       sr_err("Channels over the limit of %d.", NUM_PROBES);
-                       return SR_ERR;
-               }
+       for (node = sdi->probes; node != NULL; node = node->next) {
                probe = node->data;
                if (!probe || !probe->enabled)
                        continue;
 
+               if (probe->index >= NUM_PROBES) {
+                       sr_err("Channel index %d out of range.", probe->index);
+                       return SR_ERR_BUG;
+               }
+               probe_bit = (uint64_t)1 << probe->index;
+
                /* Enable input channel for this probe. */
                devc->channel_mask |= probe_bit;