]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hantek-dso/api.c
hantek-dso: eliminate the "forced trigger" option value
[libsigrok.git] / src / hardware / hantek-dso / api.c
index d10c58d139ef3dcd7f8a2fd1c25e685bb703a218..bfad5f7135f07750901e04a9fda5eb4fe1a87fbd 100644 (file)
@@ -168,7 +168,7 @@ static const uint64_t vdivs[][2] = {
 };
 
 static const char *trigger_sources[] = {
-       "CH1", "CH2", "EXT", "forced"
+       "CH1", "CH2", "EXT",
 };
 
 static const char *trigger_slopes[] = {
@@ -218,7 +218,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
        devc->voffset_trigger = DEFAULT_VERT_TRIGGERPOS;
        devc->framesize = DEFAULT_FRAMESIZE;
        devc->triggerslope = SLOPE_POSITIVE;
-       devc->triggersource = g_strdup(DEFAULT_TRIGGER_SOURCE);
+       devc->triggersource = NULL;
        devc->capture_ratio = DEFAULT_CAPTURE_RATIO;
        sdi->priv = devc;
 
@@ -465,6 +465,8 @@ static int config_get(uint32_t key, GVariant **data,
                        *data = g_variant_new_uint64(devc->framesize);
                        break;
                case SR_CONF_TRIGGER_SOURCE:
+                       if (!devc->triggersource)
+                               return SR_ERR_NA;
                        *data = g_variant_new_string(devc->triggersource);
                        break;
                case SR_CONF_TRIGGER_SLOPE:
@@ -555,6 +557,7 @@ static int config_set(uint32_t key, GVariant *data,
                case SR_CONF_TRIGGER_SOURCE:
                        if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_sources))) < 0)
                                return SR_ERR_ARG;
+                       g_free(devc->triggersource);
                        devc->triggersource = g_strdup(trigger_sources[idx]);
                        break;
                default:
@@ -836,8 +839,10 @@ static int handle_event(int fd, int revents, void *cb_data)
                        return TRUE;
                if (dso_enable_trigger(sdi) != SR_OK)
                        return TRUE;
-//             if (dso_force_trigger(sdi) != SR_OK)
-//                     return TRUE;
+               if (!devc->triggersource) {
+                       if (dso_force_trigger(sdi) != SR_OK)
+                               return TRUE;
+               }
                sr_dbg("Successfully requested next chunk.");
                devc->dev_state = CAPTURE;
                return TRUE;
@@ -858,7 +863,7 @@ static int handle_event(int fd, int revents, void *cb_data)
                                break;
                        if (dso_enable_trigger(sdi) != SR_OK)
                                break;
-                       if (!strcmp("forced", devc->triggersource)) {
+                       if (!devc->triggersource) {
                                if (dso_force_trigger(sdi) != SR_OK)
                                        break;
                        }