X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Funi-t-ut32x%2Fapi.c;h=f51249931c211360ffd755a00bb6178c68d70c37;hb=f8195cb2da3268c89e24071ed32ab9acdded5bc0;hp=8e84c2c109aaa1ab1426a053b2c3aebf13eb4d3f;hpb=bee2b0168c087676c1b365861d8c2d4714afa9b9;p=libsigrok.git diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index 8e84c2c1..f5124993 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -21,8 +21,15 @@ #include #include "protocol.h" -static const uint32_t devopts[] = { +static const uint32_t scanopts[] = { + SR_CONF_CONN, +}; + +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, @@ -33,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) @@ -123,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) @@ -133,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; } @@ -178,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) { @@ -206,16 +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: 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; @@ -233,9 +230,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) int len, ret; unsigned char cmd[2]; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - drvc = di->context; devc = sdi->priv; usb = sdi->conn; @@ -288,9 +282,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi) { - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - /* Signal USB transfer handler to clean up and stop. */ sdi->status = SR_ST_STOPPING; @@ -305,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,