uisp-dev
[Top][All Lists]
Advanced

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

[Uisp-dev] RE: uisp on cygwin request


From: Theodore A. Roth
Subject: [Uisp-dev] RE: uisp on cygwin request
Date: Sat, 10 May 2003 14:19:23 -0700 (PDT)

On Sat, 10 May 2003, Marc Wetzel wrote:

:)Hi Ted,
:)
:)I found the select bug also and tried to fix it.
:)
:)The following is a "fixed" routine that works for me. The bug was in
:)using getdtablesize() instead of FD_SETSIZE.
:)You should also add #include <errno.h> in the include part as I
:)introduced some retries if EINTR was found (as in avrdude).
:)
:)I also added some compiled version for the website.
:)
:)int TSerial::Rx(unsigned char* queue, int queue_size, timeval* timeout){
:)  int ret;
:)  fd_set rfds;
:)  FD_ZERO(&rfds); FD_SET(serline,&rfds);
:)  
:)retry:  
:)  if ((ret=select(/*FIXME ancient getdtablesize()*/
:)FD_SETSIZE,&rfds,NULL,NULL, timeout))==-1){
:)      Info(4, "Select on %d returned retval:%d
:)errno:%d\n",serline,ret,errno);
:)      if (errno == EINTR) {
:)         goto retry;
:)      } 
:)      throw Error_C("Select failed");
:)  }
:)  if (ret==0){throw Error_Device("Programmer is not responding.");}
:)  int size = read(serline, queue, queue_size);  
:)  Info(4, "Receive: { ");
:)  for (int n=0; n<size; n++) {
:)    Info(4, "%c [%02x] ", isprint(queue[n])?(char)queue[n]:'.',
:)queue[n]);
:)  }
:)  Info(4, "}\n");
:)  return size;
:)}
:)
:)

Ok, I've committed a fix as such:

http://savannah.nongnu.org/cgi-bin/viewcvs/uisp/uisp/src/Serial.C.diff?r1=1.4&r2=1.5

Using FD_SETSIZE is serious overkill since we only care about a single file 
descriptor. I also used a while loop with a stop-gap to avoid a possible 
(but very unlikely) infinite loop instead of the goto-label.

Could I get you guys to give it one more round of testing under cygwin?

Thanks.

Ted Roth





reply via email to

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