From owner-freebsd-usb@FreeBSD.ORG Sat Jun 17 17:28:05 2006 Return-Path: X-Original-To: freebsd-usb@freebsd.org Delivered-To: freebsd-usb@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E193E16A479 for ; Sat, 17 Jun 2006 17:28:05 +0000 (UTC) (envelope-from mistry.7@osu.edu) Received: from mail.united-ware.com (am-productions.biz [69.61.164.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id 48E8F43D45 for ; Sat, 17 Jun 2006 17:28:05 +0000 (GMT) (envelope-from mistry.7@osu.edu) Received: from [192.168.1.100] (am-productions.biz [69.61.164.22]) (authenticated bits=0) by mail.united-ware.com (8.13.6/8.13.6) with ESMTP id k5HHW27D075111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 17 Jun 2006 13:32:08 -0400 (EDT) (envelope-from mistry.7@osu.edu) From: Anish Mistry To: Hans Petter Selasky Date: Sat, 17 Jun 2006 13:28:15 -0400 User-Agent: KMail/1.9.1 References: <200606161724.21722.mistry.7@osu.edu> <200606171154.50869.mistry.7@osu.edu> <200606171916.00064.hselasky@c2i.net> In-Reply-To: <200606171916.00064.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1309124.JPdP4M1zSc"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200606171328.24960.mistry.7@osu.edu> X-Spam-Status: No, score=-5.5 required=5.0 tests=ALL_TRUSTED,BAYES_50, MYFREEBSD3 autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on mail.united-ware.com X-Virus-Scanned: ClamAV 0.88.2/1548/Fri Jun 16 13:53:47 2006 on mail.united-ware.com X-Virus-Status: Clean Cc: freebsd-usb@freebsd.org Subject: Re: ugen partial write() amount X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jun 2006 17:28:06 -0000 --nextPart1309124.JPdP4M1zSc Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Saturday 17 June 2006 13:15, Hans Petter Selasky wrote: > On Saturday 17 June 2006 17:54, Anish Mistry wrote: > > On Saturday 17 June 2006 03:50, Hans Petter Selasky wrote: > > > On Friday 16 June 2006 23:24, Anish Mistry wrote: > > > > I'm trying to reliably recover from a write() timeout using > > > > ugen. The problem that I'm having is that when using write() > > > > to write data to an endpoint and the write times out there > > > > seems no way to figure out the amount of that data that was > > > > actually written. This is a problem when trying to write > > > > data to a printer and the paper runs out. write() will > > > > timeout and you are left with no way to figure out where to > > > > start sending data since you don't know how much was received > > > > by the device before the paper ran out. > > > > It seems this could be possible by modifying the driver by > > > > adding and ioctl that would allow you to call bulk transfer > > > > and then return the number of bytes written. Is there a > > > > better way of doing? > > > > > > What about disabling the timeout ? > > > > That works, the problem is that the write() will block causing > > the controller application to be non-responsive and not report > > the condition that caused the failure since it has blocked. > > I have some plans to make "ugen" asynchronous. Then you can use > FIONBIO to set non-blocking mode, and poll the file descriptor. > That is the solution I see. Most excellent. =20 > > > My conclusion so far is that I would need to thread the writing > > logic in the application, and then write my own timeout logic > > when I notice that the write is blocking for longer than our time > > interval. At least that is the option I can think of without > > modifying the driver. > > Yes. I'll go with this approach. =2D-=20 Anish Mistry --nextPart1309124.JPdP4M1zSc Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (FreeBSD) iD8DBQBElDu4xqA5ziudZT0RAm7gAJ9vNERXpSMfEuGELRuCoaPCrTPNnwCgwdcY uvGlcdW/w9UbQHFR8zA8Umw= =LrA/ -----END PGP SIGNATURE----- --nextPart1309124.JPdP4M1zSc--