From owner-freebsd-usb@FreeBSD.ORG Mon Jul 12 17:48:17 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 19DCB1065672 for ; Mon, 12 Jul 2010 17:48:17 +0000 (UTC) (envelope-from peerst@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 9C2F08FC1B for ; Mon, 12 Jul 2010 17:48:16 +0000 (UTC) Received: by bwz12 with SMTP id 12so3058889bwz.13 for ; Mon, 12 Jul 2010 10:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=m7Y2MLSQZYclUJsQUYhqJrt687EL5WlCu+ZNqclYLx0=; b=AVdl+nc3fsu8Aq6mBnySgMBsIF2FOnfR3gcC5UD2SP4Kgdgc8rC/S/+xFr2BoOkSDG VOosxb2Wbv/8P8ebQwVLFpsgr7DFBYMqR2ntHkbGN4lqRT/kC9INE4ZA1qgklDiMGmoq mtaOq8Ck0oaHy0yrg95ooJrgYi2Fsp7/TdY/8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=J7irU2IuZAtGgKaiGSYRgQAJ9fyzpTTGESmjG9TpaQHljHRsl4bviaSReyD2Z/3xs7 p4NoArGOX8BPrWfJ2p00nD8nz5Bwc1KSM7c1W4BhMeXVLmixJTv9fk4K5wrqYFB/YtwK Vsk5znraras4bu9AEvvcckasGaQKQqeiVpvTY= MIME-Version: 1.0 Received: by 10.204.49.196 with SMTP id w4mr10619321bkf.73.1278955349017; Mon, 12 Jul 2010 10:22:29 -0700 (PDT) Received: by 10.204.56.134 with HTTP; Mon, 12 Jul 2010 10:22:28 -0700 (PDT) Date: Mon, 12 Jul 2010 19:22:28 +0200 Message-ID: From: Peer Stritzinger To: freebsd-usb@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: 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 17:48:17 -0000 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