From owner-freebsd-usb@FreeBSD.ORG Mon Jul 12 18:23:00 2010 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A2C9E1065673 for ; Mon, 12 Jul 2010 18:23:00 +0000 (UTC) (envelope-from hselasky@freebsd.org) Received: from swip.net (mailfe07.swip.net [212.247.154.193]) by mx1.freebsd.org (Postfix) with ESMTP id 04C418FC1D for ; Mon, 12 Jul 2010 18:22:59 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=32lW3yoDUX8A:10 a=VZGMvYHv9TIA:10 a=8nJEP1OIZ-IA:10 a=M8b_wTzEtboA:10 a=MnI1ikcADjEx7bvsp0jZvQ==:17 a=Ey393DdTyU5Kk_aViHYA:9 a=uXKWTSFjr8_v0qku9Sb4MrMoZ5EA:4 a=wPNLvfGTeEIA:10 Received: from [188.126.201.140] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe07.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 1404448641; Mon, 12 Jul 2010 20:22:58 +0200 Received-SPF: softfail receiver=mailfe07.swip.net; client-ip=188.126.201.140; envelope-from=hselasky@freebsd.org From: Hans Petter Selasky To: freebsd-usb@freebsd.org Date: Mon, 12 Jul 2010 20:20:02 +0200 User-Agent: KMail/1.12.4 (FreeBSD/8.1-PRERELEASE; KDE/4.3.4; amd64; ; ) References: In-Reply-To: X-Face: +~\`s("[*|O,="7?X@L.elg*F"OA\I/3%^p8g?ab%RN'(; _IjlA: hGE..Ew, XAQ*o#\/M~SC=S1-f9{EzRfT'|Hhll5Q]ha5Bt-s|oTlKMusi:1e[wJl}kd}GR Z0adGx-x_0zGbZj'e(Y[(UNle~)8CQWXW@:DX+9)_YlB[tIccCPN$7/L' MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201007122020.02934.hselasky@freebsd.org> Cc: Subject: Re: read(2) always returns 0 when reading from /dev/usb/n.m.k bulk IN endpoint 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: Mon, 12 Jul 2010 18:23:00 -0000 On Monday 12 July 2010 19:22:28 Peer Stritzinger wrote: > Hi, > > on FreeBSD 8.0-RELEASE I try to read from a bulk IN endpoint device node > with read(2). > > The USB client it is talking to is a embedded controller with Cypress SX2 > USB client chip, enumeration goes quite well (SX2 does it itself) and its > reported correctly on console. The device nodes in /dev/usv/n.m.k appear > for the control endpoint and two OUT and IN endpoints each. > > I can write to one of the OUT endpoints with e.g. dd and what I read on the > device is correct. > > However I can't read any data from a corresponding IN endpoint: What I > doing is in a loop: > > n = read(in, buf, NBUF); > printf ("read-test: read %ld bytes\n", n); > > this is run as root. > > I'm watching the USB with a USB protocol analyzer, BTW its running in > High-Speed. > > As soon as the first read is done (and blocks) I see IN->NAK (device did > not write to the IN endpoint) polling on the USB. > > When the device writes to the endpoint buffer I see a correct bulk IN > transfer that is ACKed by the host with the analyzer. > > However the read always returns 0. > > Tried different buffer sizes etc. > > Is this supposed to work as I'm using it. I'm planning to go to libusb-1.0 > later, should I debug this with the /dev/usb/n.m.k node reading or proceed > to libusb because my approach can't work anyway? > > Best regards, > Peer Stritzinger Hi, Maybe you are missing to set the short transfer OK flag. Else I recommend using LibUSB. --HPS