From owner-freebsd-usb@FreeBSD.ORG Wed Mar 7 02:52:19 2012 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 DAAA81065670 for ; Wed, 7 Mar 2012 02:52:19 +0000 (UTC) (envelope-from hartzell@alto.alerce.com) Received: from griffon.alerce.com (griffon.alerce.com [206.125.171.162]) by mx1.freebsd.org (Postfix) with ESMTP id BD3588FC1F for ; Wed, 7 Mar 2012 02:52:19 +0000 (UTC) Received: from griffon.alerce.com (localhost [127.0.0.1]) by griffon.alerce.com (Postfix) with ESMTP id 5ADDA2842A for ; Tue, 6 Mar 2012 18:35:18 -0800 (PST) Received: from alto.alerce.com (75-149-38-78-SFBA.hfc.comcastbusiness.net [75.149.38.78]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by griffon.alerce.com (Postfix) with ESMTPSA id 019B328428 for ; Tue, 6 Mar 2012 18:35:17 -0800 (PST) Received: by alto.alerce.com (Postfix, from userid 503) id 6A33A2F1990; Tue, 6 Mar 2012 18:35:17 -0800 (PST) From: George Hartzell MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <20310.51557.331624.617177@gargle.gargle.HOWL> Date: Tue, 6 Mar 2012 18:35:17 -0800 To: freebsd-usb@freebsd.org X-Mailer: VM 8.2.0b under 23.2.1 (x86_64-apple-darwin) X-Virus-Scanned: ClamAV using ClamSMTP Subject: radioSHARK, libusbhid and 'Device not configured' X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: hartzell@alerce.com List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Mar 2012 02:52:19 -0000 Long story short, I'm running into 'Device not configured' errors while trying to use libusbhid to control a Griffin radioSHARK. I'm not sure what I'm doing wrong or what to try next and am hoping that someone can help me get going again. There are links to various diagnostic material near the end of this message. I've been trying to make a Griffin radioSHARK USB AM/FM radio work. My long term goal is to use it from within the Squeezebox world but it has become something of a challenge in its own right. I was initially working on a Mac OS X system (to avoid building a recent Logitech Media Server [LMS, new name for the squeezebox server software] on my FreeBSD 9 system until later). There is an LMS plugin for the radioSHARK which uses an small C program called shark2 to set frequencies etc... Shark2 did not work on OS X 10.6, and after much gnashing of teeth and digging through the libhid and libusb world I finally found out that it can't be made to work (Apple's USB drivers grab the device exclusively and the pre OS X 10.6 trick of using a kext to protect it no longer works). The authors of libusb recommended using a library called hidapi. I got that working and discovered that the bytes that shark2 sends down the usb connection don't work on my device (possibly because I have a radioSHARK v1). A bit more googling and I found some old notes in Japanese that described the protocol (Google translate to the rescue, more or less...) and I am now able to turn the LEDs on and off and tune to FM and AM (crappy reception) at will. So, I've convinced myself that I have a sufficient understanding of how the thing works. On to FreeBSD. When I plug the device into my 9.0-STABLE system it seems to be recognized: ugen1.2: at usbus1 uaudio0: on usbus1 uaudio0: No playback! uaudio0: Record: 48000 Hz, 2 ch, 16-bit S-LE PCM format uaudio0: No midi sequencer pcm1: on uaudio0 uhid0: on And I can do the cheap and easy test of > cat /dev/dsp1.0 > /dev/dsp0.1 and listen to what ever channel it happens to be set to. The mixer command let me set the volume with "-f mixer1" and I was very hopeful. It seemed like I should be able to recreate my OS X/hidapi version using FreeBSD libusbhid. The meat of the hidapi version is a call to hid_write, which in turn does the following call into the OS X libraries. set_report(dev, kIOHIDReportTypeOutput, data, length); which seems to map straightforwardly to something like this (cribbed from various things in /usr/src): hid_init(NULL); f = open("/dev/uhid0", O_RDWR); if (f < 0) err(1, "%s", "/dev/uhid0"); // red LED memset(buf, 0x00, sizeof(buf)); buf[0] = 0xA9; /* red on */ r = hid_set_report(f, hid_output, buf, 7); if (r != 0) warn("hid_set_report"); But it consistently tells me > sudo ./shark shark: hid_set_report: Device not configured A bit of poking around led me to [blindly] try usbhidctl and to discover that it also runs into 'Device not configured' errors. > sudo usbhidctl -f /dev/uhid0 -v -a Password: usbhidctl: hid_get_report(rid 0): Device not configured Got input report 0 (6 bytes): Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= usbhidctl: hid_get_report(rid 0): Device not configured Got output report 0 (6 bytes): Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= Consumer:Consumer_Control.Consumer:Consumer_Control= I have output from setting hw.usb.uhid.debug=15 then plugging the radioSHARK in here: http://shrimp.alerce.com/radioSHARK/usb-sysctl-output.txt and the output from usbconfig -d ugen1.2 dump_device_desc dump_curr_config_desc here: http://shrimp.alerce.com/radioSHARK/usbconfig-output.txt And output from using usbdump while I tried to toggle the red led on/off here: http://shrimp.alerce.com/radioSHARK/usbdump-output-red-off.txt http://shrimp.alerce.com/radioSHARK/usbdump-output-red-on.txt I'm open to suggestions about what to try next. Thanks (double if you've made it this far), g.