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,
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;
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)
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)
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. */
.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,