From 69ee8dfec7c8e0cc006420922faa4b326f10c63a Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 28 Jun 2012 01:21:47 -0300 Subject: [PATCH] tools/antorcha.c (usage): explain options and show parameter names and defaults --- tools/antorcha.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/antorcha.c b/tools/antorcha.c index 398656c..abcd3ab 100644 --- a/tools/antorcha.c +++ b/tools/antorcha.c @@ -488,15 +488,37 @@ quit: /* ----- Command-line processing ------------------------------------------- */ +static unsigned get_int(uint8_t *p, int n) +{ + unsigned v = 0; + int i; + + for (i = 0; i != n; i++) + v |= *p++ << (i*8); + return v; +} + + static void usage(const char *name) { + const struct map *m; + fprintf(stderr, "usage: %s [-d] [param=value ...] image_file\n" "%6s %s [-d] -F firmware_file\n" "%6s %s [-d] -P\n" "%6s %s [-d] -R\n" - "%6s %s [-d] -S [-S]\n" + "%6s %s [-d] -S [-S]\n\n" +" -F file firmware upload\n" +" -P ping (version query)\n" +" -R reset\n" +" -S sample with output on stdout. Exit with ^C.\n" +" -S -S sample with graphical output. Exit with Q.\n\n" +"Parameters:\n" , name, "", name, "", name, "", name, "", name); + for (m = map; m->name; m++) + fprintf(stderr, " %s\t(default %u)\n", + m->name, get_int(m->p, m->bytes)); exit(1); }