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 09b06bb..9df2e31 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 2adccb9..d7acfbd 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 acd44f1..9c6693c 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) {