const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- GVariant *range[2];
uint64_t low, high;
int tmp, ret;
*data = g_variant_new_boolean(tmp == SR_MQFLAG_MIN);
break;
case SR_CONF_SPL_MEASUREMENT_RANGE:
- if ((ret = cem_dt_885x_meas_range_get(sdi, &low, &high)) == SR_OK) {
- range[0] = g_variant_new_uint64(low);
- range[1] = g_variant_new_uint64(high);
- *data = g_variant_new_tuple(range, 2);
- }
+ if ((ret = cem_dt_885x_meas_range_get(sdi, &low, &high)) == SR_OK)
+ *data = std_gvar_tuple_u64(low, high);
break;
case SR_CONF_POWER_OFF:
*data = g_variant_new_boolean(FALSE);
static int config_list(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
- GVariant *grange[2];
struct dev_context *devc;
devc = (sdi) ? sdi->priv : NULL;
case SR_CONF_LIMIT_SAMPLES:
if (!devc->prof)
return SR_ERR_BUG;
- grange[0] = g_variant_new_uint64(0);
- if (devc->prof->model == CHRONOVU_LA8)
- grange[1] = g_variant_new_uint64(MAX_NUM_SAMPLES);
- else
- grange[1] = g_variant_new_uint64(MAX_NUM_SAMPLES / 2);
- *data = g_variant_new_tuple(grange, 2);
+ *data = std_gvar_tuple_u64(0, (devc->prof->model == CHRONOVU_LA8) ? MAX_NUM_SAMPLES : MAX_NUM_SAMPLES / 2);
break;
case SR_CONF_TRIGGER_MATCH:
if (!devc->prof)
static int config_list(uint32_t key, GVariant **data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
- GVariant *grange[2];
-
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
*data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
break;
case SR_CONF_LIMIT_SAMPLES:
- grange[0] = g_variant_new_uint64(0);
- grange[1] = g_variant_new_uint64(MAX_SAMPLES);
- *data = g_variant_new_tuple(grange, 2);
+ *data = std_gvar_tuple_u64(0, MAX_SAMPLES);
break;
default:
return SR_ERR_NA;
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- GVariant *rational[2];
const uint64_t *si;
(void)cg;
break;
case SR_CONF_SAMPLE_INTERVAL:
si = kecheng_kc_330b_sample_intervals[devc->sample_interval];
- rational[0] = g_variant_new_uint64(si[0]);
- rational[1] = g_variant_new_uint64(si[1]);
- *data = g_variant_new_tuple(rational, 2);
+ *data = std_gvar_tuple_u64(si[0], si[1]);
break;
case SR_CONF_DATALOG:
/* There really isn't a way to be sure the device is logging. */
struct sr_datafeed_meta meta;
struct sr_config *src;
struct sr_usb_dev_inst *usb;
- GVariant *gvar, *rational[2];
+ GVariant *gvar;
const uint64_t *si;
int req_len, buf_len, len, ret;
unsigned char buf[9];
devc->stored_samples = devc->limit_samples;
si = kecheng_kc_330b_sample_intervals[buf[1]];
- rational[0] = g_variant_new_uint64(si[0]);
- rational[1] = g_variant_new_uint64(si[1]);
- gvar = g_variant_new_tuple(rational, 2);
+ gvar = std_gvar_tuple_u64(si[0], si[1]);
+
src = sr_config_new(SR_CONF_SAMPLE_INTERVAL, gvar);
packet.type = SR_DF_META;
packet.payload = &meta;
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- GVariant *grange[2];
int num_ols_changrp, i;
switch (key) {
if (devc->channel_mask & (0xff << (i * 8)))
num_ols_changrp++;
}
- grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES);
- if (num_ols_changrp)
- grange[1] = g_variant_new_uint64(devc->max_samples / num_ols_changrp);
- else
- grange[1] = g_variant_new_uint64(MIN_NUM_SAMPLES);
- *data = g_variant_new_tuple(grange, 2);
+
+ *data = std_gvar_tuple_u64(MIN_NUM_SAMPLES,
+ (num_ols_changrp) ? devc->max_samples / num_ols_changrp : MIN_NUM_SAMPLES);
break;
default:
return SR_ERR_NA;
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- GVariant *range[2];
uint64_t low, high;
uint64_t tmp;
int ret;
return SR_ERR;
break;
case SR_CONF_SPL_MEASUREMENT_RANGE:
- if ((ret = pce_322a_meas_range_get(sdi, &low, &high)) == SR_OK) {
- range[0] = g_variant_new_uint64(low);
- range[1] = g_variant_new_uint64(high);
- *data = g_variant_new_tuple(range, 2);
- }
+ if ((ret = pce_322a_meas_range_get(sdi, &low, &high)) == SR_OK)
+ *data = std_gvar_tuple_u64(low, high);
break;
case SR_CONF_POWER_OFF:
*data = g_variant_new_boolean(FALSE);
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- GVariant *grange[2];
int num_pols_changrp, i;
switch (key) {
/* 3 channel groups takes as many bytes as 4 channel groups */
if (num_pols_changrp == 3)
num_pols_changrp = 4;
- grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES);
- if (num_pols_changrp)
- grange[1] = g_variant_new_uint64(devc->max_samplebytes / num_pols_changrp);
- else
- grange[1] = g_variant_new_uint64(MIN_NUM_SAMPLES);
- *data = g_variant_new_tuple(grange, 2);
+
+ *data = std_gvar_tuple_u64(MIN_NUM_SAMPLES,
+ (num_pols_changrp) ? devc->max_samplebytes / num_pols_changrp : MIN_NUM_SAMPLES);
break;
default:
return SR_ERR_NA;
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
struct dev_context *devc;
- GVariant *grange[2];
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
if (!sdi)
return SR_ERR_ARG;
devc = sdi->priv;
- grange[0] = g_variant_new_uint64(0);
- grange[1] = g_variant_new_uint64(devc->max_sample_depth);
- *data = g_variant_new_tuple(grange, 2);
+ *data = std_gvar_tuple_u64(0, devc->max_sample_depth);
break;
default:
return SR_ERR_NA;
SR_PRIV GVariant *std_gvar_min_max_step_array(const double a[3]);
SR_PRIV GVariant *std_gvar_min_max_step_thresholds(const double dmin, const double dmax, const double dstep);
+SR_PRIV GVariant *std_gvar_tuple_u64(uint64_t low, uint64_t high);
+
SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n);
SR_PRIV GVariant *std_gvar_array_u32(const uint32_t *a, unsigned int n);
SR_PRIV GVariant *std_gvar_array_u64(const uint64_t *a, unsigned int n);
return g_variant_builder_end(&gvb);
}
+SR_PRIV GVariant *std_gvar_tuple_u64(uint64_t low, uint64_t high)
+{
+ GVariant *range[2];
+
+ range[0] = g_variant_new_uint64(low);
+ range[1] = g_variant_new_uint64(high);
+
+ return g_variant_new_tuple(range, 2);
+}
+
SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n)
{
return g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,