2 * This file is part of the sigrok project.
4 * Copyright (C) 2010 Bert Vermeulen <bert@biot.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <sigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
28 #include <sys/types.h>
32 #include <glib/gstdio.h>
34 #include "sigrok-cli.h"
37 #define DEFAULT_OUTPUT_FORMAT "bits:width=64"
39 extern struct sr_hwcap_option sr_hwcap_options[];
42 uint64_t limit_samples = 0;
43 struct sr_output_format *output_format = NULL;
44 int default_output_format = FALSE;
45 char *output_format_param = NULL;
46 char *input_format_param = NULL;
48 static gboolean opt_version = FALSE;
49 static gint opt_loglevel = SR_LOG_WARN; /* Show errors+warnings per default. */
50 static gboolean opt_list_devices = FALSE;
51 static gboolean opt_wait_trigger = FALSE;
52 static gchar *opt_input_file = NULL;
53 static gchar *opt_output_file = NULL;
54 static gchar *opt_device = NULL;
55 static gchar *opt_probes = NULL;
56 static gchar *opt_triggers = NULL;
57 static gchar *opt_pds = NULL;
58 static gchar *opt_input_format = NULL;
59 static gchar *opt_format = NULL;
60 static gchar *opt_time = NULL;
61 static gchar *opt_samples = NULL;
62 static gchar *opt_continuous = NULL;
64 static GOptionEntry optargs[] = {
65 {"version", 'V', 0, G_OPTION_ARG_NONE, &opt_version, "Show version and support list", NULL},
66 {"loglevel", 'l', 0, G_OPTION_ARG_INT, &opt_loglevel, "Select libsigrok loglevel", NULL},
67 {"list-devices", 'D', 0, G_OPTION_ARG_NONE, &opt_list_devices, "List devices", NULL},
68 {"input-file", 'i', 0, G_OPTION_ARG_FILENAME, &opt_input_file, "Load input from file", NULL},
69 {"output-file", 'o', 0, G_OPTION_ARG_FILENAME, &opt_output_file, "Save output to file", NULL},
70 {"device", 'd', 0, G_OPTION_ARG_STRING, &opt_device, "Use device ID", NULL},
71 {"probes", 'p', 0, G_OPTION_ARG_STRING, &opt_probes, "Probes to use", NULL},
72 {"triggers", 't', 0, G_OPTION_ARG_STRING, &opt_triggers, "Trigger configuration", NULL},
73 {"wait-trigger", 'w', 0, G_OPTION_ARG_NONE, &opt_wait_trigger, "Wait for trigger", NULL},
74 {"protocol-decoders", 'a', 0, G_OPTION_ARG_STRING, &opt_pds, "Protocol decoder sequence", NULL},
75 {"input-format", 'I', 0, G_OPTION_ARG_STRING, &opt_input_format, "Input format", NULL},
76 {"format", 'f', 0, G_OPTION_ARG_STRING, &opt_format, "Output format", NULL},
77 {"time", 0, 0, G_OPTION_ARG_STRING, &opt_time, "How long to sample (ms)", NULL},
78 {"samples", 0, 0, G_OPTION_ARG_STRING, &opt_samples, "Number of samples to acquire", NULL},
79 {"continuous", 0, 0, G_OPTION_ARG_NONE, &opt_continuous, "Sample continuously", NULL},
80 {NULL, 0, 0, 0, NULL, NULL, NULL}
83 static void show_version(void)
85 GSList *plugins, *p, *l;
86 struct sr_device_plugin *plugin;
87 struct sr_input_format **inputs;
88 struct sr_output_format **outputs;
89 struct srd_decoder *dec;
92 printf("sigrok-cli %s\n\n", VERSION);
93 printf("Supported hardware drivers:\n");
94 plugins = sr_list_hwplugins();
95 for (p = plugins; p; p = p->next) {
97 printf(" %-20s %s\n", plugin->name, plugin->longname);
101 printf("Supported input formats:\n");
102 inputs = sr_input_list();
103 for (i = 0; inputs[i]; i++)
104 printf(" %-20s %s\n", inputs[i]->id, inputs[i]->description);
107 printf("Supported output formats:\n");
108 outputs = sr_output_list();
109 for (i = 0; outputs[i]; i++)
110 printf(" %-20s %s\n", outputs[i]->id, outputs[i]->description);
113 /* TODO: Error handling. */
116 printf("Supported protocol decoders:\n");
117 for (l = srd_list_decoders(); l; l = l->next) {
119 printf(" %-20s %s\n", dec->id, dec->desc);
126 static void print_device_line(struct sr_device *device)
128 struct sr_device_instance *sdi;
130 sdi = device->plugin->get_device_info(device->plugin_index, SR_DI_INSTANCE);
132 if (sdi->vendor && sdi->vendor[0])
133 printf("%s ", sdi->vendor);
134 if (sdi->model && sdi->model[0])
135 printf("%s ", sdi->model);
136 if (sdi->version && sdi->version[0])
137 printf("%s ", sdi->version);
139 printf("with %d probes", g_slist_length(device->probes));
143 static void show_device_list(void)
145 struct sr_device *device, *demo_device;
150 devices = sr_device_list();
152 if (g_slist_length(devices) == 0)
155 printf("The following devices were found:\nID Device\n");
157 for (l = devices; l; l = l->next) {
159 if (strstr(device->plugin->name, "demo")) {
160 demo_device = device;
163 printf("%-3d ", devcnt++);
164 print_device_line(device);
168 print_device_line(demo_device);
172 static void show_device_detail(void)
174 struct sr_device *device;
175 struct sr_hwcap_option *hwo;
176 struct sr_samplerates *samplerates;
177 int cap, *capabilities, i;
178 char *s, *title, *charopts, **stropts;
180 device = parse_devicestring(opt_device);
182 printf("No such device. Use -D to list all devices.\n");
186 print_device_line(device);
188 if ((charopts = (char *)device->plugin->get_device_info(
189 device->plugin_index, SR_DI_TRIGGER_TYPES))) {
190 printf("Supported triggers: ");
192 printf("%c ", *charopts);
198 title = "Supported options:\n";
199 capabilities = device->plugin->get_capabilities();
200 for (cap = 0; capabilities[cap]; cap++) {
201 if (!(hwo = sr_find_hwcap_option(capabilities[cap])))
209 if (hwo->capability == SR_HWCAP_PATTERN_MODE) {
210 printf(" %s", hwo->shortname);
211 stropts = (char **)device->plugin->get_device_info(
212 device->plugin_index, SR_DI_PATTERNMODES);
217 printf(" - supported modes:\n");
218 for (i = 0; stropts[i]; i++)
219 printf(" %s\n", stropts[i]);
220 } else if (hwo->capability == SR_HWCAP_SAMPLERATE) {
221 printf(" %s", hwo->shortname);
222 /* Supported samplerates */
223 samplerates = device->plugin->get_device_info(
224 device->plugin_index, SR_DI_SAMPLERATES);
230 if (samplerates->step) {
232 if (!(s = sr_samplerate_string(samplerates->low)))
237 if (!(s = sr_samplerate_string(samplerates->high)))
242 if (!(s = sr_samplerate_string(samplerates->step)))
244 printf(" in steps of %s)\n", s);
247 printf(" - supported samplerates:\n");
248 for (i = 0; samplerates->list[i]; i++) {
249 printf(" %7s\n", sr_samplerate_string(samplerates->list[i]));
253 printf(" %s\n", hwo->shortname);
258 static void datafeed_in(struct sr_device *device, struct sr_datafeed_packet *packet)
260 static struct sr_output *o = NULL;
261 static int probelist[65] = { 0 };
262 static uint64_t received_samples = 0;
263 static int unitsize = 0;
264 static int triggered = 0;
265 static FILE *outfile = NULL;
266 struct sr_probe *probe;
267 struct sr_datafeed_header *header;
268 struct sr_datafeed_logic *logic;
269 int num_enabled_probes, sample_size, ret, i;
270 uint64_t output_len, filter_out_len;
271 char *output_buf, *filter_out;
273 /* If the first packet to come in isn't a header, don't even try. */
274 if (packet->type != SR_DF_HEADER && o == NULL)
278 switch (packet->type) {
280 g_message("cli: Received SR_DF_HEADER");
281 /* Initialize the output module. */
282 if (!(o = malloc(sizeof(struct sr_output)))) {
283 printf("Output module malloc failed.\n");
286 o->format = output_format;
288 o->param = output_format_param;
289 if (o->format->init) {
290 if (o->format->init(o) != SR_OK) {
291 printf("Output format initialization failed.\n");
296 header = packet->payload;
297 num_enabled_probes = 0;
298 for (i = 0; i < header->num_logic_probes; i++) {
299 probe = g_slist_nth_data(device->probes, i);
301 probelist[num_enabled_probes++] = probe->index;
303 /* How many bytes we need to store num_enabled_probes bits */
304 unitsize = (num_enabled_probes + 7) / 8;
307 if (opt_output_file) {
308 if (default_output_format) {
309 /* output file is in session format, which means we'll
310 * dump everything in the datastore as it comes in,
311 * and save from there after the session. */
313 ret = sr_datastore_new(unitsize, &(device->datastore));
315 printf("Failed to create datastore.\n");
319 /* saving to a file in whatever format was set
320 * with --format, so all we need is a filehandle */
321 outfile = g_fopen(opt_output_file, "wb");
325 srd_session_start(device->plugin->name, unitsize,
326 time(NULL), header->samplerate);
329 g_message("cli: Received SR_DF_END");
331 g_message("cli: double end!");
334 if (o->format->event) {
335 o->format->event(o, SR_DF_END, &output_buf, &output_len);
338 fwrite(output_buf, 1, output_len, outfile);
343 if (limit_samples && received_samples < limit_samples)
344 printf("Device only sent %" PRIu64 " samples.\n",
347 printf("Device stopped after %" PRIu64 " samples.\n",
350 if (outfile && outfile != stdout)
356 g_message("cli: received SR_DF_TRIGGER at %"PRIu64" ms",
357 packet->timeoffset / 1000000);
358 if (o->format->event)
359 o->format->event(o, SR_DF_TRIGGER, &output_buf,
364 logic = packet->payload;
365 sample_size = logic->unitsize;
366 g_message("cli: received SR_DF_LOGIC at %f ms duration %f ms, %"PRIu64" bytes",
367 packet->timeoffset / 1000000.0, packet->duration / 1000000.0,
374 /* not supporting anything but SR_DF_LOGIC for now */
376 if (sample_size == -1 || logic->length == 0)
379 /* Don't store any samples until triggered. */
380 if (opt_wait_trigger && !triggered)
383 if (limit_samples && received_samples >= limit_samples)
386 /* TODO: filters only support SR_DF_LOGIC */
387 ret = sr_filter_probes(sample_size, unitsize, probelist,
388 logic->data, logic->length,
389 &filter_out, &filter_out_len);
393 /* what comes out of the filter is guaranteed to be packed into the
394 * minimum size needed to support the number of samples at this sample
395 * size. however, the driver may have submitted too much -- cut off
396 * the buffer of the last packet according to the sample limit.
398 if (limit_samples && (received_samples + logic->length / sample_size >
399 limit_samples * sample_size))
400 filter_out_len = limit_samples * sample_size - received_samples;
402 if (device->datastore)
403 sr_datastore_put(device->datastore, filter_out,
404 filter_out_len, sample_size, probelist);
406 if (opt_output_file && default_output_format)
407 /* saving to a session file, don't need to do anything else
408 * to this data for now. */
412 if (srd_session_feed(packet->timeoffset, packet->duration,
413 (uint8_t*)filter_out, filter_out_len) != SRD_OK)
417 if (o->format->data && packet->type == o->format->df_type)
418 o->format->data(o, filter_out, filter_out_len, &output_buf, &output_len);
420 fwrite(output_buf, 1, output_len, outfile);
427 received_samples += logic->length / sample_size;
431 /* Register the given PDs for this session. */
432 /* Accepts a string of the form: "spi:sck=3:sdata=4,spi:sck=3:sdata=5"
433 * That will instantiate two SPI decoders on the clock but different data
436 /* TODO: Support both serial PDs and nested PDs. Parallel PDs even? */
437 /* TODO: Only register here, run in streaming fashion later/elsewhere. */
438 static int register_pds(struct sr_device *device, const char *pdstring)
440 char **pdtokens, **pdtok;
442 /* Avoid compiler warnings. */
445 pdtokens = g_strsplit(pdstring, ",", -1);
447 for (pdtok = pdtokens; *pdtok; pdtok++) {
448 struct srd_decoder_instance *di;
450 /* Configure probes from command line */
451 char **optokens, **optok;
452 optokens = g_strsplit(*pdtok, ":", -1);
453 di = srd_instance_new(optokens[0]);
455 fprintf(stderr, "Failed to instantiate PD: %s\n",
457 g_strfreev(optokens);
458 g_strfreev(pdtokens);
461 for (optok = optokens+1; *optok; optok++) {
462 char probe[strlen(*optok)];
464 if(sscanf(*optok, "%[^=]=%d", probe, &num) == 2)
465 srd_instance_set_probe(di, probe, num);
466 /* TODO: else fail somehow */
468 g_strfreev(optokens);
470 /* TODO: Handle errors. */
473 g_strfreev(pdtokens);
478 static int select_probes(struct sr_device *device)
480 struct sr_probe *probe;
488 * This only works because a device by default initializes
489 * and enables all its probes.
491 max_probes = g_slist_length(device->probes);
492 probelist = parse_probestring(max_probes, opt_probes);
497 for (i = 0; i < max_probes; i++) {
499 sr_device_probe_name(device, i + 1, probelist[i]);
500 g_free(probelist[i]);
502 probe = sr_device_probe_find(device, i + 1);
503 probe->enabled = FALSE;
512 * Return the input file format which the CLI tool should use.
514 * If the user specified -I / --input-format, use that one. Otherwise, try to
515 * autodetect the format as good as possible. Failing that, return NULL.
517 * @param filename The filename of the input file. Must not be NULL.
518 * @param opt The -I / --input-file option the user specified (or NULL).
520 * @return A pointer to the 'struct sr_input_format' that should be used,
521 * or NULL if no input format was selected or auto-detected.
523 static struct sr_input_format *determine_input_file_format(
524 const char *filename, const char *opt)
527 struct sr_input_format **inputs;
529 /* If there are no input formats, return NULL right away. */
530 inputs = sr_input_list();
532 fprintf(stderr, "cli: %s: no supported input formats "
533 "available", __func__);
537 /* If the user specified -I / --input-format, use that one. */
539 for (i = 0; inputs[i]; i++) {
540 if (strcasecmp(inputs[i]->id, opt_input_format))
542 printf("Using user-specified input file format"
543 " '%s'.\n", inputs[i]->id);
547 /* The user specified an unknown input format, return NULL. */
548 fprintf(stderr, "Error: Specified input file format '%s' is "
549 "unknown.\n", opt_input_format);
553 /* Otherwise, try to find an input module that can handle this file. */
554 for (i = 0; inputs[i]; i++) {
555 if (inputs[i]->format_match(filename))
559 /* Return NULL if no input module wanted to touch this. */
561 fprintf(stderr, "Error: No matching input module found.\n");
565 printf("Using input file format '%s'.\n", inputs[i]->id);
569 static void load_input_file_format(void)
573 struct sr_input_format *input_format;
575 input_format = determine_input_file_format(opt_input_file,
578 fprintf(stderr, "Error: Couldn't detect input file format.\n");
582 if (stat(opt_input_file, &st) == -1) {
583 printf("Failed to load %s: %s\n", opt_input_file,
588 /* Initialize the input module. */
589 if (!(in = malloc(sizeof(struct sr_input)))) {
590 printf("Failed to allocate input module.\n");
593 in->format = input_format;
594 in->param = input_format_param;
595 if (in->format->init) {
596 if (in->format->init(in) != SR_OK) {
597 printf("Input format init failed.\n");
602 if (select_probes(in->vdevice) > 0)
606 sr_session_datafeed_callback_add(datafeed_in);
607 if (sr_session_device_add(in->vdevice) != SR_OK) {
608 printf("Failed to use device.\n");
609 sr_session_destroy();
613 input_format->loadfile(in, opt_input_file);
614 if (opt_output_file && default_output_format) {
615 if (sr_session_save(opt_output_file) != SR_OK)
616 printf("Failed to save session.\n");
618 sr_session_destroy();
622 static void load_input_file(void)
625 if (sr_session_load(opt_input_file) == SR_OK) {
626 /* sigrok session file */
627 sr_session_datafeed_callback_add(datafeed_in);
633 /* fall back on input modules */
634 load_input_file_format();
639 int num_real_devices(void)
641 struct sr_device *device;
646 devices = sr_device_list();
647 for (l = devices; l; l = l->next) {
649 if (!strstr(device->plugin->name, "demo"))
656 int set_device_options(struct sr_device *device, GHashTable *args)
665 g_hash_table_iter_init(&iter, args);
666 while (g_hash_table_iter_next(&iter, &key, &value)) {
668 for (i = 0; sr_hwcap_options[i].capability; i++) {
669 if (strcmp(sr_hwcap_options[i].shortname, key))
671 if ((value == NULL) &&
672 (sr_hwcap_options[i].type != SR_T_BOOL)) {
673 printf("Option '%s' needs a value.\n", (char *)key);
677 switch (sr_hwcap_options[i].type) {
679 ret = sr_parse_sizestring(value, &tmp_u64);
682 ret = device->plugin-> set_configuration(device-> plugin_index,
683 sr_hwcap_options[i]. capability, &tmp_u64);
686 ret = device->plugin-> set_configuration(device-> plugin_index,
687 sr_hwcap_options[i]. capability, value);
693 tmp_bool = sr_parse_boolstring(value);
694 ret = device->plugin-> set_configuration(device-> plugin_index,
695 sr_hwcap_options[i]. capability,
696 GINT_TO_POINTER(tmp_bool));
703 printf("Failed to set device option '%s'.\n", (char *)key);
710 printf("Unknown device option '%s'.\n", (char *) key);
718 static void run_session(void)
720 struct sr_device *device;
722 int num_devices, max_probes, *capabilities, i;
723 uint64_t tmp_u64, time_msec;
724 char **probelist, *devspec;
728 devargs = parse_generic_arg(opt_device);
729 devspec = g_hash_table_lookup(devargs, "sigrok_key");
730 device = parse_devicestring(devspec);
732 g_warning("Device not found.");
735 g_hash_table_remove(devargs, "sigrok_key");
737 num_devices = num_real_devices();
738 if (num_devices == 1) {
739 /* No device specified, but there is only one. */
741 device = parse_devicestring("0");
742 } else if (num_devices == 0) {
743 printf("No devices found.\n");
746 printf("%d devices found, please select one.\n", num_devices);
752 sr_session_datafeed_callback_add(datafeed_in);
754 if (sr_session_device_add(device) != SR_OK) {
755 printf("Failed to use device.\n");
756 sr_session_destroy();
761 if (set_device_options(device, devargs) != SR_OK) {
762 sr_session_destroy();
765 g_hash_table_destroy(devargs);
768 if (select_probes(device) != SR_OK)
771 if (opt_continuous) {
772 capabilities = device->plugin->get_capabilities();
773 if (!sr_find_hwcap(capabilities, SR_HWCAP_CONTINUOUS)) {
774 printf("This device does not support continuous sampling.");
775 sr_session_destroy();
781 probelist = sr_parse_triggerstring(device, opt_triggers);
783 sr_session_destroy();
787 max_probes = g_slist_length(device->probes);
788 for (i = 0; i < max_probes; i++) {
790 sr_device_trigger_set(device, i + 1, probelist[i]);
791 g_free(probelist[i]);
798 time_msec = sr_parse_timestring(opt_time);
799 if (time_msec == 0) {
800 printf("Invalid time '%s'\n", opt_time);
801 sr_session_destroy();
805 capabilities = device->plugin->get_capabilities();
806 if (sr_find_hwcap(capabilities, SR_HWCAP_LIMIT_MSEC)) {
807 if (device->plugin->set_configuration(device->plugin_index,
808 SR_HWCAP_LIMIT_MSEC, &time_msec) != SR_OK) {
809 printf("Failed to configure time limit.\n");
810 sr_session_destroy();
815 /* time limit set, but device doesn't support this...
816 * convert to samples based on the samplerate.
819 if (sr_device_has_hwcap(device, SR_HWCAP_SAMPLERATE)) {
820 tmp_u64 = *((uint64_t *) device->plugin->get_device_info(
821 device->plugin_index, SR_DI_CUR_SAMPLERATE));
822 limit_samples = tmp_u64 * time_msec / (uint64_t) 1000;
824 if (limit_samples == 0) {
825 printf("Not enough time at this samplerate.\n");
826 sr_session_destroy();
830 if (device->plugin->set_configuration(device->plugin_index,
831 SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK) {
832 printf("Failed to configure time-based sample limit.\n");
833 sr_session_destroy();
840 if ((sr_parse_sizestring(opt_samples, &limit_samples) != SR_OK)
841 || (device->plugin->set_configuration(device->plugin_index,
842 SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK)) {
843 printf("Failed to configure sample limit.\n");
844 sr_session_destroy();
849 if (device->plugin->set_configuration(device->plugin_index,
850 SR_HWCAP_PROBECONFIG, (char *)device->probes) != SR_OK) {
851 printf("Failed to configure probes.\n");
852 sr_session_destroy();
856 if (sr_session_start() != SR_OK) {
857 printf("Failed to start session.\n");
858 sr_session_destroy();
870 if (opt_output_file && default_output_format) {
871 if (sr_session_save(opt_output_file) != SR_OK)
872 printf("Failed to save session.\n");
874 sr_session_destroy();
878 static void logger(const gchar *log_domain, GLogLevelFlags log_level,
879 const gchar *message, gpointer user_data)
881 /* Avoid compiler warnings. */
886 * All messages, warnings, errors etc. go to stderr (not stdout) in
887 * order to not mess up the CLI tool data output, e.g. VCD output.
889 if (log_level & (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING)) {
890 fprintf(stderr, "%s\n", message);
893 if ((log_level & G_LOG_LEVEL_MESSAGE && debug == 1)
895 printf("%s\n", message);
901 int main(int argc, char **argv)
903 struct sr_output_format **outputs;
904 GOptionContext *context;
912 g_log_set_default_handler(logger, NULL);
913 if (getenv("SIGROK_DEBUG"))
914 debug = strtol(getenv("SIGROK_DEBUG"), NULL, 10);
917 context = g_option_context_new(NULL);
918 g_option_context_add_main_entries(context, optargs, NULL);
920 if (!g_option_context_parse(context, &argc, &argv, &error)) {
921 g_warning("%s", error->message);
925 /* Set the loglevel (amount of messages to output) for libsigrok. */
926 if (sr_set_loglevel(opt_loglevel) != SR_OK) {
927 fprintf(stderr, "cli: %s: sr_set_loglevel(%d) failed\n",
928 __func__, opt_loglevel);
932 if (sr_init() != SR_OK)
936 /* TODO: Error handling. */
938 register_pds(NULL, opt_pds);
942 opt_format = DEFAULT_OUTPUT_FORMAT;
943 /* we'll need to remember this, so when saving to an file
944 * later, sigrok session format will be used.
946 default_output_format = TRUE;
948 fmtargs = parse_generic_arg(opt_format);
949 fmtspec = g_hash_table_lookup(fmtargs, "sigrok_key");
951 printf("Invalid output format.\n");
954 outputs = sr_output_list();
955 for (i = 0; outputs[i]; i++) {
956 if (strcmp(outputs[i]->id, fmtspec))
958 g_hash_table_remove(fmtargs, "sigrok_key");
959 output_format = outputs[i];
960 g_hash_table_iter_init(&iter, fmtargs);
961 while (g_hash_table_iter_next(&iter, &key, &value)) {
962 /* only supporting one parameter per output module
963 * for now, and only its value */
964 output_format_param = g_strdup(value);
969 if (!output_format) {
970 printf("invalid output format %s\n", opt_format);
976 else if (opt_list_devices)
978 else if (opt_input_file)
980 else if (opt_samples || opt_time || opt_continuous)
983 show_device_detail();
985 printf("%s", g_option_context_get_help(context, TRUE, NULL));
990 g_option_context_free(context);
991 g_hash_table_destroy(fmtargs);