} else {
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
break;
case SR_CONF_CURRENT_LIMIT:
*data = std_gvar_min_max_step(0.0, 6.0, 0.001);
break;
#if ASIX_SIGMA_WITH_TRIGGER
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- trigger_matches, ARRAY_SIZE(trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
break;
#endif
default:
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
break;
case SR_CONF_VOLTAGE_TARGET:
*data = std_gvar_min_max_step_array(devc->model->channels[channel].voltage);
if (bl_acme_probe_has_pws(cg))
devopts_cg[num_devopts_cg++] = HAS_POWER_OFF;
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg, num_devopts_cg, sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg, num_devopts_cg);
break;
default:
return SR_ERR_NA;
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches));
break;
default:
return SR_ERR_NA;
case SR_CONF_TRIGGER_MATCH:
if (!devc->prof)
return SR_ERR_BUG;
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- trigger_matches, devc->prof->num_trigger_matches,
- sizeof(int32_t));
+ *data = std_gvar_array_i32(trigger_matches, devc->prof->num_trigger_matches);
break;
default:
return SR_ERR_NA;
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
if (ch->type == SR_CHANNEL_LOGIC)
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_logic, ARRAY_SIZE(devopts_cg_logic),
- sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg_logic, ARRAY_SIZE(devopts_cg_logic));
else if (ch->type == SR_CHANNEL_ANALOG) {
if (strcmp(cg->name, "Analog") == 0)
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_analog_group, ARRAY_SIZE(devopts_cg_analog_group),
- sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg_analog_group, ARRAY_SIZE(devopts_cg_analog_group));
else
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_analog_channel, ARRAY_SIZE(devopts_cg_analog_channel),
- sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg_analog_channel, ARRAY_SIZE(devopts_cg_analog_channel));
}
else
return SR_ERR_BUG;
*data = std_gvar_samplerates(devc->samplerates, devc->num_samplerates);
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches));
break;
default:
return SR_ERR_NA;
switch (key) {
case SR_CONF_SCAN_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
+ *data = std_gvar_array_u32(scanopts, ARRAY_SIZE(scanopts));
break;
case SR_CONF_DEVICE_OPTIONS:
if (cg_type == CG_NONE) {
if (model)
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- model->devopts, model->num_devopts, sizeof(uint32_t));
+ *data = std_gvar_array_u32((const uint32_t *)model->devopts, model->num_devopts);
else
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t));
+ *data = std_gvar_array_u32(drvopts, ARRAY_SIZE(drvopts));
} else if (cg_type == CG_ANALOG) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- model->devopts_cg_analog, model->num_devopts_cg_analog,
- sizeof(uint32_t));
+ *data = std_gvar_array_u32((const uint32_t *)model->devopts_cg_analog, model->num_devopts_cg_analog);
} else {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- NULL, 0, sizeof(uint32_t));
+ *data = std_gvar_array_u32(NULL, 0);
}
break;
case SR_CONF_COUPLING:
} else {
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
break;
case SR_CONF_COUPLING:
*data = g_variant_new_strv(devc->coupling_vals, devc->coupling_tab_size);
if (!sdi)
return SR_ERR_ARG;
devc = sdi->priv;
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
- devc->profile->buffersizes, NUM_BUFFER_SIZES, sizeof(uint64_t));
+ *data = std_gvar_array_u64(devc->profile->buffersizes, NUM_BUFFER_SIZES);
break;
case SR_CONF_TIMEBASE:
*data = std_gvar_tuple_array(&timebases, ARRAY_SIZE(timebases));
} else {
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
break;
case SR_CONF_COUPLING:
*data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling));
case SR_CONF_DEVICE_OPTIONS:
if (!cg)
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
break;
case SR_CONF_SAMPLERATE:
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
*data = g_variant_new_strv(trigger_slopes, ARRAY_SIZE(trigger_slopes));
break;
case SR_CONF_BUFFERSIZE:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
- buffersizes, ARRAY_SIZE(buffersizes), sizeof(uint64_t));
+ *data = std_gvar_array_u64(buffersizes, ARRAY_SIZE(buffersizes));
break;
case SR_CONF_VDIV:
*data = std_gvar_tuple_array(&vdivs, ARRAY_SIZE(vdivs));
*data = std_gvar_samplerates(sl2_samplerates, ARRAY_SIZE(sl2_samplerates));
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- trigger_matches, ARRAY_SIZE(trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
break;
case SR_CONF_LIMIT_SAMPLES:
grange[0] = g_variant_new_uint64(0);
*data = std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- trigger_matches, ARRAY_SIZE(trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
break;
default:
return SR_ERR_NA;
case SR_CONF_DEVICE_OPTIONS:
if (!cg)
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog),
- sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog));
break;
case SR_CONF_COUPLING:
*data = g_variant_new_strv(*model->coupling_options,
} else {
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg, ARRAY_SIZE(devopts_cg));
break;
case SR_CONF_VOLTAGE_TARGET:
*data = std_gvar_min_max_step(0.0, devc->model->max_voltage, 0.001);
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
if ((ch_idx == 0) || (ch_idx == 1)) /* CH1, CH2 */
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_ch12, ARRAY_SIZE(devopts_cg_ch12), sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg_ch12, ARRAY_SIZE(devopts_cg_ch12));
else /* Must be CH3 */
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_ch3, ARRAY_SIZE(devopts_cg_ch3), sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg_ch3, ARRAY_SIZE(devopts_cg_ch3));
break;
case SR_CONF_VOLTAGE_TARGET:
*data = std_gvar_min_max_step_array(devc->model->channels[ch_idx].voltage);
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- trigger_matches, ARRAY_SIZE(trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
break;
case SR_CONF_PATTERN_MODE:
*data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns));
*data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- trigger_matches, ARRAY_SIZE(trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
break;
case SR_CONF_PATTERN_MODE:
*data = g_variant_new_strv(patterns, ARRAY_SIZE(patterns));
if (!cg)
return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
if (cg == devc->digital_group) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- NULL, 0, sizeof(uint32_t));
+ *data = std_gvar_array_u32(NULL, 0);
return SR_OK;
} else {
for (i = 0; i < devc->model->analog_channels; i++) {
if (cg == devc->analog_groups[i]) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog), sizeof(uint32_t));
+ *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog));
return SR_OK;
}
}
case SR_CONF_PROBE_FACTOR:
if (!cg)
return SR_ERR_CHANNEL_GROUP;
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
- probe_factor, ARRAY_SIZE(probe_factor), sizeof(uint64_t));
+ *data = std_gvar_array_u64(probe_factor, ARRAY_SIZE(probe_factor));
break;
case SR_CONF_VDIV:
if (!devc)
*data = g_variant_builder_end(&gvb);
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches));
break;
default:
return SR_ERR_NA;
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devc->device->devopts_cg, devc->device->num_devopts_cg,
- sizeof(uint32_t));
+ *data = std_gvar_array_u32(devc->device->devopts_cg, devc->device->num_devopts_cg);
break;
case SR_CONF_VOLTAGE_TARGET:
*data = std_gvar_min_max_step_array(ch_spec->voltage);
*data = std_gvar_samplerates(devc->model->samplerates, devc->model->num_samplerates);
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- trigger_matches, ARRAY_SIZE(trigger_matches),
- sizeof(trigger_matches[0]));
+ *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
break;
case SR_CONF_TRIGGER_SOURCE:
*data = g_variant_new_strv(trigger_source_names,
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- if (cg_type == CG_ANALOG) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog), sizeof(uint32_t));
- } else if (cg_type == CG_DIGITAL) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts_cg_digital, ARRAY_SIZE(devopts_cg_digital), sizeof(uint32_t));
- } else {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- NULL, 0, sizeof(uint32_t));
- }
+ if (cg_type == CG_ANALOG)
+ *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog));
+ else if (cg_type == CG_DIGITAL)
+ *data = std_gvar_array_u32(devopts_cg_digital, ARRAY_SIZE(devopts_cg_digital));
+ else
+ *data = std_gvar_array_u32(NULL, 0);
break;
case SR_CONF_COUPLING:
if (cg_type == CG_NONE)
}
break;
case SR_CONF_TRIGGER_MATCH:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
- trigger_matches, ARRAY_SIZE(trigger_matches),
- sizeof(int32_t));
+ *data = std_gvar_array_i32(trigger_matches, ARRAY_SIZE(trigger_matches));
break;
case SR_CONF_VOLTAGE_THRESHOLD:
*data = std_gvar_min_max_step_thresholds(-6.0, 6.0, 0.1);
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_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);
/*--- resource.c ------------------------------------------------------------*/
return g_variant_builder_end(&gvb);
}
+
+SR_PRIV GVariant *std_gvar_array_i32(const int32_t *a, unsigned int n)
+{
+ return g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
+ a, n, sizeof(int32_t));
+}
+
+SR_PRIV GVariant *std_gvar_array_u32(const uint32_t *a, unsigned int n)
+{
+ return g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+ a, n, sizeof(uint32_t));
+}
+
+SR_PRIV GVariant *std_gvar_array_u64(const uint64_t *a, unsigned int n)
+{
+ return g_variant_new_fixed_array(G_VARIANT_TYPE_UINT64,
+ a, n, sizeof(uint64_t));
+}