summaryrefslogtreecommitdiff
path: root/ao-tools/lib/ccdbg-io.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-08-18 12:19:31 -0700
committerKeith Packard <keithp@keithp.com>2009-08-18 14:39:15 -0700
commit9b03d620722dc54630539afba40720c30de69b2d (patch)
tree49450794239dfcfaab32190ccb7c81e2e71c2bbc /ao-tools/lib/ccdbg-io.c
parent7c790fe859dff062692964338091ffbbcdf63257 (diff)
Use --tty/-T on command line to specify target device
Also, use the ALTOS_TTY environment variable in all tools. Note that the magic value of "BITBANG" switches the library to connecting through a CP2103 instead. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao-tools/lib/ccdbg-io.c')
-rw-r--r--ao-tools/lib/ccdbg-io.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/ao-tools/lib/ccdbg-io.c b/ao-tools/lib/ccdbg-io.c
index 9c6693cd..d3f87274 100644
--- a/ao-tools/lib/ccdbg-io.c
+++ b/ao-tools/lib/ccdbg-io.c
@@ -22,25 +22,32 @@
#include "cc-bitbang.h"
struct ccdbg *
-ccdbg_open(void)
+ccdbg_open(char *tty)
{
struct ccdbg *dbg;
- char *tty;
dbg = calloc(sizeof (struct ccdbg), 1);
if (!dbg) {
perror("calloc");
return NULL;
}
- tty = getenv("CCDBG_TTY");
- if (!tty || tty[0] == '/')
- dbg->usb = cc_usb_open(tty);
- if (!dbg->usb) {
+ if (!tty)
+ tty = getenv("ALTOS_TTY");
+ if (!tty)
+ tty="/dev/ttyACM0";
+
+ if (!strcmp(tty, "BITBANG")) {
dbg->bb = cc_bitbang_open();
if (!dbg->bb) {
free(dbg);
return NULL;
}
+ } else {
+ dbg->usb = cc_usb_open(tty);
+ if (!dbg->usb) {
+ free(dbg);
+ return NULL;
+ }
}
return dbg;
}