From owner-freebsd-usb@FreeBSD.ORG Thu May 6 20:43:20 2010 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 81C9F106567D for ; Thu, 6 May 2010 20:43:20 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe01.swip.net [212.247.154.1]) by mx1.freebsd.org (Postfix) with ESMTP id DCB5E8FC24 for ; Thu, 6 May 2010 20:43:19 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=SZdgNhJuHXgA:10 a=8nJEP1OIZ-IA:10 a=M8b_wTzEtboA:10 a=MnI1ikcADjEx7bvsp0jZvQ==:17 a=6I5d2MoRAAAA:8 a=mOw-Q1E_MEZTz1_SpHsA:9 a=TavmHYLosac_bvbWFbRTRELap-sA:4 a=wPNLvfGTeEIA:10 a=rIyH_HcT2nnJfa5V:21 a=reRJb9sDhsXLdoq2:21 Received: from [188.126.201.140] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe01.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 337419143; Thu, 06 May 2010 22:43:18 +0200 From: Hans Petter Selasky To: freebsd-usb@freebsd.org Date: Thu, 6 May 2010 22:40:30 +0200 User-Agent: KMail/1.12.4 (FreeBSD/8.0-STABLE; KDE/4.3.4; amd64; ; ) References: <201005061949.o46Jngdt028521@lava.sentex.ca> In-Reply-To: <201005061949.o46Jngdt028521@lava.sentex.ca> X-Face: +~\`s("[*|O,="7?X@L.elg*F"OA\I/3%^p8g?ab%RN'(; _IjlA: hGE..Ew, XAQ*o#\/M~SC=S1-f9{EzRfT'|Hhll5Q]ha5Bt-s|oTlKMusi:1e[wJl}kd}GR Z0adGx-x_0zGbZj'e(Y[(UNle~)8CQWXW@:DX+9)_YlB[tIccCPN$7/L' MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201005062240.30548.hselasky@c2i.net> Cc: Subject: Re: apcupsd port regression from 7x. to 8.x 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: Thu, 06 May 2010 20:43:20 -0000 On Thursday 06 May 2010 21:49:46 Mike Tancsa wrote: > While apcupsd works fine with one ups hooked up, apcupsd is not able > to find multiple ones like it did on RELENG_7. Looking at the way > the code is compiled, it uses the generic libusd driver to talk to > and find the UPSes on RELENG_8. Not sure if this is a bug with > apcupsd or how it works with RELENG_8. > > Running the daemon in debug mode, it loops through the following > code, but always finds the same UPS and never 'moves on' to the next > UPS like it did in RELENG_7. Has anyone got multiple UPSes working > with apcupsd on RELENG_8 ? > > > /* Initialize libusb */ > Dmsg0(200, "Initializing libusb\n"); > usb_init(); > > /* Enumerate usb busses and devices */ > i = usb_find_busses(); > Dmsg1(200, "Found %d USB busses\n", i); > i = usb_find_devices(); > Dmsg1(200, "Found %d USB devices\n", i); > > /* Iterate over all devices, checking for idVendor=APC */ > bus = usb_get_busses(); > while (bus) > { > dev = bus->devices; > while (dev) > { > Dmsg4(200, "MDT bus loop %s:%s - %04x:%04x\n", > bus->dirname, dev->filename, > dev->descriptor.idVendor, dev->descriptor.idProduct); > > if (dev->descriptor.idVendor == VENDOR_APC) { > Dmsg2(200, "Trying device %s:%s\n", bus->dirname, > dev->filename); if (init_device(ups, dev)) { > /* Successfully found and initialized an UPS */ > astrncpy(ups->device, bus->dirname, sizeof(ups->device)); > astrncat(ups->device, ":", sizeof(ups->device)); > astrncat(ups->device, dev->filename, sizeof(ups->device)); > return 1; > } > } > > dev = dev->next; > } > > bus = bus->next; > } > > /* Failed to find an UPS */ > ups->device[0] = 0; > return 0; > } > > Where as the following are attached. It only is ever able to talk to > the ups on ugen1.2 > > 0[upsmon1]# usbconfig > ugen0.1: at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) > pwr=ON ugen1.1: at usbus1, cfg=0 md=HOST spd=FULL > (12Mbps) pwr=ON ugen2.1: at usbus2, cfg=0 md=HOST > spd=FULL (12Mbps) pwr=ON ugen3.1: at usbus3, cfg=0 > md=HOST spd=FULL (12Mbps) pwr=ON ugen4.1: at usbus4, > cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON ugen0.2: FW:802.n2.D USB FW:n2 APC> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) > pwr=ON > ugen4.2: at usbus4, cfg=0 md=HOST spd=HIGH > (480Mbps) pwr=SAVE > ugen4.3: at usbus4, cfg=0 > md=HOST spd=LOW (1.5Mbps) pwr=ON > ugen0.3: Conversion> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON > ugen4.4: at usbus4, cfg=0 > md=HOST spd=LOW (1.5Mbps) pwr=ON > ugen4.5: Conversion> at usbus4, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON > ugen4.6: at usbus4, cfg=0 > md=HOST spd=LOW (1.5Mbps) pwr=ON > ugen1.2: at usbus1, cfg=0 > md=HOST spd=LOW (1.5Mbps) pwr=ON > 0[upsmon1]# > > > 0.000 apcupsd: apcupsd.c:219 Options parsed. > 0.001 apcupsd: apcconfig.c:803 After config scriptdir: > "/usr/local/etc/apcupsd.a" > 0.001 apcupsd: apcconfig.c:804 After config pwrfailpath: "/var/run/a" > 0.001 apcupsd: apcconfig.c:805 After config nologinpath: "/var/run" > 0.001 apcupsd: apcupsd.c:242 Config file > /usr/local/etc/apcupsd.a/apcupsd.conf processed. > 0.001 apcupsd: :newups.c:102 write_lock at drivers.c:181 > 0.001 apcupsd: drivers.c:183 Looking for driver: usb > 0.001 apcupsd: drivers.c:187 Driver dumb is configured. > 0.001 apcupsd: drivers.c:187 Driver apcsmart is configured. > 0.001 apcupsd: drivers.c:187 Driver net is configured. > 0.001 apcupsd: drivers.c:187 Driver usb is configured. > 0.001 apcupsd: drivers.c:190 Driver usb found and attached. > 0.001 apcupsd: newups.c:108 write_unlock at drivers.c:207 > 0.001 apcupsd: drivers.c:209 Driver ptr=0x805c8e4 > 0.001 apcupsd: apcupsd.c:261 Attached to driver: usb > 0.003 apcupsd: newups.c:102 write_lock at generic-usb.c:614 > 0.003 apcupsd: generic-usb.c:398 Initializing libusb The FreeBSD LibUSB v0.1 reports the wrong number of busses and devices. I can fix this. > 0.003 apcupsd: generic-usb.c:403 Found 0 USB busses > 0.007 apcupsd: generic-usb.c:405 Found 0 USB devices The problem is that the UPS code is designed to attach to the first matching device only. LibUSB does not hide devices with drivers already attached, which I think your utility assumes. You should use: pidfile, see man pidfile To create a temporary file with some string which consists of all numbers in udev->filename, separated by ".". Or USB LibUSB v.1.0! I've made a small patch, but it won't fix your issue :-( http://p4web.freebsd.org/@@177865?ac=10 --HPS