agilent-dmm: Adjust to GVariant-based sr_config_* functions

This commit is contained in:
Bert Vermeulen 2013-03-30 19:48:38 +01:00
parent a59b4eef55
commit e44ac12a29
1 changed files with 13 additions and 13 deletions

View File

@ -27,18 +27,16 @@
#include "libsigrok-internal.h"
#include "agilent-dmm.h"
static const int hwopts[] = {
static const int32_t hwopts[] = {
SR_CONF_CONN,
SR_CONF_SERIALCOMM,
0,
};
static const int hwcaps[] = {
static const int32_t hwcaps[] = {
SR_CONF_MULTIMETER,
SR_CONF_LIMIT_SAMPLES,
SR_CONF_LIMIT_MSEC,
SR_CONF_CONTINUOUS,
0,
};
extern const struct agdmm_job agdmm_jobs_u123x[];
@ -116,10 +114,10 @@ static GSList *hw_scan(GSList *options)
src = l->data;
switch (src->key) {
case SR_CONF_CONN:
conn = src->value;
conn = g_variant_get_string(src->data, NULL);
break;
case SR_CONF_SERIALCOMM:
serialcomm = src->value;
serialcomm = g_variant_get_string(src->data, NULL);
break;
}
}
@ -230,7 +228,7 @@ static int hw_cleanup(void)
return SR_OK;
}
static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
@ -245,16 +243,16 @@ static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
switch (id) {
case SR_CONF_LIMIT_MSEC:
/* TODO: not yet implemented */
if (*(const uint64_t *)value == 0) {
if (g_variant_get_uint64(data) == 0) {
sr_err("LIMIT_MSEC can't be 0.");
return SR_ERR;
}
devc->limit_msec = *(const uint64_t *)value;
devc->limit_msec = g_variant_get_uint64(data);
sr_dbg("Setting time limit to %" PRIu64 "ms.",
devc->limit_msec);
break;
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = *(const uint64_t *)value;
devc->limit_samples = g_variant_get_uint64(data);
sr_dbg("Setting sample limit to %" PRIu64 ".",
devc->limit_samples);
break;
@ -267,17 +265,19 @@ static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
return SR_OK;
}
static int config_list(int key, const void **data, const struct sr_dev_inst *sdi)
static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
switch (key) {
case SR_CONF_SCAN_OPTIONS:
*data = hwopts;
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t));
break;
case SR_CONF_DEVICE_OPTIONS:
*data = hwcaps;
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
break;
default:
return SR_ERR_ARG;