USB APC UPS issue with FreeBSD 8

Good afternoon. I've been running Freebsd for about a year now with no issues. But, now I've got one.

I have an APC USB UPS for the FreeBSD server, and it worked great with 7.1 and 7.2. Upon upgrading to 8.0, I see that the USB stack has been rewritten, and now apcupsd can no longer see the UPS. Does anybody have any suggestions? I verified that this worked immediately before upgrading, because I checked it via the CGI interface on my apache server.

My boot message in 8:

Code:
ugen0.3: <American Power Conversion> at usbus0

My boot message in 7 (when it worked):

Code:
ugen1: <American Power Conversion Back-UPS CS 350 FW:805.q5.D USB FW:q5, class 0/0, rev 1.10/0.06, addr 3> on uhub0

My apcupsd.events log:

Code:
apcupsd FATAL ERROR in bsd-usb.c at line 735
Cannot find UPS device --

This seems to be the only issue with the upgrade. Everything else (apache, mysql, java, etc.) seems to be working fine. Thanks!
 
I was looking through their official user manual, and it looks like you can specify a DEVICE explicitly. However, I don't know if that is necessary or even supported with usb.

edit: read this section in particular.

-------

You should probably back up your current config, and then rebuild / reinstall the apcupsd port (if you have not already).
 
Thanks for the reply! Yeah, I had looked at that before, and the conf file actually says to leave that blank if using USB. Regardless, I put in my device name for the guy, restarted apcupsd, and it didn't work.
 
I am confirming that I have apcupsd installed on FreeBSD 7.2-STABLE and FreeBSD 8.0-RELEASE (same machine). I don't have any issues with it.

What helped me to install and configure apcupsd in FreeBSD was this HOWTO:

HTML:
http://www.freebsddiary.org/apcupsd.php
 
i had the same problem after 7.2 to 8.0 upgrade with apcupsd and with my HP usb printer. i recompiled and reinstall apcupsd and foo2zjs. this helped. or, hmm... may be i updated apcupsd to the latest one, but all troubles with usb devices was solved after reinstalling the application.
 
No joy. I'll keep looking, I guess. For you guys that are working, can you tell me what your output for the boot looks like for your UPS? Does it look like the descriptive one from 7.* or the non-specific one for 8, that I posted?

Thanks!
 
tlc337 said:
No joy. I'll keep looking, I guess. For you guys that are working, can you tell me what your output for the boot looks like for your UPS? Does it look like the descriptive one from 7.* or the non-specific one for 8, that I posted?

Thanks!

For me, mine looks exactly the one you have posted for the FreeBSD 7.X output (with the exception of the UPS model, firmware, etc). I am running FreeBSD 8.0-RELEASE on the amd64 platform.

You have re-installed apcupsd, so I am also under the assumption that you have completely remove the software and attempted to install apcupsd from scratch (if it, give it a shot). Otherwise, the only thing I can think of is trying a different USB port? Sounds illogical, I can't think of a reason why it does not work, but ... what do you got to lose?
I have a strong feeling that this entire issue is caused by something silly that is being overlooked by assumption.
 
Yes, I think I completely uninstalled it, but I guess I could've missed something:

Code:
cd /usr/ports/sysutils/apcupsd
make deinstall
pkg_info |grep apcupsd (nothing found)
make install

However, none of my conf files needed to be reentered, so I guess technically, I didn't install from scratch.

I will try switching ports next. Thanks.
 
Hrmm .. I suppose you are not the only one with issues. Just rebooted my system and noticed that apcupsd was not loaded during startup. I have no issues when entering ' apcupsd ' in command line, to which it loads fine and works as expected.

I do have the ' apcupsd_enabled="YES" ' entry in my /etc/rc.conf , but the logs don't show anything useful to troubleshoot it.
 
