don't time out prolific i/o. (should do for all serial types?) when rts/cts are used, i/o can hang forever. this is not a problem. this is expected. Reference: /n/atom/patch/applied/usbprolificnotmout Date: Sat Apr 19 16:05:59 CES 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/usb/serial/prolific.c Sat Apr 19 16:05:01 2014 +++ /sys/src/cmd/usb/serial/prolific.c Sat Apr 19 16:05:01 2014 @@ -348,32 +348,28 @@ static int plreadstatus(Serialport *p) { - int nr, dfd; + int nr; char err[ERRMAX]; uchar buf[VendorReqSz]; Serial *ser; ser = p->s; + nr = read(p->epintr->dfd, buf, sizeof buf); qlock(ser); - dsprint(2, "serial: reading from interrupt\n"); - dfd = p->epintr->dfd; + dsprint(2, "serial: interrupt read %d\n", nr); - qunlock(ser); - nr = read(dfd, buf, sizeof buf); - qlock(ser); - snprint(err, sizeof err, "%r"); - dsprint(2, "serial: interrupt read %d %r\n", nr); - - if(nr < 0 && strstr(err, "timed out") == nil){ - dsprint(2, "serial: need to recover, status read %d %r\n", nr); - if(serialrecover(ser, nil, nil, err) < 0){ - qunlock(ser); - return -1; + if(nr < 0){ + snprint(err, sizeof err, "%r"); + dsprint(2, "serial: reading status: %s", err); + if(nr < 0 && strstr(err, "timed out") == nil){ + dsprint(2, "serial: need to recover, status read %d %s\n", nr, err); + if(serialrecover(ser, nil, nil, err) < 0){ + qunlock(ser); + return -1; + } } } - if(nr < 0) - dsprint(2, "serial: reading status: %r"); else if(nr >= sizeof buf - 1){ p->dcd = buf[8] & DcdStatus; p->dsr = buf[8] & DsrStatus; @@ -387,8 +383,7 @@ if(buf[8] & OvererrStatus) p->novererr++; } else - dsprint(2, "serial: bad status read %d\n", nr); - dsprint(2, "serial: finished read %d from interrupt\n", nr); + dsprint(2, "serial: bad status read %d bytes\n", nr); qunlock(ser); return 0; } @@ -416,6 +411,14 @@ static int plseteps(Serialport *p) { + if(devctl(p->epin, "timeout 0") < 0){ + fprint(2, "can't set timeout on %s: %r\n", p->epin->dir); + return -1; + } + if(devctl(p->epout, "timeout 0") < 0){ + fprint(2, "can't set timeout on %s: %r\n", p->epin->dir); + return -1; + } devctl(p->epin, "maxpkt 256"); devctl(p->epout, "maxpkt 256"); return 0; --- /sys/src/cmd/usb/serial/serial.c Sat Apr 19 16:05:01 2014 +++ /sys/src/cmd/usb/serial/serial.c Sat Apr 19 16:05:01 2014 @@ -525,13 +525,9 @@ dsprint(2, "serial: read: %s %ld\n", err, rcount); } while(rcount < 0 && strstr(err, "timed out") != nil); - dsprint(2, "serial: read %ld bytes from bulk, %10.10s\n", rcount, err); - if(rcount < 0){ - dsprint(2, "serial: need to recover, data read %ld %r\n", - count); + dsprint(2, "serial: read from bulk %ld, %10.10s\n", rcount, err); + if(rcount < 0) serialrecover(ser, p, p->epin, err); - } - dsprint(2, "serial: read %ld bytes from bulk\n", rcount); count = rcount; break; case Qctl: