]> sigrok.org Git - libsigrok.git/blobdiff - hardware/hantek-dso/api.c
gmc-mh-1x-2x: Support for interface SI232-II with driver gmc-mh-2x-bd232.
[libsigrok.git] / hardware / hantek-dso / api.c
index f74cefdf02ab54aac120f5851a7ef577cc3e2fcb..41c78290ef79b38a77341276de1292ca3cb93a3b 100644 (file)
@@ -478,10 +478,11 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
                devc->limit_frames = g_variant_get_uint64(data);
                break;
        case SR_CONF_TRIGGER_SLOPE:
-               tmp_u64 = g_variant_get_uint64(data);
-               if (tmp_u64 != SLOPE_NEGATIVE && tmp_u64 != SLOPE_POSITIVE)
-                       ret = SR_ERR_ARG;
-               devc->triggerslope = tmp_u64;
+               tmp_str = g_variant_get_string(data, NULL);
+               if (!tmp_str || !(tmp_str[0] == 'f' || tmp_str[0] == 'r'))
+                       return SR_ERR_ARG;
+               devc->triggerslope = (tmp_str[0] == 'r')
+                       ? SLOPE_POSITIVE : SLOPE_NEGATIVE;
                break;
        case SR_CONF_HORIZ_TRIGGERPOS:
                tmp_double = g_variant_get_double(data);
@@ -805,8 +806,7 @@ static int handle_event(int fd, int revents, void *cb_data)
        struct timeval tv;
        struct dev_context *devc;
        struct drv_context *drvc = di->priv;
-       const struct libusb_pollfd **lupfd;
-       int num_probes, i;
+       int num_probes;
        uint32_t trigger_offset;
        uint8_t capturestate;
 
@@ -822,10 +822,7 @@ static int handle_event(int fd, int revents, void *cb_data)
                 * TODO: Doesn't really cancel pending transfers so they might
                 * come in after SR_DF_END is sent.
                 */
-               lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
-               for (i = 0; lupfd[i]; i++)
-                       sr_source_remove(lupfd[i]->fd);
-               free(lupfd);
+               usb_source_remove(drvc->sr_ctx);
 
                packet.type = SR_DF_END;
                sr_session_send(sdi, &packet);
@@ -915,10 +912,8 @@ static int handle_event(int fd, int revents, void *cb_data)
 
 static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
 {
-       const struct libusb_pollfd **lupfd;
        struct dev_context *devc;
        struct drv_context *drvc = di->priv;
-       int i;
 
        if (sdi->status != SR_ST_ACTIVE)
                return SR_ERR_DEV_CLOSED;
@@ -938,11 +933,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
                return SR_ERR;
 
        devc->dev_state = CAPTURE;
-       lupfd = libusb_get_pollfds(drvc->sr_ctx->libusb_ctx);
-       for (i = 0; lupfd[i]; i++)
-               sr_source_add(lupfd[i]->fd, lupfd[i]->events, TICK,
-                               handle_event, (void *)sdi);
-       free(lupfd);
+       usb_source_add(drvc->sr_ctx, TICK, handle_event, (void *)sdi);
 
        /* Send header packet to the session bus. */
        std_session_send_df_header(cb_data, LOG_PREFIX);