]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hantek-dso/protocol.c
zeroplus-logic-cube: move USB VID:PID check in scan before device access
[libsigrok.git] / src / hardware / hantek-dso / protocol.c
index 39d87c4433bb316564e0cdff84df818b76c2f808..408f61122a07dad0bd606c0bbddc4871ed11f168 100644 (file)
@@ -130,7 +130,9 @@ SR_PRIV int dso_open(struct sr_dev_inst *sdi)
                        /*
                         * Check device by its physical USB bus/port address.
                         */
-                       usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
+                       if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
+                               continue;
+
                        if (strcmp(sdi->connection_id, connection_id))
                                /* This is not the one. */
                                continue;
@@ -278,7 +280,7 @@ static int dso2250_set_trigger_samplerate(const struct sr_dev_inst *sdi)
                tmp = 3;
        else if (!strcmp("CH1", devc->triggersource))
                tmp = 2;
-       else if (!strcmp("EXT", devc->triggersource))
+       else if (!strcmp("EXT", devc->triggersource) || !strcmp("forced", devc->triggersource))
                tmp = 0;
        else {
                sr_err("Invalid trigger source: '%s'.", devc->triggersource);
@@ -324,7 +326,8 @@ static int dso2250_set_trigger_samplerate(const struct sr_dev_inst *sdi)
        }
 
        tmp = base / devc->samplerate;
-       if (tmp) {
+       /* Downsample only if really necessary */
+       if (tmp > 1) {
                /* Downsampling on */
                cmdstring[2] |= 2;
                /* Downsampler = 1comp((Base / Samplerate) - 2)
@@ -423,7 +426,7 @@ SR_PRIV int dso_set_trigger_samplerate(const struct sr_dev_inst *sdi)
                tmp = 0;
        else if (!strcmp("CH1", devc->triggersource))
                tmp = 1;
-       else if (!strcmp("EXT", devc->triggersource))
+       else if (!strcmp("EXT", devc->triggersource) || !strcmp("forced", devc->triggersource))
                tmp = 2;
        else {
                sr_err("Invalid trigger source: '%s'.", devc->triggersource);