This wait is performed after initializing the capture hardware, so it
is useful for starting the capture interactively more precisely at a
operator-controlled time than simply pressing enter in the shell.
This can also be used by an external tool to start the capture
somewhat precisely, ie. (sleep 15; echo) | sigrok-cli --wait-key .
---
doc/sigrok-cli.1 | 7 +++++++
options.c | 3 +++
session.c | 12 ++++++++++++
sigrok-cli.h | 1 +
4 files changed, 23 insertions(+)
diff --git a/doc/sigrok-cli.1 b/doc/sigrok-cli.1
index 5e5df36..f9bcd70 100644
--- a/doc/sigrok-cli.1
+++ b/doc/sigrok-cli.1
@@ -194,6 +194,13 @@ any pre-trigger data. This option is useful if you don't
care about the data
that came before the trigger (but the hardware delivers this data to sigrok
nonetheless).
.TP
+.BR "\-k, \-\-wait-key"
+Start capture after the enter key has been pressed. This is for
+working in situations where operator-driven instantenous start of
+capture is useful, but the initialization of the capturing hardware
+takes a long time. If both \fB--wait-key\fP and \fB--wait-trigger\fP
+are enabled, then the triggers will be waited after the key press.
+.TP
.BR "\-P, \-\-protocol\-decoders " <list>
This option allows the user to specify a comma-separated list of protocol
decoders to be used in this session. The decoders are specified by their
diff --git a/options.c b/options.c
index 6a97595..b5852c6 100644
--- a/options.c
+++ b/options.c
@@ -46,6 +46,7 @@ gchar *opt_time = NULL;
gchar *opt_samples = NULL;
gchar *opt_frames = NULL;
gchar *opt_continuous = NULL;
+gchar *opt_wait_key = NULL;
gchar *opt_get = NULL;
gchar *opt_set = NULL;
@@ -124,6 +125,8 @@ static const GOptionEntry optargs[] = {
"Trigger configuration", NULL},
{"wait-trigger", 'w', 0, G_OPTION_ARG_NONE, &opt_wait_trigger,
"Wait for trigger", NULL},
+ {"wait-key", 'k', 0, G_OPTION_ARG_NONE, &opt_wait_key,
+ "Wait enter to be pressed", NULL},
#ifdef HAVE_SRD
{"protocol-decoders", 'P', 0, G_OPTION_ARG_CALLBACK, &check_opt_pds,
"Protocol decoders to run", NULL},
diff --git a/session.c b/session.c
index 9fa545e..9b08ea6 100644
--- a/session.c
+++ b/session.c
@@ -21,6 +21,7 @@
#include <glib/gstdio.h>
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include "sigrok-cli.h"
static uint64_t limit_samples = 0;
@@ -654,6 +655,17 @@ void run_session(void)
if (!(t = setup_transform_module(sdi)))
g_critical("Failed to initialize transform module.");
+ if (opt_wait_key) {
+ /* This waiting is done after
+ * setup_transform_module and before sr_session_start to
+ * have the biggest wait over and before losing any
+ * samples
+ */
+
+ fprintf(stderr, "Waiting the enter to start the capture\n");
+ fgetc(stdin);
+ }
+
if (sr_session_start(session) != SR_OK) {
g_critical("Failed to start session.");
sr_session_destroy(session);
diff --git a/sigrok-cli.h b/sigrok-cli.h
index f05a169..856fd0d 100644
--- a/sigrok-cli.h
+++ b/sigrok-cli.h
@@ -125,6 +125,7 @@ extern gchar *opt_time;
extern gchar *opt_samples;
extern gchar *opt_frames;
extern gchar *opt_continuous;
+extern gchar *opt_wait_key;
extern gchar *opt_get;
extern gchar *opt_set;
int parse_options(int argc, char **argv);
--
1.9.1
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel