From: Keith Packard Date: Fri, 17 Apr 2009 17:10:47 +0000 (-0700) Subject: Run-time selection between cp2103 and cc1111 X-Git-Tag: 0.5~58^2~8 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=26095fc0511ee0d5213f038986032f7c59964cf0;ds=sidebyside Run-time selection between cp2103 and cc1111 --- diff --git a/lib/cc-usb.c b/lib/cc-usb.c index 09b06bb5..9df2e312 100644 --- a/lib/cc-usb.c +++ b/lib/cc-usb.c @@ -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); diff --git a/lib/cc-usb.h b/lib/cc-usb.h index 2adccb93..d7acfbd2 100644 --- a/lib/cc-usb.h +++ b/lib/cc-usb.h @@ -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); diff --git a/lib/ccdbg-io.c b/lib/ccdbg-io.c index acd44f10..9c6693cd 100644 --- a/lib/ccdbg-io.c +++ b/lib/ccdbg-io.c @@ -21,18 +21,20 @@ #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) {