avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avrdude-dev] ser_posix.c: is select()ing for the write descriptor usefu


From: Joerg Wunsch
Subject: [avrdude-dev] ser_posix.c: is select()ing for the write descriptor useful at all?
Date: Wed, 18 Apr 2007 22:36:13 +0200
User-agent: Mutt/1.5.11

A fellow worker recently stumbled across avrdude not working against a
bootloader that was behind one of these Silabs CP210x USB/RS-232
bridges under Linux.  I turned out that somehow, the Linux driver for
that part (unlike the FTDI driver) does not support select() on a
write descriptor properly, so it always runs into a timeout, and
avrdude then complains the programmer were not responding.

While this is clearly a fault somehow in the Linux driver(s), it makes
me wonder whether select()ing on our write descriptor is really buying
us anything.  The only advantage I could see is that on a completely
congested channel, avrdude could volunteerily give up after 500 ms,
rather than blocking indefinately (i.e. until the luser hits ^C).

Would anybody terribly mind removing that piece of code?  I tried to
track its history, and it seems to have been present already in
avrprog 3.0.0 which has been Brian's first version talking through a
serial port (to an STK500).  Later on, it has been moved out into its
own file.

Index: ser_posix.c
===================================================================
RCS file: /home/cvs/avrdude/avrdude/ser_posix.c,v
retrieving revision 1.19
diff -u -u -r1.19 ser_posix.c
--- ser_posix.c 24 Jan 2007 21:07:54 -0000      1.19
+++ ser_posix.c 18 Apr 2007 20:35:33 -0000
@@ -271,8 +271,6 @@
 static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t 
buflen)
 {
   struct timeval timeout, to2;
-  fd_set wfds;
-  int nfds;
   int rc;
   unsigned char * p = buf;
   size_t len = buflen;
@@ -306,29 +304,6 @@
   to2 = timeout;
 
   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);
     if (rc < 0) {
       fprintf(stderr, "%s: ser_send(): write error: %s\n",

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]