Code:
ugen0.2: <American Power Conversion> at usbus0
Code:
FreeBSD hp.aicom.loc 8.0-RELEASE-p1 FreeBSD 8.0-RELEASE-p1 #0: Sun Dec 13 02:24:13 EET 2009     gkontos@hp.aicom.loc:/usr/obj/usr/src/sys/GENERIC  amd64
What options do you pass when you compile ?
Here is mine:
Code:
gkontos@hp>cat /var/db/ports/apcupsd/options 
# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for apcupsd-3.14.5_1
_OPTIONS_READ=apcupsd-3.14.5_1
WITHOUT_APCSMART_DRV=true
WITH_APCDUMB_DRV=true
WITHOUT_CLIENT_ONLY=true
WITHOUT_CGI=true
WITH_PCNET_DRV=true
WITH_USB=true
WITH_SNMP_DRV=true
WITH_TCP_WRAPPERS=true
WITHOUT_TEST_DRV=true
WITHOUT_GAPCMON=true
 
Code:
# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for apcupsd-3.14.5_1
_OPTIONS_READ=apcupsd-3.14.5_1
WITHOUT_APCSMART_DRV=true
WITHOUT_APCDUMB_DRV=true
WITHOUT_CLIENT_ONLY=true
WITH_CGI=true
WITH_PCNET_DRV=true
WITH_USB=true
WITH_SNMP_DRV=true
WITH_TCP_WRAPPERS=true
WITHOUT_TEST_DRV=true
WITHOUT_GAPCMON=true
 
Hey... I had the same issue here and I worked through it by grabbing the latest version of APCUPSD (3.14.7) from the home website, applying the patches from /usr/ports/sysutils/apcupsd/files and then configuring and installing by hand.

First I had install the port with "make install".

Then apply the patches:

Code:
$ tar zxf apcupsd-3.14.7.tar.gz
$ cd apcupsd-3.14.7
$  (for _patch in $(find /usr/ports/sysutils/apcupsd/files -type f -name 'patch-*'); do patch -p0 < ${_patch}; done)
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- configure.orig     2009-03-12 00:42:12.000000000 +0300
|+++ configure  2009-03-12 00:43:17.000000000 +0300
--------------------------
Patching file configure using Plan A...
Hunk #1 succeeded at 10568 (offset -55 lines).
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- ./src/apcaccess.c.orig     2008-01-27 18:22:58.000000000 +0200
|+++ ./src/apcaccess.c  2008-06-29 14:17:12.000000000 +0300
--------------------------
Patching file ./src/apcaccess.c using Plan A...
Hunk #1 succeeded at 68.
Hunk #2 succeeded at 102.
Hunk #3 succeeded at 131.
done
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- ./src/powerflute.c.orig    2008-01-27 18:22:57.000000000 +0200
|+++ ./src/powerflute.c 2008-06-29 14:16:28.000000000 +0300
--------------------------
Patching file ./src/powerflute.c using Plan A...
Hunk #1 succeeded at 28.
done

To ensure I was configuring in basically the same way as the port, I went ahead and grabbed the configure line from the top of /usr/ports/sysutils/apcupsd/work/apcupd-3.14.5:

Code:
$ head /usr/ports/sysutils/apcupsd/work/apcupsd-3.14.5/config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by configure, which was
generated by GNU Autoconf 2.59.  Invocation command line was

  $ ./configure --sbindir=/usr/local/sbin --with-nologin=/var/run --disable-install-distdir --sysconfdir=/usr/local/etc/apcupsd --with-serial-
dev=/dev/usv --enable-apcsmart --disable-dumb --enable-pcnet --enable-usb --disable-snmp --with-libwrap=yes --with-generic-usb --prefix=/usr
/local --mandir=/usr/local/man --infodir=/usr/local/info/ --build=i386-portbld-freebsd8.0

## --------- ##
## Platform. ##

And ran it:

