The availability of a configuration value with floating point data type
was determined by checking its value for being zero. Which prevents the
display of valid data. See the 'offset' in this example:
$ sigrok-cli -d demo -g Analog --show
Track the current value's availability in a boolean variable. Do print
values even if they are zero.
char *tmp_str, *s, c;
const char **stropts;
double tmp_flt;
char *tmp_str, *s, c;
const char **stropts;
double tmp_flt;
const double *fltopts;
if (parse_driver(opt_drv, &driver_from_opt, NULL)) {
const double *fltopts;
if (parse_driver(opt_drv, &driver_from_opt, NULL)) {
} else if (srci->datatype == SR_T_FLOAT) {
printf(" %s: ", srci->id);
tmp_flt = 0.0;
} else if (srci->datatype == SR_T_FLOAT) {
printf(" %s: ", srci->id);
tmp_flt = 0.0;
if (maybe_config_get(driver, sdi, channel_group, key,
&gvar) == SR_OK) {
tmp_flt = g_variant_get_double(gvar);
if (maybe_config_get(driver, sdi, channel_group, key,
&gvar) == SR_OK) {
tmp_flt = g_variant_get_double(gvar);
g_variant_unref(gvar);
}
if (maybe_config_list(driver, sdi, channel_group, key,
&gvar) != SR_OK) {
g_variant_unref(gvar);
}
if (maybe_config_list(driver, sdi, channel_group, key,
&gvar) != SR_OK) {
/* Can't list, but got a value to show. */
printf("%f (current)", tmp_flt);
}
/* Can't list, but got a value to show. */
printf("%f (current)", tmp_flt);
}
if (i)
printf(", ");
printf("%f", fltopts[i]);
if (i)
printf(", ");
printf("%f", fltopts[i]);
- if (tmp_flt && fltopts[i] == tmp_flt)
+ if (have_tmp_flt && fltopts[i] == tmp_flt)
printf(" (current)");
}
printf("\n");
printf(" (current)");
}
printf("\n");