Date: Wed, 11 May 2005 13:32:52 +0200 From: Hans Petter Selasky <hselasky@c2i.net> To: freebsd-usb@freebsd.org, paradox <algorist2000@yahoo.com> Subject: Re: a problem about ugen.c Message-ID: <200505111332.53170.hselasky@c2i.net> In-Reply-To: <20050511062048.37521.qmail@web53602.mail.yahoo.com> References: <20050511062048.37521.qmail@web53602.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 11 May 2005 08:20, paradox wrote: > Thanks,all problems are solved. > > The usb key device has two hardware bugs, one is the > CLEAR_FEATURE packet problem just like you said, the > other is an error in the toggle bit changing. > > after I change the usb-subr.c, I can use ugen.ko to > read and write the device directly. > > but when I read data from the device(low speed, > interrupt pipe),the data length I read must be less > than the max packet size,or some data will be lost. > The read command only read data in one interval. but I > thought the standard read function should read the > data till all the data has been read or we got an > incomplete packet. Am I right? The current ugen implementation for INTERRUPT transfers is going to loose packet synchronization if too many packets arrive at the same time, because it uses a ring-buffer to buffer data. Maybe it should use mbufs instead? You read data from an ugen INTERRUPT endpoint like this: length = read(fd, buf, sizeof(buf)); /* got one packet (should be like this) */ if(length == -1) error; else got length bytes of data (and not sizeof(buf) bytes). buf should have a size greater than maxpacket size, and if (length == sizeof(buf)) packet synchronization will be lost until the buffer drains. This should be fixed in the ugen driver. > > --- Hans Petter Selasky <hselasky@c2i.net> wrote: > > On Saturday 30 April 2005 09:00, paradox wrote: > > > > It might be the CLEAR_FEATURE or clear stall packet > > that does it. Some devices > > will only work if clear stall is issued as a part of > > a reset sequence. This > > has been discussed before on this list. > > > > In the file "/sys/dev/usb/usb_subr.c" in the > > function "usbd_setup_pipe" could > > you change: > > > > err = usbd_clear_endpoint_stall(p); > > > > into > > > > err = 0; /* usbd_clear_endpoint_stall(p); */ I see that the memory allocated is not zeroed, so you might have to add: (p->methods->cleartoggle)(p); after err = 0; > > > > Then recompile the USB module: > > "make -C/sys/modules/usb depend all install clean" > > > > Reboot and see if there is any change. > > --HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505111332.53170.hselasky>