Fix bug introduced in patch #8580 to allow usage with no -C option or -C ft[n]
This commit is contained in:
parent
7d9ee2694e
commit
d4c7ef19bf
65
ft245r.c
65
ft245r.c
|
@ -543,10 +543,8 @@ static const struct pin_checklist_t pin_checklist[] = {
|
||||||
static int ft245r_open(PROGRAMMER * pgm, char * port) {
|
static int ft245r_open(PROGRAMMER * pgm, char * port) {
|
||||||
int rv;
|
int rv;
|
||||||
int devnum = -1;
|
int devnum = -1;
|
||||||
char device[9] = "";
|
|
||||||
|
|
||||||
rv = pins_check(pgm,pin_checklist,sizeof(pin_checklist)/sizeof(pin_checklist[0]), true);
|
rv = pins_check(pgm,pin_checklist,sizeof(pin_checklist)/sizeof(pin_checklist[0]), true);
|
||||||
|
|
||||||
if(rv) {
|
if(rv) {
|
||||||
pgm->display(pgm, progbuf);
|
pgm->display(pgm, progbuf);
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -554,46 +552,33 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
|
||||||
|
|
||||||
strcpy(pgm->port, port);
|
strcpy(pgm->port, port);
|
||||||
|
|
||||||
// read device string cut after 8 chars (max. length of serial number)
|
if (strcmp(port, DEFAULT_USB) != 0) {
|
||||||
if ((sscanf(port, "usb:%8s", device) != 1)) {
|
if (strncasecmp("ft", port, 2) == 0) {
|
||||||
avrdude_message(MSG_INFO,
|
char* startptr = port + 2;
|
||||||
"%s: ft245r_open(): invalid device identifier '%8s'\n",
|
char* endptr = NULL;
|
||||||
progname, device);
|
devnum = strtol(startptr, &endptr, 10);
|
||||||
return -1;
|
if ((startptr == endptr) || (*endptr != '\0')) {
|
||||||
} else {
|
devnum = -1;
|
||||||
if (strlen(device) == 8 ){ // serial number
|
}
|
||||||
if (verbose >= 2) {
|
} else {
|
||||||
avrdude_message(MSG_INFO,
|
char device[9] = "";
|
||||||
"%s: ft245r_open(): serial number parsed as: "
|
if ((sscanf(port, "usb:%8s", device) == 1)) {
|
||||||
"%s\n",
|
if (strlen(device) == 8) {
|
||||||
progname,
|
// copy serial number to pgm struct
|
||||||
device);
|
strcpy(pgm->usbsn, device);
|
||||||
|
// and use first device with matching serial (should be unique)
|
||||||
|
devnum = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// copy serial number to pgm struct
|
|
||||||
strcpy(pgm->usbsn, device);
|
|
||||||
// and use first device with matching serial (should be unique)
|
|
||||||
devnum = 0;
|
|
||||||
}
|
|
||||||
else if (strncmp("ft", device, 2) || strlen(device) <= 8) { // classic device number
|
|
||||||
char *startptr = device + 2;
|
|
||||||
char *endptr = NULL;
|
|
||||||
devnum = strtol(startptr,&endptr,10);
|
|
||||||
if ((startptr==endptr) || (*endptr != '\0')) {
|
|
||||||
devnum = -1;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_INFO,
|
|
||||||
"%s: ft245r_open(): device number parsed as: "
|
|
||||||
"%d\n",
|
|
||||||
progname,
|
|
||||||
devnum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if something went wrong before abort with helpful message
|
if (devnum < 0) {
|
||||||
if (devnum < 0) {
|
avrdude_message(MSG_INFO, "%s: invalid portname '%s': use 'ft[0-9]+' or serial number\n",
|
||||||
avrdude_message(MSG_INFO, "%s: ft245r_open(): invalid portname '%s': use^ 'ft[0-9]+' or serial number\n",
|
progname, port);
|
||||||
progname,port);
|
return -1;
|
||||||
return -1;
|
}
|
||||||
|
} else {
|
||||||
|
devnum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle = malloc (sizeof (struct ftdi_context));
|
handle = malloc (sizeof (struct ftdi_context));
|
||||||
|
|
Loading…
Reference in New Issue