In ser_send(), don't select() on the output fd before trying to write

something to the serial line.  That kind of polling isn't very useful
anyway, and it seems it breaks for the Linux CP210x USB<->RS-232
bridge driver which is certainly a bug in the driver, but we can just
avoid that bug alltogether.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@736 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2007-05-15 20:30:15 +00:00
parent 0266bf8ef8
commit 9a6c9d2343
2 changed files with 8 additions and 25 deletions

View File

@ -1,3 +1,11 @@
2007-05-15 Joerg Wunsch <j@uriah.heep.sax.de>
* ser_posix.c (ser_send): Don't select() on the output fd before
trying to write something to the serial line. That kind of
polling isn't very useful anyway, and it seems it breaks for the
Linux CP210x USB<->RS-232 bridge driver which is certainly a bug
in the driver, but we can just avoid that bug alltogether.
2007-05-15 Joerg Wunsch <j@uriah.heep.sax.de> 2007-05-15 Joerg Wunsch <j@uriah.heep.sax.de>
* avrdude.conf.in: Fix the STK500v2 ISP delay parameter for * avrdude.conf.in: Fix the STK500v2 ISP delay parameter for

View File

@ -271,8 +271,6 @@ static void ser_close(union filedescriptor *fd)
static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen) static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen)
{ {
struct timeval timeout, to2; struct timeval timeout, to2;
fd_set wfds;
int nfds;
int rc; int rc;
unsigned char * p = buf; unsigned char * p = buf;
size_t len = buflen; size_t len = buflen;
@ -306,29 +304,6 @@ static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen
to2 = timeout; to2 = timeout;
while (len) { while (len) {
reselect:
FD_ZERO(&wfds);
FD_SET(fd->ifd, &wfds);
nfds = select(fd->ifd + 1, NULL, &wfds, NULL, &to2);
if (nfds == 0) {
if (verbose >= 1)
fprintf(stderr,
"%s: ser_send(): programmer is not responding\n",
progname);
exit(1);
}
else if (nfds == -1) {
if (errno == EINTR || errno == EAGAIN) {
goto reselect;
}
else {
fprintf(stderr, "%s: ser_send(): select(): %s\n",
progname, strerror(errno));
exit(1);
}
}
rc = write(fd->ifd, p, (len > 1024) ? 1024 : len); rc = write(fd->ifd, p, (len > 1024) ? 1024 : len);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "%s: ser_send(): write error: %s\n", fprintf(stderr, "%s: ser_send(): write error: %s\n",