* serial_open() calls will now return -1 on error (no call to exit())
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@948 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
f1bf228061
commit
0c603e4791
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2010-10-22 Nils Springob <nils@nicai-systems.de>
|
||||
|
||||
* serial.h: serial_open() calls will now return -1 on error (no call to exit())
|
||||
* buspirate.c: (Dito.)
|
||||
* jtagmkII.c: (Dito.)
|
||||
* butterfly.c: (Dito.)
|
||||
* jtagmkI.c: (Dito.)
|
||||
* arduino.c: (Dito.)
|
||||
* avr910.c: (Dito.)
|
||||
* stk500.c: (Dito.)
|
||||
* ser_avrdoper.c: (Dito.)
|
||||
* stk500v2.c: (Dito.)
|
||||
* ser_posix.c: (Dito.)
|
||||
* usb_libusb.c: (Dito.)
|
||||
|
||||
2010-07-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
bug #30566: MinGW + Ubuntu 9.04
|
||||
|
|
|
@ -86,7 +86,9 @@ static int arduino_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
|
|||
static int arduino_open(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &pgm->fd);
|
||||
if (serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Clear DTR and RTS to unload the RESET capacitor
|
||||
* (for example in Arduino) */
|
||||
|
|
4
avr910.c
4
avr910.c
|
@ -383,7 +383,9 @@ static int avr910_open(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, pgm->baudrate, &pgm->fd);
|
||||
if (serial_open(port, pgm->baudrate, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
|
|
@ -374,7 +374,9 @@ static int buspirate_open(struct programmer_t *pgm, char * port)
|
|||
pgm->baudrate = 115200;
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, pgm->baudrate, &pgm->fd);
|
||||
if (serial_open(port, pgm->baudrate, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* drain any extraneous input */
|
||||
serial_drain(&pgm->fd, 0);
|
||||
|
|
|
@ -356,7 +356,9 @@ static int butterfly_open(PROGRAMMER * pgm, char * port)
|
|||
if(pgm->baudrate == 0) {
|
||||
pgm->baudrate = 19200;
|
||||
}
|
||||
serial_open(port, pgm->baudrate, &pgm->fd);
|
||||
if (serial_open(port, pgm->baudrate, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
|
|
@ -673,7 +673,9 @@ static int jtagmkI_open(PROGRAMMER * pgm, char * port)
|
|||
fprintf(stderr,
|
||||
"%s: jtagmkI_open(): trying to sync at baud rate %ld:\n",
|
||||
progname, baudtab[i].baud);
|
||||
serial_open(port, baudtab[i].baud, &pgm->fd);
|
||||
if (serial_open(port, baudtab[i].baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
|
28
jtagmkII.c
28
jtagmkII.c
|
@ -1420,7 +1420,9 @@ static int jtagmkII_open(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -1465,7 +1467,9 @@ static int jtagmkII_open_dw(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -1510,7 +1514,9 @@ static int jtagmkII_open_pdi(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -1556,7 +1562,9 @@ static int jtagmkII_dragon_open(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -1602,7 +1610,9 @@ static int jtagmkII_dragon_open_dw(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -1648,7 +1658,9 @@ static int jtagmkII_dragon_open_pdi(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -3118,7 +3130,9 @@ static int jtagmkII_open32(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
|
|
@ -504,7 +504,7 @@ static char *usbErrorText(int usbErrno)
|
|||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void avrdoper_open(char *port, long baud, union filedescriptor *fdp)
|
||||
static int avrdoper_open(char *port, long baud, union filedescriptor *fdp)
|
||||
{
|
||||
int rval;
|
||||
char *vname = "obdev.at";
|
||||
|
@ -514,7 +514,9 @@ static void avrdoper_open(char *port, long baud, union filedescriptor *fdp)
|
|||
if(rval != 0){
|
||||
fprintf(stderr, "%s: avrdoper_open(): %s\n", progname, usbErrorText(rval));
|
||||
exit(1);
|
||||
//return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
|
10
ser_posix.c
10
ser_posix.c
|
@ -247,7 +247,7 @@ static int ser_set_dtr_rts(union filedescriptor *fdp, int is_on)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void ser_open(char * port, long baud, union filedescriptor *fdp)
|
||||
static int ser_open(char * port, long baud, union filedescriptor *fdp)
|
||||
{
|
||||
int rc;
|
||||
int fd;
|
||||
|
@ -258,7 +258,7 @@ static void ser_open(char * port, long baud, union filedescriptor *fdp)
|
|||
*/
|
||||
if (strncmp(port, "net:", strlen("net:")) == 0) {
|
||||
net_open(port + strlen("net:"), fdp);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -268,7 +268,7 @@ static void ser_open(char * port, long baud, union filedescriptor *fdp)
|
|||
if (fd < 0) {
|
||||
fprintf(stderr, "%s: ser_open(): can't open device \"%s\": %s\n",
|
||||
progname, port, strerror(errno));
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fdp->ifd = fd;
|
||||
|
@ -281,8 +281,10 @@ static void ser_open(char * port, long baud, union filedescriptor *fdp)
|
|||
fprintf(stderr,
|
||||
"%s: ser_open(): can't set attributes for device \"%s\": %s\n",
|
||||
progname, port, strerror(-rc));
|
||||
exit(1);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
3
serial.h
3
serial.h
|
@ -44,7 +44,8 @@ union filedescriptor
|
|||
|
||||
struct serial_device
|
||||
{
|
||||
void (*open)(char * port, long baud, union filedescriptor *fd);
|
||||
// open should return -1 on error, other values on success
|
||||
int (*open)(char * port, long baud, union filedescriptor *fd);
|
||||
int (*setspeed)(union filedescriptor *fd, long baud);
|
||||
void (*close)(union filedescriptor *fd);
|
||||
|
||||
|
|
4
stk500.c
4
stk500.c
|
@ -657,7 +657,9 @@ static void stk500_enable(PROGRAMMER * pgm)
|
|||
static int stk500_open(PROGRAMMER * pgm, char * port)
|
||||
{
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &pgm->fd);
|
||||
if (serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
|
20
stk500v2.c
20
stk500v2.c
|
@ -1313,7 +1313,9 @@ static int stk500v2_open(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -1363,7 +1365,9 @@ static int stk600_open(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -2818,7 +2822,9 @@ static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -2906,7 +2912,9 @@ static int stk500v2_dragon_isp_open(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
@ -2977,7 +2985,9 @@ static int stk500v2_dragon_hv_open(PROGRAMMER * pgm, char * port)
|
|||
}
|
||||
|
||||
strcpy(pgm->port, port);
|
||||
serial_open(port, baud, &pgm->fd);
|
||||
if (serial_open(port, baud, &pgm->fd)==-1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* drain any extraneous input
|
||||
|
|
|
@ -56,7 +56,7 @@ static int usb_interface;
|
|||
* The "baud" parameter is meaningless for USB devices, so we reuse it
|
||||
* to pass the desired USB device ID.
|
||||
*/
|
||||
static void usbdev_open(char * port, long baud, union filedescriptor *fd)
|
||||
static int usbdev_open(char * port, long baud, union filedescriptor *fd)
|
||||
{
|
||||
char string[256];
|
||||
char product[256];
|
||||
|
@ -220,7 +220,7 @@ static void usbdev_open(char * port, long baud, union filedescriptor *fd)
|
|||
progname, USBDEV_BULK_EP_READ);
|
||||
fd->usb.ep = USBDEV_BULK_EP_READ;
|
||||
}
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
trynext:
|
||||
usb_close(udev);
|
||||
|
|
Loading…
Reference in New Issue