X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=src%2Fhardware%2Funi-t-ut32x%2Fapi.c;h=b49080d0b9ab7514ef3af0a9612ac70b6d102de2;hp=1f4830e45d6abe10b00aaaa8af70eb02af820548;hb=bf700f679af2ad95c1272df47579b21212241718;hpb=e66d1892d0dd16ed166fc8f13493f95de0607362 diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index 1f4830e4..b49080d0 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) @@ -53,7 +55,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) drvc = di->context; - conn = NULL; + conn = "1a86.e008"; for (l = options; l; l = l->next) { src = l->data; switch (src->key) { @@ -72,8 +74,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) for (l = usb_devices; l; l = l->next) { sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_INACTIVE; - sdi->vendor = g_strdup(VENDOR); - sdi->model = g_strdup(MODEL); + sdi->vendor = g_strdup("UNI-T"); + sdi->model = g_strdup("UT32x"); sdi->inst_type = SR_INST_USB; sdi->conn = l->data; for (i = 0; i < ARRAY_SIZE(channel_names); i++) @@ -147,8 +149,8 @@ static int dev_close(struct sr_dev_inst *sdi) return SR_OK; } -static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_get(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; @@ -172,11 +174,11 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s return SR_OK; } -static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_set(uint32_t key, GVariant *data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; - const char *tmp_str; + int idx; (void)cg; @@ -187,13 +189,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd devc->limit_samples = g_variant_get_uint64(data); break; case SR_CONF_DATA_SOURCE: - tmp_str = g_variant_get_string(data, NULL); - if (!strcmp(tmp_str, "Live")) - devc->data_source = DATA_SOURCE_LIVE; - else if (!strcmp(tmp_str, "Memory")) - devc->data_source = DATA_SOURCE_MEMORY; - else - return SR_ERR; + if ((idx = std_str_idx(data, ARRAY_AND_SIZE(data_sources))) < 0) + return SR_ERR_ARG; + devc->data_source = idx; break; default: return SR_ERR_NA; @@ -202,15 +200,15 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd return SR_OK; } -static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_list(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { switch (key) { case SR_CONF_SCAN_OPTIONS: case SR_CONF_DEVICE_OPTIONS: - return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, NULL, devopts); + 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;