From owner-freebsd-usb@freebsd.org Wed Apr 27 05:27:15 2016 Return-Path: Delivered-To: freebsd-usb@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 52592B1D485 for ; Wed, 27 Apr 2016 05:27:15 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 319E41D27 for ; Wed, 27 Apr 2016 05:27:14 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from Julian-MBP3.local (50-196-156-133-static.hfc.comcastbusiness.net [50.196.156.133]) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id u3R5RANF057826 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Tue, 26 Apr 2016 22:27:13 -0700 (PDT) (envelope-from julian@freebsd.org) Subject: Re: Byte-banging a USB device attached on ugen To: freebsd-usb@freebsd.org References: From: Julian Elischer Message-ID: <9ea9f4ec-f6be-eaca-54cb-4013a3e0c7be@freebsd.org> Date: Wed, 27 Apr 2016 13:27:04 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2016 05:27:15 -0000 On 27/04/2016 4:06 AM, Karl Denninger wrote: > So I've got one of these.... > > ugen0.5: at usbus0 > > Which is a CM15. > > It does not appear to attach as an HID or expose a serial-like interface > (on a tty or cua device node.) > > I have documentation of two end-points that this device uses, one for > transmitting data to the host and one for receiving commands from the > host, along with the byte-format protocol that is expected on each. As > such if I can determine how to programmatically access those two > end-points I should be good. > > What I'm having trouble finding documentation on is how to open the > device and attach a byte stream to those endpoints on FreeBSD (e.g. how > to get it open and specify which endpoint to associate with the handle) > and once I do, can I expect to use the usual select() paradigm to see if > they're ready for read (e.g. something is on the bus inbound to me) and > ready for write (can be written to.) > > Is there a pointer available somewhere to a code fragment that shows how > to do this? I also want to get the device specification as part of the > setup, obviously, to make sure I'm talking to the right device and not > some other random thing that was plugged in -- my intent is to handle > the situation where my code can detect a hot-plug (or unplug) of the > device and initialize and/or shut down the channel accordingly and thus > I want to iterate over the ugen devices I find and check them for the > correct device specification. what you are looking for is libusb I think. https://www.freebsd.org/cgi/man.cgi?apropos=0&sektion=3&query=libusb20&manpath=FreeBSD+5.0-current&format=html you should also look at the webcamd which I think uses it. > > Thanks in advance! >