Add port name defaults to the config file instead of hard-coding.

This adds 'default_parallel' and 'default_serial' keywords to the
grammar, which take quoted string arguments.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@214 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Brian S. Dean 2003-02-21 18:46:51 +00:00
parent b33a87868e
commit 39e35145fa
6 changed files with 51 additions and 7 deletions

View File

@ -169,6 +169,13 @@
#define AT89S52 0xE1
#
# Overall avrdude defaults
#
default_parallel = "/dev/ppi0";
default_serial = "/dev/cuaa0";
#
# PROGRAMMER DEFINITIONS
#

View File

@ -30,6 +30,9 @@
#include "config.h"
#include "config_gram.h"
char default_parallel[PATH_MAX];
char default_serial[PATH_MAX];
char string_buf[MAX_STR_CONST];
char *string_buf_ptr;

View File

@ -53,6 +53,10 @@ extern int lineno;
extern char * infile;
extern LISTID string_list;
extern LISTID number_list;
extern char default_parallel[];
extern char default_serial[];
#if !defined(HAS_YYSTYPE)
#define YYSTYPE struct token_t *

View File

@ -67,6 +67,8 @@ static int parse_cmdbits(OPCODE * op);
%token K_BUFF
%token K_CHIP_ERASE_DELAY
%token K_DEDICATED
%token K_DEFAULT_PARALLEL
%token K_DEFAULT_SERIAL
%token K_DESC
%token K_DEVICECODE
%token K_EEPROM
@ -126,7 +128,20 @@ config :
def :
prog_def TKN_SEMI |
part_def TKN_SEMI
part_def TKN_SEMI |
K_DEFAULT_PARALLEL TKN_EQUAL TKN_STRING TKN_SEMI {
strncpy(default_parallel, $3->value.string, PATH_MAX);
default_parallel[PATH_MAX-1] = 0;
free_token($3);
} |
K_DEFAULT_SERIAL TKN_EQUAL TKN_STRING TKN_SEMI {
strncpy(default_serial, $3->value.string, PATH_MAX);
default_serial[PATH_MAX-1] = 0;
free_token($3);
}
;

View File

@ -121,6 +121,8 @@ bs2 { yylval=NULL; return K_BS2; }
buff { yylval=NULL; return K_BUFF; }
chip_erase_delay { yylval=NULL; return K_CHIP_ERASE_DELAY; }
desc { yylval=NULL; return K_DESC; }
default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; }
default_serial { yylval=NULL; return K_DEFAULT_SERIAL; }
devicecode { yylval=NULL; return K_DEVICECODE; }
eeprom { yylval=NULL; return K_EEPROM; }
errled { yylval=NULL; return K_ERRLED; }

25
main.c
View File

@ -86,9 +86,6 @@
#include "term.h"
#define DEFAULT_PARALLEL "/dev/ppi0"
#define DEFAULT_SERIAL "/dev/cuaa0"
char * version = "3.1.0";
int verbose; /* verbose output */
@ -308,11 +305,14 @@ int main(int argc, char * argv [])
else
progname = argv[0];
default_parallel[0] = 0;
default_serial[0] = 0;
init_config();
partdesc = NULL;
readorwrite = 0;
port = DEFAULT_PARALLEL;
port = default_parallel;
outputf = NULL;
inputf = NULL;
doread = 1;
@ -381,8 +381,8 @@ int main(int argc, char * argv [])
case 'c': /* pin configuration */
pinconfig = optarg;
if (strcmp(pinconfig, "stk500") == 0) {
if (port == DEFAULT_PARALLEL) {
port = DEFAULT_SERIAL;
if (port == default_parallel) {
port = default_serial;
}
}
break;
@ -613,6 +613,19 @@ int main(int argc, char * argv [])
/*
* open the programmer
*/
if (port[0] == 0) {
fprintf(stderr, "\n%s: no port has been specified on the command or the "
"config file\n",
progname);
fprintf(stderr, "%sSpecify a port using the -P option and try again\n\n",
progbuf);
exit(1);
}
if (verbose) {
fprintf(stderr, "%sUsing Port : %s\n", progbuf, port);
}
pgm->open(pgm, port);
if (verbose) {