Code:
$ ./configure --sbindir=/usr/local/sbin --with-nologin=/var/run --disable-install-distdir --sysconfdir=/usr/local/etc/apcupsd --with-serial-
dev=/dev/usv --enable-apcsmart --disable-dumb --enable-pcnet --enable-usb --disable-snmp --with-libwrap=yes --with-generic-usb --prefix=/usr
/local --mandir=/usr/local/man --infodir=/usr/local/info/ --build=i386-portbld-freebsd8.0

... tons of autoconf output ...

Configuration on Mon Dec 21 11:46:08 MST 2009:

  Host:                       i386-portbld-freebsd8.0 -- freebsd 8.0-RELEASE-p1
  Apcupsd version:            3.14.7 (1 August 2009)
  Source code location:       .
  Install binaries:           /usr/local/sbin
  Install config files:       /usr/local/etc/apcupsd
  Install man files:          /usr/local/man
  Nologin file in:            /var/run
  PID directory:              /var/run
  LOG dir (events, status)    /var/log
  LOCK dir (for serial port)  /var/spool/lock
  Power Fail dir              /var/run
  Compiler:                   g++ 4.2.1
  Compiler flags:              -g -O2 -fno-exceptions -fno-rtti -Wall 
  Linker:                     gcc
  Linker flags:                -pthread
  Host and version:           freebsd 8.0-RELEASE-p1
  Shutdown Program:           /sbin/shutdown
  Port/Device:                /dev/usv
  Network Info Port (CGI):    3551
  UPSTYPE                     apcsmart
  UPSCABLE                    smart

  drivers (no-* are disabled): apcsmart no-dumb net generic-usb no-snmp pcnet no-test

  enable-nis:                 yes
  with-nisip:                 0.0.0.0
  enable-cgi:                 no
  with-cgi-bin:               /etc/apcupsd
  with-libwrap:               yes
  enable-pthreads:            yes
  enable-dist-install:        no
  enable-gapcmon:             no
  
Configuration complete: Run 'gmake' to build apcuspd.

And then ran 'gmake && gmake install'. After that I was able to start fine using '/usr/local/etc/rc.d/apcupsd start'.

Hopefully somebody will get the port updated to the latest so others won't have to go through this, but it did work for me. I haven't yet submitted the PR, but I will soon.
 
tcl337,
have you tried something like
Code:
UPSCABLE usb
UPSTYPE usb
DEVICE /dev/ugen0.3 
# (your device as it appears in /dev)
in your /usr/local/etc/apcupsd/apcupsd.conf ?
 
to achix:

Yes, I did try that. Thank you for the suggestion, though.

to benschumacher:

Wow. Thanks, man. This is extremely helpful. Although, now I'm having a different problem. I downloaded, and applied the patches like you did. I couldn't run the for loop, though, I just had to do the patches one by one for some reason.

But, now when I do a configure, it tells me this:

Code:
configure: error: Found system GD library but no header file.

My gd.h is in the same path where it finds the rest of the header files. I googled this error and some other people were having this issue earlier in the year, but there are no other notes. Thanks, though.
 
tlc337 said:
I couldn't run the for loop, though, I just had to do the patches one by one for some reason.

Run it from within bash(1).
However, i dont think that a seemingly different way of compilation outside the ports system would help somehow.
 
Oh, ha. Yeah, that would do it.

Yeah, doing this, it didn't really help, but I haven't tracked down the problem with GD. When I run portmaster vanilla install on apcupsd, it runs fine, but when I try to do configure in this manner, I get the GD problem (even though my header files are correct). If ben is really going to submit a patch, then I'll probably just wait for ports to get upgraded.

Thx.
 
why dont you try to upgrade the port your self, and then try building the port again, by the normal procedure?

a) edit Makefile and put PORTVERSION= 3.14.7
b) replace
MD5 (apcupsd-3.14.7.tar.gz) = IGNORE
SHA256 (apcupsd-3.14.7.tar.gz) = IGNORE
SIZE (apcupsd-3.14.7.tar.gz) = IGNORE
in /usr/ports/sysutils/apcupsd/distinfo

and build the port.
 
I tried it, and it is painfully obvious that I only know enough about this stuff to be dangerous.

