]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hantek-dso/api.c
hantek-dso: add "forced" trigger source
[libsigrok.git] / src / hardware / hantek-dso / api.c
index b0726e98c86f62ca653a27d388ab9f2ec46176fa..d10c58d139ef3dcd7f8a2fd1c25e685bb703a218 100644 (file)
@@ -55,7 +55,7 @@ static const uint32_t drvopts[] = {
 static const uint32_t devopts[] = {
        SR_CONF_CONTINUOUS,
        SR_CONF_CONN | SR_CONF_GET,
-       SR_CONF_LIMIT_FRAMES | SR_CONF_SET,
+       SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_NUM_HDIV | SR_CONF_GET,
        SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
@@ -168,8 +168,7 @@ static const uint64_t vdivs[][2] = {
 };
 
 static const char *trigger_sources[] = {
-       "CH1", "CH2", "EXT",
-       /* TODO: forced */
+       "CH1", "CH2", "EXT", "forced"
 };
 
 static const char *trigger_slopes[] = {
@@ -199,10 +198,8 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
         */
        for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
                ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
-               cg = g_malloc0(sizeof(struct sr_channel_group));
-               cg->name = g_strdup(channel_names[i]);
+               cg = sr_channel_group_new(sdi, channel_names[i], NULL);
                cg->channels = g_slist_append(cg->channels, ch);
-               sdi->channel_groups = g_slist_append(sdi->channel_groups, cg);
        }
 
        devc = g_malloc0(sizeof(struct dev_context));
@@ -477,6 +474,9 @@ static int config_get(uint32_t key, GVariant **data,
                case SR_CONF_CAPTURE_RATIO:
                        *data = g_variant_new_uint64(devc->capture_ratio);
                        break;
+               case SR_CONF_LIMIT_FRAMES:
+                       *data = g_variant_new_uint64(devc->limit_frames);
+                       break;
                default:
                        return SR_ERR_NA;
                }
@@ -858,8 +858,10 @@ static int handle_event(int fd, int revents, void *cb_data)
                                break;
                        if (dso_enable_trigger(sdi) != SR_OK)
                                break;
-//                     if (dso_force_trigger(sdi) != SR_OK)
-//                             break;
+                       if (!strcmp("forced", devc->triggersource)) {
+                               if (dso_force_trigger(sdi) != SR_OK)
+                                       break;
+                       }
                        sr_dbg("Successfully requested next chunk.");
                }
                break;