diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-08-13 01:10:59 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-08-13 01:10:59 +0200 |
commit | d8d26c7001d63537be2d4bf6c39778ad07e32e3a (patch) | |
tree | b20af2491c566b4d7a2e9c993ea4da48185b4d85 /sys/src | |
parent | bedffdd8c3946a5a13a2ef7015b214ed8f8f5f66 (diff) |
nusb/ptp: do maxpkt reads to avoid babble error with usb 2.0 devices (thanks mischief!)
mischief got babble error with his mobile phone as we used to
read at max 64 bytes for the data response phase. his device
has 512 byte packet size.
thans to mischief for the patience.
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/cmd/nusb/ptp/ptp.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/src/cmd/nusb/ptp/ptp.c b/sys/src/cmd/nusb/ptp/ptp.c index aae70d984..872773a03 100644 --- a/sys/src/cmd/nusb/ptp/ptp.c +++ b/sys/src/cmd/nusb/ptp/ptp.c @@ -45,7 +45,7 @@ struct Ptprpc uchar type[2]; uchar code[2]; uchar transid[4]; - uchar d[52]; + uchar d[500]; }; struct Node @@ -281,7 +281,7 @@ vptprpc(Ioproc *io, int code, int flags, va_list a) *prdata = nil; *prdatalen = 0; - while((n = ioread(io, usbep[In]->dfd, &rpc, sizeof(rpc))) <= 0){ + while((n = ioread(io, usbep[In]->dfd, &rpc, usbep[In]->maxpkt)) <= 0){ if(n < 0){ wasinterrupt(); return -1; @@ -334,7 +334,7 @@ vptprpc(Ioproc *io, int code, int flags, va_list a) } } - while((n = ioread(io, usbep[In]->dfd, &rpc, sizeof(rpc))) <= 0){ + while((n = ioread(io, usbep[In]->dfd, &rpc, usbep[In]->maxpkt)) <= 0){ if(n < 0){ wasinterrupt(); return -1; @@ -1028,6 +1028,8 @@ threadmain(int argc, char **argv) } if(usbep[In]->dfd < 0 || usbep[Out]->dfd < 0) sysfatal("open endpoints: %r"); + if(usbep[In]->maxpkt < 12 || usbep[In]->maxpkt > sizeof(Ptprpc)) + sysfatal("bad packet size: %d\n", usbep[In]->maxpkt); iochan = chancreate(sizeof(Ioproc*), 1); sendp(iochan, ioproc()); |