]> sigrok.org Git - sigrok-cli.git/commitdiff
add --set option
authorBert Vermeulen <redacted>
Mon, 11 Mar 2013 15:29:27 +0000 (16:29 +0100)
committerBert Vermeulen <redacted>
Mon, 11 Mar 2013 15:29:27 +0000 (16:29 +0100)
doc/sigrok-cli.1
sigrok-cli.c

index 58f86e734d272836818c1f4354e58ac60cb85b68..e4f4c4f415eb05bc339dfed6d43d4d2bbc01160f 100644 (file)
@@ -398,12 +398,16 @@ will acquire 3000000 samples.
 .TP
 .BR "\-\-continuous"
 Sample continuously until stopped. Not all devices support this.
 .TP
 .BR "\-\-continuous"
 Sample continuously until stopped. Not all devices support this.
+.TP
+.BR "\-\-set"
+Set one or more variables specified with the --device option, without doing
+any acquisition.
 .SH EXAMPLES
 In order to get exactly 100 samples from the connected fx2lafw-supported logic analyzer hardware, run the following command:
 .TP
 .B "  sigrok\-cli \-\-driver fx2lafw \-\-samples 100"
 .TP
 .SH EXAMPLES
 In order to get exactly 100 samples from the connected fx2lafw-supported logic analyzer hardware, run the following command:
 .TP
 .B "  sigrok\-cli \-\-driver fx2lafw \-\-samples 100"
 .TP
-If you want to sample data for 3 seconds, use:
+If you want to sample data for 3 seconds (3000 ms), use:
 .TP
 .B "  sigrok\-cli \-\-driver fx2lafw \-\-time 3000"
 .TP
 .TP
 .B "  sigrok\-cli \-\-driver fx2lafw \-\-time 3000"
 .TP
@@ -415,9 +419,15 @@ To capture data from the first 4 probes using the Openbench Logic Sniffer lastin
 0:high, 1:rising, 2:low, 3:high, use:
 .TP
 .nf
 0:high, 1:rising, 2:low, 3:high, use:
 .TP
 .nf
-  \fBsigrok\-cli \-\-driver ols:conn=/dev/ttyACM0 \-\-device samplerate=10m \\
-\fB\-\-output\-format bits \-\-probes 0\-3 \-\-time 100 \\
-\fB\-\-wait\-trigger \-\-triggers 0=1,1=r,2=0,3=1
+  \fBsigrok\-cli \-\-driver ols:conn=/dev/ttyACM0 \-\-device samplerate=10m \\\fP
+\fB\-\-output\-format bits \-\-probes 0\-3 \-\-time 100 \\\fP
+\fB\-\-wait\-trigger \-\-triggers 0=1,1=r,2=0,3=1\fP
+.TP
+To turn on internal logging on a Lascar EL-USB series device:
+.TP
+\fBsigrok\-cli \-\-driver lascar\-el\-usb:conn=10c4.0002 \\\fP
+\fB\-\-device datalog=on --set\fP
+.TP
 .fi
 .SH "EXIT STATUS"
 .B sigrok\-cli
 .fi
 .SH "EXIT STATUS"
 .B sigrok\-cli
index a6db4f5ddc3cba15e47d933dd2964aa10c073497..e58c51422a817ac37c8e0171c570caaa2bdbfeb2 100644 (file)
@@ -66,6 +66,7 @@ static gchar *opt_time = NULL;
 static gchar *opt_samples = NULL;
 static gchar *opt_frames = NULL;
 static gchar *opt_continuous = NULL;
 static gchar *opt_samples = NULL;
 static gchar *opt_frames = NULL;
 static gchar *opt_continuous = NULL;
+static gchar *opt_set = NULL;
 
 static GOptionEntry optargs[] = {
        {"version", 'V', 0, G_OPTION_ARG_NONE, &opt_version,
 
 static GOptionEntry optargs[] = {
        {"version", 'V', 0, G_OPTION_ARG_NONE, &opt_version,
@@ -108,6 +109,7 @@ static GOptionEntry optargs[] = {
                        "Number of frames to acquire", NULL},
        {"continuous", 0, 0, G_OPTION_ARG_NONE, &opt_continuous,
                        "Sample continuously", NULL},
                        "Number of frames to acquire", NULL},
        {"continuous", 0, 0, G_OPTION_ARG_NONE, &opt_continuous,
                        "Sample continuously", NULL},
+       {"set", 0, 0, G_OPTION_ARG_NONE, &opt_set, "Set device options only", NULL},
        {NULL, 0, 0, 0, NULL, NULL, NULL}
 };
 
        {NULL, 0, 0, 0, NULL, NULL, NULL}
 };
 
@@ -1292,6 +1294,40 @@ static int set_dev_options(struct sr_dev_inst *sdi, GHashTable *args)
        return SR_OK;
 }
 
        return SR_OK;
 }
 
+static void set_options(void)
+{
+       struct sr_dev_inst *sdi;
+       GSList *devices;
+       GHashTable *devargs;
+
+       if (!opt_dev) {
+               g_critical("No setting specified.");
+               return;
+       }
+
+       if (!(devargs = parse_generic_arg(opt_dev, FALSE)))
+               return;
+
+       if (!(devices = device_scan())) {
+               g_critical("No devices found.");
+               return;
+       }
+       sdi = devices->data;
+
+       sr_session_new();
+       if (sr_session_dev_add(sdi) != SR_OK) {
+               g_critical("Failed to use device.");
+               return;
+       }
+
+       set_dev_options(sdi, devargs);
+
+       sr_session_destroy();
+       g_slist_free(devices);
+       g_hash_table_destroy(devargs);
+
+}
+
 static int set_limit_time(const struct sr_dev_inst *sdi)
 {
        uint64_t time_msec;
 static int set_limit_time(const struct sr_dev_inst *sdi)
 {
        uint64_t time_msec;
@@ -1521,6 +1557,8 @@ int main(int argc, char **argv)
                show_dev_detail();
        else if (opt_input_file)
                load_input_file();
                show_dev_detail();
        else if (opt_input_file)
                load_input_file();
+       else if (opt_set)
+               set_options();
        else if (opt_samples || opt_time || opt_frames || opt_continuous)
                run_session();
        else
        else if (opt_samples || opt_time || opt_frames || opt_continuous)
                run_session();
        else