From owner-freebsd-questions@FreeBSD.ORG Wed Jul 23 04:20:56 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43304106567C for ; Wed, 23 Jul 2008 04:20:56 +0000 (UTC) (envelope-from af300wsm@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.237]) by mx1.freebsd.org (Postfix) with ESMTP id 20FD98FC08 for ; Wed, 23 Jul 2008 04:20:55 +0000 (UTC) (envelope-from af300wsm@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so2656576rvf.43 for ; Tue, 22 Jul 2008 21:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:cc:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id; bh=OKdXp2EepYW10eJ8Vo04cOvCrNlakraV/4O10tSAPuA=; b=qqSrgmdwxf97f5VanDLOmRlhXDbGGbJu/CzVLUdUbzWyAvBq7rdYsNmXdGnQjyEHYq FGyaD2d3tCAR8OOPXfYs91Dl83klXe2o+RrUyz4MCqIZPx5O0QGv+q0vNyMeTKB1cCx7 /fgABEeRG/biKn/fVEK8587v2uIEpugejBjek= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:message-id; b=bdRaM3lMMRyiQnettEALU8+UOtqni/442KjrgrllYfkNbyxdwt+ufteCzk4w//0tu8 eFa8RxkTuXVmBPF6I0bdmo4FlOuQ+pLsAOPdc7NfqtVWjajIjCHKvjdrrRgB+44Y4Vpr EQqtE+oeGIvELoUZVKT/apOpQHFwRFkQDJCiQ= Received: by 10.140.170.12 with SMTP id s12mr350296rve.83.1216786855470; Tue, 22 Jul 2008 21:20:55 -0700 (PDT) Received: from sniper ( [71.221.186.159]) by mx.google.com with ESMTPS id k41sm10700772rvb.3.2008.07.22.21.20.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 22 Jul 2008 21:20:54 -0700 (PDT) From: Andrew Falanga To: Lowell Gilbert Date: Tue, 22 Jul 2008 22:20:09 -0600 User-Agent: KMail/1.9.6 References: <340a29540807220721r10e36a99v1a2fa74e2bb2dfa0@mail.gmail.com> <44bq0qc7b1.fsf@be-well.ilk.org> In-Reply-To: <44bq0qc7b1.fsf@be-well.ilk.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200807222220.10176.af300wsm@gmail.com> Cc: "freebsd-questions@freebsd.org" Subject: Re: Has anyone used libusb for accessing usb devices here? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jul 2008 04:20:56 -0000 On Tuesday 22 July 2008 08:38:58 Lowell Gilbert wrote: > "Andrew Falanga" writes: > > I'd like to know if anyone here on the list has ever used libusb > > (http://libusb.sourceforge.net) for accessing usb devices. I > > successfully compiled and installed it on my FreeBSD 7 laptop but when > > I run a test program no USB HUBs are found. The same test on a Fedora > > box works fine. I was wondering what the magic is for FreeBSD since > > the web site claims the package works on FreeBSD. > > libusb is in ports, and a number of other ports use it. > (See "make search key=libusb".) > That should provide a variety of working examples. Ok, I've installed from the ports collection this time (at home now on my 6.2p11 box) and I'm seeing busses in my computer. However, when I plug in my USB thumb drive, a Sandisk Cruizer Micro that the kernel does see as da0 (verified in /var/log/messages), I don't get any devices shown. Below is the code to the program I'm using. It's a hack of the basic example on the libusb.sourceforge.net website docs. #include #include int main(void) { usb_init(); struct usb_bus *busses; usb_init(); usb_find_busses(); usb_find_devices(); busses = usb_get_busses(); if(busses) std::cout << "we found some busses" << std::endl; else std::cout << "no busses were found" << std::endl; struct usb_bus *bus; int c, i, a, bussCount(0); /* ... */ for (bus = busses; bus; bus = bus->next) { std::cout << "enumerating buss: " << ++bussCount << std::endl; struct usb_device *dev; // loop through each device and display its vid pid for (dev = bus->devices; dev; dev = dev->next) { struct usb_device_descriptor* pUsbDev = &dev->descriptor; if(pUsbDev->bDeviceClass == 0x09) std::cout << "Device is a HUB\n"; if(pUsbDev->bDeviceClass == 0x07) std::cout << "Device is a printer:\n"; if(pUsbDev->bDeviceClass == 0x08) std::cout << "Device is a mass storage device:\n"; std::cout << "Device Class: " << (int)pUsbDev->bDeviceClass << std::endl; std::cout << "VID: " << std::dec << pUsbDev->idVendor << " " << std::hex << pUsbDev->idVendor << std::endl; std::cout << "PID: " << std::dec << pUsbDev->idProduct << " " << std::hex << pUsbDev->idProduct << std::endl; if(dev->num_children > 0) { struct usb_device* pChild = *(dev->children); while(pChild) { std::cout << "Childs device class: " << std::dec << pChild->descriptor.bDeviceClass << " " << std::hex << pChild->descriptor.bDeviceClass << std::endl; pChild = pChild->next; } } } } return 0; } Any ideas why I'm not seeing any devices? Andy