X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Funi-t-ut32x%2Fapi.c;h=f51249931c211360ffd755a00bb6178c68d70c37;hb=f8195cb2da3268c89e24071ed32ab9acdded5bc0;hp=a4d906d0e41945217235e15c69aa7348e61f804c;hpb=f670835f1fbc03525e995d6970a5495976ab7c1a;p=libsigrok.git diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index a4d906d0..f5124993 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -25,8 +25,11 @@ static const uint32_t scanopts[] = { SR_CONF_CONN, }; -static const uint32_t devopts[] = { +static const uint32_t drvopts[] = { SR_CONF_THERMOMETER, +}; + +static const uint32_t devopts[] = { SR_CONF_CONTINUOUS, SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, SR_CONF_DATA_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, @@ -37,8 +40,7 @@ static const char *channel_names[] = { }; static const char *data_sources[] = { - "Live", - "Memory", + "Live", "Memory", }; static GSList *scan(struct sr_dev_driver *di, GSList *options) @@ -127,9 +129,8 @@ static int dev_open(struct sr_dev_inst *sdi) sr_err("Failed to claim interface: %s.", libusb_error_name(ret)); return SR_ERR; } - sdi->status = SR_ST_ACTIVE; - return ret; + return SR_OK; } static int dev_close(struct sr_dev_inst *sdi) @@ -137,14 +138,13 @@ static int dev_close(struct sr_dev_inst *sdi) struct sr_usb_dev_inst *usb; usb = sdi->conn; + if (!usb->devhdl) - /* Nothing to do. */ - return SR_OK; + return SR_ERR_BUG; libusb_release_interface(usb->devhdl, USB_INTERFACE); libusb_close(usb->devhdl); usb->devhdl = NULL; - sdi->status = SR_ST_INACTIVE; return SR_OK; } @@ -182,9 +182,6 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd (void)cg; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - devc = sdi->priv; switch (key) { @@ -210,20 +207,12 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - (void)sdi; - (void)cg; - switch (key) { case SR_CONF_SCAN_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); - break; case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, - devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); - break; + return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_DATA_SOURCE: - *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources)); break; default: return SR_ERR_NA; @@ -307,7 +296,7 @@ static struct sr_dev_driver uni_t_ut32x_driver_info = { .cleanup = std_cleanup, .scan = scan, .dev_list = std_dev_list, - .dev_clear = NULL, + .dev_clear = std_dev_clear, .config_get = config_get, .config_set = config_set, .config_list = config_list,