Run-time selection between cp2103 and cc1111
authorKeith Packard <keithp@keithp.com>
Fri, 17 Apr 2009 17:10:47 +0000 (10:10 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 17 Apr 2009 17:10:47 +0000 (10:10 -0700)
lib/cc-usb.c
lib/cc-usb.h
lib/ccdbg-io.c

index 09b06bb54054b2e71c2e5c8c7b4ea8b175fce2f0..9df2e31224554e944c47f33bbb1e82f7632b80af 100644 (file)
@@ -317,13 +317,11 @@ cc_usb_reset(struct cc_usb *cc)
 static struct termios  save_termios;
 
 struct cc_usb *
-cc_usb_open(void)
+cc_usb_open(char *tty)
 {
        struct cc_usb   *cc;
-       char            *tty;
        struct termios  termios;
        
-       tty = getenv("CCDBG_TTY");
        if (!tty)
                tty = DEFAULT_TTY;
        cc = calloc (sizeof (struct cc_usb), 1);
index 2adccb933a1b4536c2224cc70a4d2d1f085b85c9..d7acfbd2be1b70a1e59283b2af582e868c0db701 100644 (file)
@@ -24,7 +24,7 @@
 struct cc_usb;
 
 struct cc_usb *
-cc_usb_open(void);
+cc_usb_open(char *tty);
 
 void
 cc_usb_close(struct cc_usb *cc);
index acd44f10ac13cbb0ea51aef051403ec16ba7ae82..9c6693cdbe0ad5a0698cdcfc8b214761b877b148 100644 (file)
 #include "cc-usb.h"
 #include "cc-bitbang.h"
 
-
 struct ccdbg *
 ccdbg_open(void)
 {
        struct ccdbg *dbg;
+       char *tty;
 
        dbg = calloc(sizeof (struct ccdbg), 1);
        if (!dbg) {
                perror("calloc");
                return NULL;
        }
-       dbg->usb = cc_usb_open();
+       tty = getenv("CCDBG_TTY");
+       if (!tty || tty[0] == '/')
+               dbg->usb = cc_usb_open(tty);
        if (!dbg->usb) {
                dbg->bb = cc_bitbang_open();
                if (!dbg->bb) {