As a test, I added the binary package, and that runs fine. I can run apctest, and it comes back good. However, the pkg_add version doesn't compile with the CGI stuff which I need. So, I thought, maybe it's the CGI stuff that's killing the compile. Nope. If I remove the cgi stuff from the config, it still won't run past apctest.

Anyway, thanks for all of your help.

Edit: I don't know what happened, but now the CGI stuff is working from pkg_add. LOL.
 
benschumacher said:
First I had install the port with "make install".

And then ran 'gmake && gmake install'. After that I was able to start fine using '/usr/local/etc/rc.d/apcupsd start'.

Thanks for the info, but are you installing 3.14.5 first?

I dont have '/usr/local/etc/rc.d/apcupsd start' after following the instructions.

Thanks
 
Well, nevermind...I just needed to run apcupsd start, without the path.

Pretty sure after following benschumacher's instructions, everything seems to be working here, though I havent pulled the plug.

Code:
$ apcaccess status
APC      : 001,024,0607
DATE     : Tue Dec 28 11:27:34 CST 2009
HOSTNAME : dru.home
VERSION  : 3.14.7 (1 August 2009) freebsd
UPSNAME  : dru.home
CABLE    : USB Cable
MODEL    : Back-UPS 500 
UPSMODE  : Stand Alone
STARTTIME: Tue Dec 28 11:27:32 CST 2009
STATUS   : ONLINE 
BCHARGE  : 100.0 Percent
TIMELEFT :  23.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
NUMXFERS : 0
TONBATT  : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
STATFLAG : 0x07000008 Status Flag
MANDATE  : 2003-07-01
SERIALNO : BB0327006288
FIRMWARE : 6.4.D USB FW: c1 
APCMODEL : Back-UPS 500 
END APC  : Tue Dec 28 11:27:35 CST 2009

Code:
# apctest
2009-12-28 11:26:51 apctest 3.14.7 (1 August 2009) freebsd
Checking configuration ...
Attached to driver: usb
sharenet.type = DISABLE
cable.type = USB_CABLE

You are using a USB cable type, so I'm entering USB test mode
mode.type = USB_UPS
Setting up the port ...
Hello, this is the apcupsd Cable Test program.
This part of apctest is for testing USB UPSes.

Getting UPS capabilities...SUCCESS

Please select the function you want to perform.

1)  Test kill UPS power
2)  Perform self-test
3)  Read last self-test result
4)  Change battery date
5)  View battery date
6)  View manufacturing date
7)  Set alarm behavior
8)  Set sensitivity
9)  Set low transfer voltage
10) Set high transfer voltage
11) Quit

apcupsd.conf
Code:
## apcupsd.conf v1.1 ##
# 
#  for apcupsd release 3.14.7 (1 August 2009) - freebsd
#
# "apcupsd" POSIX config file

UPSCABLE usb
UPSTYPE usb
DEVICE /dev/ugen1.2
LOCKFILE /var/spool/lock
SCRIPTDIR /usr/local/etc/apcupsd
PWRFAILDIR /var/run
NOLOGINDIR /var/run
ONBATTERYDELAY 6
BATTERYLEVEL 5
MINUTES 3
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 127.0.0.1
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0

rc.conf
Code:
apcupsd_enable="YES"

Code:
$ dmesg
ugen1.2: <American Power Conversion> at usbus1

Code:
$ uname -a
FreeBSD dru.home 8.0-RELEASE FreeBSD 8.0-RELEASE #1: Mon Dec 28 16:15:34 CST 2009     Dru@dru.home:/usr/obj/usr/src/sys/PLANETPISS  i386


Have to run apcupsd start manually, still havent figured the correct line to add to my Openbox autostart.sh, but thats unrelated.
 
Just had this same issue... comment out the DEVICE line... apcupsd will default to search for the correct device itself.
Worked like a charm for me. Just ran a power-loss test today after figuring this out.
 
Last edited by a moderator:
Back
Top