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: Jason Kyle
Subject: [Uisp-dev] RE: uisp on cygwin request
Date: Sun, 11 May 2003 10:17:29 +1200

At 14:19 10/05/2003 -0700, Theodore A. Roth wrote:
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?

Compiles ok, tested with -dprog=pavr. Don't have any parallel programmers to test with.

Line 85 Main.C has an old URL for pavr, please change to http://www.avr1.org

Thanks Ted/Marc

Jason Kyle


Thanks.

Ted Roth





reply via email to

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