.BR "\-\-continuous"
Sample continuously until stopped. Not all devices support this.
.TP
+.BR "\-\-get " <variable>
+Get the value of
+.B <variable>
+from the specified device and print it.
+.TP
.BR "\-\-set"
Set one or more variables specified with the \fB\-\-config\fP option, without
doing any acquisition.
return SR_OK;
}
+static void get_option(void)
+{
+ struct sr_dev_inst *sdi;
+ struct sr_channel_group *cg;
+ const struct sr_config_info *ci;
+ GSList *devices;
+ GVariant *gvar;
+ int ret;
+ char *s;
+
+ if (!(devices = device_scan())) {
+ g_critical("No devices found.");
+ return;
+ }
+ sdi = devices->data;
+ g_slist_free(devices);
+
+ if (sr_dev_open(sdi) != SR_OK) {
+ g_critical("Failed to open device.");
+ return;
+ }
+
+ cg = select_channel_group(sdi);
+ if (!(ci = sr_config_info_name_get(opt_get)))
+ g_critical("Unknown option '%s'", opt_get);
+
+ if ((ret = sr_config_get(sdi->driver, sdi, cg, ci->key, &gvar)) != SR_OK)
+ g_critical("Failed to get '%s': %s", opt_get, sr_strerror(ret));
+ s = g_variant_print(gvar, FALSE);
+ printf("%s\n", s);
+ g_free(s);
+
+ g_variant_unref(gvar);
+ sr_dev_close(sdi);
+}
+
static void set_options(void)
{
struct sr_dev_inst *sdi;
show_dev_detail();
else if (opt_input_file)
load_input_file();
+ else if (opt_get)
+ get_option();
else if (opt_set)
set_options();
else if (opt_samples || opt_time || opt_frames || opt_continuous)
gchar *opt_samples = NULL;
gchar *opt_frames = NULL;
gchar *opt_continuous = NULL;
+gchar *opt_get = NULL;
gchar *opt_set = NULL;
/* defines a callback function that generates
CHECK_ONCE(opt_time)
CHECK_ONCE(opt_samples)
CHECK_ONCE(opt_frames)
+CHECK_ONCE(opt_get)
#undef CHECK_STR_ONCE
"Number of frames to acquire", NULL},
{"continuous", 0, 0, G_OPTION_ARG_NONE, &opt_continuous,
"Sample continuously", NULL},
+ {"get", 0, 0, G_OPTION_ARG_CALLBACK, &check_opt_get, "Get device option only", NULL},
{"set", 0, 0, G_OPTION_ARG_NONE, &opt_set, "Set device options only", NULL},
{NULL, 0, 0, 0, NULL, NULL, NULL}
};
extern gchar *opt_samples;
extern gchar *opt_frames;
extern gchar *opt_continuous;
+extern gchar *opt_get;
extern gchar *opt_set;
int parse_options(int argc, char **argv);
void show_help(void);