projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use --tty/-T on command line to specify target device
[fw/altos]
/
ao-tools
/
ao-eeprom
/
ao-eeprom.c
diff --git
a/ao-tools/ao-eeprom/ao-eeprom.c
b/ao-tools/ao-eeprom/ao-eeprom.c
index 399732d9f1fea9b9b7e230ac782c52943035d440..726cc22cafd0e0c1a8becbe4ef52ab03c5e1b547 100644
(file)
--- 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 <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
#include "cc-usb.h"
#define NUM_BLOCK 512
#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)
{
int
main (int argc, char **argv)
{
@@
-31,10
+44,26
@@
main (int argc, char **argv)
uint8_t *b;
int i, j;
uint32_t addr;
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);
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);
for (block = 0; block < NUM_BLOCK; block++) {
cc_queue_read(cc, bytes, sizeof (bytes));
cc_usb_printf(cc, "e %x\n", block);