X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Flascar-el-usb%2Fapi.c;h=64753d780dd2162648fde1982146d07d663d97e4;hb=HEAD;hp=7f741280758d47fd00014a533482981d405a98cb;hpb=f778bf02eaf0d7fa7ccb91a0da8a68233f1fb79a;p=libsigrok.git diff --git a/src/hardware/lascar-el-usb/api.c b/src/hardware/lascar-el-usb/api.c index 7f741280..64753d78 100644 --- a/src/hardware/lascar-el-usb/api.c +++ b/src/hardware/lascar-el-usb/api.c @@ -28,9 +28,12 @@ static const uint32_t scanopts[] = { SR_CONF_CONN, }; -static const uint32_t devopts[] = { +static const uint32_t drvopts[] = { SR_CONF_THERMOMETER, SR_CONF_HYGROMETER, +}; + +static const uint32_t devopts[] = { SR_CONF_CONN | SR_CONF_GET, SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, SR_CONF_DATALOG | SR_CONF_GET | SR_CONF_SET, @@ -117,13 +120,12 @@ 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; struct sr_usb_dev_inst *usb; int ret; - char str[128]; (void)cg; @@ -133,8 +135,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s if (!sdi || !sdi->conn) return SR_ERR_ARG; usb = sdi->conn; - snprintf(str, 128, "%d.%d", usb->bus, usb->address); - *data = g_variant_new_string(str); + *data = g_variant_new_printf("%d.%d", usb->bus, usb->address); break; case SR_CONF_DATALOG: if (!sdi) @@ -153,53 +154,36 @@ 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; - int ret; (void)cg; devc = sdi->priv; - ret = SR_OK; + switch (key) { case SR_CONF_DATALOG: if (g_variant_get_boolean(data)) - ret = lascar_start_logging(sdi); + return lascar_start_logging(sdi); else - ret = lascar_stop_logging(sdi); + return lascar_stop_logging(sdi); break; case SR_CONF_LIMIT_SAMPLES: devc->limit_samples = g_variant_get_uint64(data); break; default: - ret = SR_ERR_NA; + return SR_ERR_NA; } - return ret; + 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) { - (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; - default: - return SR_ERR_NA; - } - - return SR_OK; + return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); } static void LIBUSB_CALL mark_xfer(struct libusb_transfer *xfer) @@ -304,7 +288,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) src = sr_config_new(SR_CONF_SAMPLE_INTERVAL, g_variant_new_uint64(interval)); meta.config = g_slist_append(NULL, src); sr_session_send(sdi, &packet); - g_free(src); + g_slist_free(meta.config); + sr_config_free(src); if (devc->logged_samples == 0) { /* This ensures the frontend knows the session is done. */