diff options
author | Bdale Garbee <bdale@gag.com> | 2009-08-18 18:09:38 -0600 |
---|---|---|
committer | Bdale Garbee <bdale@gag.com> | 2009-08-18 18:09:38 -0600 |
commit | 4685fc541466afbeefc151bcb64cd054739c048b (patch) | |
tree | d7e0f521bd51897a59dd9c355d74218132da4b75 /ao-tools/ao-eeprom/ao-eeprom.c | |
parent | 1c2a0b6653623b689d68d7349a6b2dce3e20a4a6 (diff) | |
parent | c29275b72438637d46d7a50742882d2736eb176a (diff) |
Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
Conflicts:
ao-tools/ao-bitbang/Makefile.am
ao-tools/ao-eeprom/Makefile.am
ao-tools/ao-load/Makefile.am
ao-tools/ao-load/ao-load.c
ao-tools/ao-rawload/Makefile.am
Diffstat (limited to 'ao-tools/ao-eeprom/ao-eeprom.c')
-rw-r--r-- | ao-tools/ao-eeprom/ao-eeprom.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/ao-tools/ao-eeprom/ao-eeprom.c b/ao-tools/ao-eeprom/ao-eeprom.c index 399732d9..726cc22c 100644 --- a/ao-tools/ao-eeprom/ao-eeprom.c +++ b/ao-tools/ao-eeprom/ao-eeprom.c @@ -18,10 +18,23 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> +#include <getopt.h> #include "cc-usb.h" #define NUM_BLOCK 512 +static const struct option options[] = { + { .name = "tty", .has_arg = 1, .val = 'T' }, + { 0, 0, 0, 0}, +}; + +static void usage(char *program) +{ + fprintf(stderr, "usage: %s [--tty <tty-name>]\n", program); + exit(1); +} + int main (int argc, char **argv) { @@ -31,10 +44,26 @@ main (int argc, char **argv) uint8_t *b; int i, j; uint32_t addr; - char *tty; + char *tty = NULL; + int c; - tty = getenv("CCDBG_TTY"); + while ((c = getopt_long(argc, argv, "T:", options, NULL)) != -1) { + switch (c) { + case 'T': + tty = optarg; + break; + default: + usage(argv[0]); + break; + } + } + if (!tty) + tty = getenv("ALTOS_TTY"); + if (!tty) + tty="/dev/ttyACM0"; cc = cc_usb_open(tty); + if (!cc) + exit(1); for (block = 0; block < NUM_BLOCK; block++) { cc_queue_read(cc, bytes, sizeof (bytes)); cc_usb_printf(cc, "e %x\n", block); |