From owner-freebsd-usb@FreeBSD.ORG Wed May 25 09:37:33 2005 Return-Path: X-Original-To: freebsd-usb@freebsd.org Delivered-To: freebsd-usb@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A8C4E16A41C for ; Wed, 25 May 2005 09:37:33 +0000 (GMT) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe03.swip.net [212.247.154.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 322B743D49 for ; Wed, 25 May 2005 09:37:32 +0000 (GMT) (envelope-from hselasky@c2i.net) X-T2-Posting-ID: Y1QAsIk9O44SO+J/q9KNyQ== Received: from mp-217-233-132.daxnet.no ([193.217.233.132] verified) by mailfe03.swip.net (CommuniGate Pro SMTP 4.3c5) with ESMTP id 179094620; Wed, 25 May 2005 11:37:30 +0200 From: Hans Petter Selasky To: freebsd-usb@freebsd.org Date: Wed, 25 May 2005 11:38:13 +0200 User-Agent: KMail/1.7 References: <200505242052.j4OKqJiI001602@karga.hank.home> In-Reply-To: <200505242052.j4OKqJiI001602@karga.hank.home> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200505251138.14355.hselasky@c2i.net> Cc: Subject: Re: poll(2)ing or select(2)ing /dev/usb0 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: hselasky@c2i.net List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2005 09:37:33 -0000 On Tuesday 24 May 2005 22:52, Dirk GOUDERS wrote: > > You cannot read data from /dev/usbN, only ioctls are possible on those > > devices. > > > > See "/sys/dev/usb/usb.c" (usbpoll), if you got the source code > > installed. > > Ah yes, thank you, now I understand why my programs behave like they do. > > To me, it looks as if the manual page usb(4) is a little bit misleading: > > > USB CONTROLLER INTERFACE > Use the following to get access to the USB specific structures and > defines. > > The /dev/usbN can be opened and a few operations can be performed on > it. The poll(2) system call will say that I/O is possible on the controller > device when a USB device has been connected or disconnected to the bus. > > The following ioctl(2) commands are supported on the controller > device: > > I understood the text in the following way: > > "If you want to know if a device has been connected/disconnected, then > call poll(2) on /dev/usbN and if poll(2) says that descriptors are > ready, perform one of the ioctl(2) command to find out what exactly > happened." > > > Well, do I understand it right, that the only way to use poll(2) to > come to know if a device has been connected/disconnected to/from the > bus is to poll(2) /dev/usb (the event interface)? right > And therefore on a > machine that runs usbd(8), no other process can use poll(2), to come to > know about such events, but has to do it somehow else? If you want to do something special then you might want to modify "/usr/src/usr.sbin/usbd/usbd.c", if you got the sources installed. If you just want to start a program when a device has been attached or detached, there is "/etc/devd.conf" (or "/etc/usbd.conf", which is depreceated). These configuration files do almost the same. I'm not sure exactly when, but in FreeBSD-6-current, USB product and vendor ID's get printed to "pnpinfo" (sysctl -a | grep pnpinfo), and can be matched in "/etc/devd.conf". If there is no "pnpinfo" for your USB devices, then you might have to use "/etc/usbd.conf" until further, though that file will be replaced by "/etc/devd.conf". --HPS