Skip to content

Commit

Permalink
Merge pull request #1557 from stefanrueger/programmer-not-recognised
Browse files Browse the repository at this point in the history
Test programmers for prog_modes and type
  • Loading branch information
stefanrueger authored Nov 11, 2023
2 parents 0fe1bf0 + 84e7ff1 commit 9596faa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,15 @@ static int dev_opt(const char *str) {
}


static void programmer_not_found(const char *programmer) {
static void programmer_not_found(const char *programmer, PROGRAMMER *pgm) {
msg_error("\n");
if(programmer && *programmer)
pmsg_error("cannot find programmer id %s\n", programmer);
else {
if(programmer && *programmer) {
if(!pgm || !pgm->id || !lsize(pgm->id))
pmsg_error("cannot find programmer id %s\n", programmer);
else
pmsg_error("programmer %s lacks %s setting\n", programmer,
!pgm->prog_modes? "prog_modes": !pgm->initpgm? "type": "some");
} else {
pmsg_error("no programmer has been specified on the command line or in the\n");
imsg_error("config file(s); specify one using the -c option and try again\n");
}
Expand Down Expand Up @@ -1028,6 +1032,7 @@ int main(int argc, char * argv [])
exit(0);
}

PROGRAMMER *dry = locate_programmer(programmers, "dryrun");
for(LNODEID ln1 = lfirst(part_list); ln1; ln1 = lnext(ln1)) {
AVRPART *p = ldata(ln1);
for(LNODEID ln2 = lfirst(programmers); ln2; ln2 = lnext(ln2)) {
Expand All @@ -1036,7 +1041,7 @@ int main(int argc, char * argv [])
continue;
const char *pnam = pgm->id? ldata(lfirst(pgm->id)): "???";
int pm = pgm->prog_modes & p->prog_modes;
if((pm & (pm-1)) && !str_eq(pnam, "dryrun"))
if((pm & (pm-1)) && !str_eq(pnam, "dryrun") && !(dry && pgm->initpgm == dry->initpgm))
pmsg_warning("%s and %s share multiple modes (%s)\n", pnam, p->desc, avr_prog_modes(pm));
}
}
Expand All @@ -1057,7 +1062,7 @@ int main(int argc, char * argv [])
if(pgmid && *pgmid && explicit_c) {
PROGRAMMER *pgm = locate_programmer_set(programmers, pgmid, &pgmid);
if(!pgm || !is_programmer(pgm)) {
programmer_not_found(pgmid);
programmer_not_found(pgmid, pgm);
exit(1);
}
msg_error("\nValid parts for programmer %s are:\n", pgmid);
Expand Down Expand Up @@ -1100,13 +1105,13 @@ int main(int argc, char * argv [])
msg_notice("\n");

if(!pgmid || !*pgmid) {
programmer_not_found(NULL);
programmer_not_found(NULL, NULL);
exit(1);
}

pgm = locate_programmer_set(programmers, pgmid, &pgmid);
if (pgm == NULL || !is_programmer(pgm)) {
programmer_not_found(pgmid);
programmer_not_found(pgmid, pgm);
exit(1);
}

Expand Down

0 comments on commit 9596faa

Please sign in to comment.