Print -x help text when invalid extended option is passed

This commit is contained in:
MCUdude
2024-07-29 06:31:50 +02:00
parent cda52a3a06
commit c1a0378229
4 changed files with 71 additions and 57 deletions

View File

@@ -40,7 +40,7 @@
static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
const char *extended_param;
int attempts;
int rv = 0;
int rv = 0, help = 0;
for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) {
extended_param = ldata(ln);
@@ -57,17 +57,20 @@ static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
}
if (str_eq(extended_param, "help")) {
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xattempts=<n> Specify the number <n> of connection retry attempts\n");
msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n");
msg_error(" -xhelp Show this help menu and exit\n");
return LIBAVRDUDE_EXIT;
help = 1;
rv = LIBAVRDUDE_EXIT;
}
pmsg_error("invalid extended parameter %s\n", extended_param);
rv = -1;
if (!help) {
pmsg_error("invalid extended parameter %s\n", extended_param);
rv = -1;
}
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xattempts=<n> Specify the number <n> of connection retry attempts\n");
msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n");
msg_error(" -xhelp Show this help menu and exit\n");
return rv;
}
return rv;
}

View File

@@ -696,7 +696,7 @@ static int butterfly_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, con
static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
const char *extended_param;
int rv = 0;
int rv = 0, help = 0;
for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) {
extended_param = ldata(ln);
@@ -707,14 +707,18 @@ static int butterfly_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
}
if (str_eq(extended_param, "help")) {
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xautoreset Toggle RTS/DTR lines on port open to issue a hardware reset\n");
msg_error(" -xhelp Show this help menu and exit\n");
exit(0);
help = 1;
rv = LIBAVRDUDE_EXIT;
}
pmsg_error("invalid extended parameter %s\n", extended_param);
rv = -1;
if (!help) {
pmsg_error("invalid extended parameter %s\n", extended_param);
rv = -1;
}
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xautoreset Toggle RTS/DTR lines on port open to issue a hardware reset\n");
msg_error(" -xhelp Show this help menu and exit\n");
return rv;
}
return rv;

View File

@@ -640,15 +640,14 @@ static int stk500_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
return pgm->program_enable(pgm, p);
}
static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
{
LNODEID ln;
const char *extended_param;
int attempts;
int rv = 0;
static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
LNODEID ln;
const char *extended_param;
int attempts;
int rv = 0, help = 0;
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
extended_param = ldata(ln);
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
extended_param = ldata(ln);
if (sscanf(extended_param, "attempts=%i", &attempts) == 1) {
PDATA(pgm)->retry_attempts = attempts;
@@ -783,33 +782,37 @@ static int stk500_parseextparms(const PROGRAMMER *pgm, const LISTID extparms)
}
else if (str_eq(extended_param, "help")) {
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xattempts=<n> Specify the number <n> of connection retry attempts\n");
if (pgm->extra_features & HAS_VTARG_READ) {
msg_error(" -xvtarg Read target supply voltage\n");
}
if (pgm->extra_features & HAS_VTARG_ADJ) {
msg_error(" -xvtarg=<arg> Set target supply voltage\n");
}
if (pgm->extra_features & HAS_VAREF_ADJ) {
msg_error(" -xvaref Read analog reference voltage\n");
msg_error(" -xvaref=<arg> Set analog reference voltage\n");
}
if (pgm->extra_features & HAS_FOSC_ADJ) {
msg_error(" -xfosc Read oscillator clock frequency\n");
msg_error(" -xfosc=<arg>[M|k]|off Set oscillator clock frequency\n");
}
msg_error(" -xxtal=<arg>[M|k] Set programmer xtal frequency\n");
msg_error(" -xhelp Show this help menu and exit\n");
return LIBAVRDUDE_EXIT;;
help = 1;
rv = LIBAVRDUDE_EXIT;
}
pmsg_error("invalid extended parameter %s\n", extended_param);
rv = -1;
}
if (!help) {
pmsg_error("invalid extended parameter %s\n", extended_param);
rv = -1;
}
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xattempts=<n> Specify the number <n> of connection retry attempts\n");
if (pgm->extra_features & HAS_VTARG_READ) {
msg_error(" -xvtarg Read target supply voltage\n");
}
if (pgm->extra_features & HAS_VTARG_ADJ) {
msg_error(" -xvtarg=<arg> Set target supply voltage\n");
}
if (pgm->extra_features & HAS_VAREF_ADJ) {
msg_error(" -xvaref Read analog reference voltage\n");
msg_error(" -xvaref=<arg> Set analog reference voltage\n");
}
if (pgm->extra_features & HAS_FOSC_ADJ) {
msg_error(" -xfosc Read oscillator clock frequency\n");
msg_error(" -xfosc=<arg>[M|k]|off Set oscillator clock frequency\n");
}
msg_error(" -xxtal=<arg>[M|k] Set programmer xtal frequency\n");
msg_error(" -xhelp Show this help menu and exit\n");
return rv;
}
return rv;
}
return rv;
}
static void stk500_disable(const PROGRAMMER *pgm) {
unsigned char buf[16];

View File

@@ -83,7 +83,7 @@ static void wiring_teardown(PROGRAMMER *pgm) {
static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
LNODEID ln;
const char *extended_param, *errstr;
int rv = 0;
int rv = 0, help = 0;
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
extended_param = ldata(ln);
@@ -113,16 +113,20 @@ static int wiring_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) {
continue;
}
else if (str_eq(extended_param, "help")) {
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xsnooze=<n> Wait snooze <n> ms before protocol sync after port open\n");
msg_error(" -xdelay=<n> Add delay [n] ms after reset, can be negative\n");
msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n");
msg_error(" -xhelp Show this help menu and exit\n");
return LIBAVRDUDE_EXIT;;
help = 1;
rv = LIBAVRDUDE_EXIT;
}
pmsg_error("invalid extended parameter %s\n", extended_param);
rv = -1;
if (!help) {
pmsg_error("invalid extended parameter %s\n", extended_param);
rv = -1;
}
msg_error("%s -c %s extended options:\n", progname, pgmid);
msg_error(" -xsnooze=<n> Wait snooze <n> ms before protocol sync after port open\n");
msg_error(" -xdelay=<n> Add delay [n] ms after reset, can be negative\n");
msg_error(" -xnoautoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n");
msg_error(" -xhelp Show this help menu and exit\n");
return rv;
}
return rv;