What's new

Configuring apcupsd

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

tonysamson

Regular Contributor
Hi All,

I'm trying to configure my APC Back-UPS 1100 on my AC66u with Merlin firmware. I think I have installed it already and have also configured the apcupsd.conf.

I am supposed to configure the ISCONFIGURED next.

The problem is that I can't seem to find where it is. Based on my readings, it is supposed to be located in:

/etc/default/apcupsd

But it is not there.

I ran apcaccess and this is what I get:

APC : 001,018,0450
DATE : 2016-02-14 08:57:32 +0000
HOSTNAME : RT-AC66U-9EE8
VERSION : 3.14.13 (02 February 2015) unknown
UPSNAME : ups1
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2015-08-01 00:00:29 +0000
STATUS : COMMLOST
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
STATFLAG : 0x05000100
END APC : 2016-02-14 10:50:51 +0000

Please help. Thanks.
 
I am supposed to configure the ISCONFIGURED next.

The problem is that I can't seem to find where it is. Based on my readings, it is supposed to be located in:

/etc/default/apcupsd
Forget about it, just run apcupsd from /opt/etc/init.d folder.
 
Forget about it, just run apcupsd from /opt/etc/init.d folder.

Hi thanks for the reply.

How am I supposed to do that? Hope you can point me towards the right direction. Is there a tutorial or a guide that I can read for this one?

Thank you so much..
 
I tried running it from that location by typing apcupsd but nothing happened. Then I ran apctest but I still got this:

2016-02-14 11:39:11 apctest 3.14.13 (02 February 2015) unknown
Checking configuration ...
sharenet.type = Network & ShareUPS Disabled
cable.type = USB Cable
mode.type = USB UPS Driver
apctest FATAL ERROR in apctest.c at line 313
Unable to create UPS lock file.
If apcupsd or apctest is already running,
please stop it and run this program again.
apctest error termination completed
 
Apcupsd is running. That's why apctest says some resources were locked. You may type ps to find running apcupsd in the background.
So what you want to do next with it?
 
Hi ryzhov_al,

If I run apcaccess I'm still getting this:

STATUS : COMMLOST

Does the above mean that the router is still not communicating with the UPS? Not sure if this is relevant but my UPS is APC Back-UPS 1100.

Also, when I try to access the apcupsd-cgi using my browser, nothing happens.
 
Yes, I can see apcupsd running. Maybe it can't communicate with the UPS?

Here's the apcupsd.conf settings:

UPSNAME ups1
UPSCABLE USB
UPSTYPE apcsmart
# DEVICE /dev/ttyS0
LOCKFILE /opt/var/lock
SCRIPTDIR /opt/etc/apcupsd
PWRFAILDIR /opt/etc
NOLOGINDIR /opt/etc
#ONBATTERYDELAY 6
BATTERYLEVEL 5
MINUTES 3
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /opt/var/log/apcupsd.events
EVENTSFILEMAX 10
#NETTIME 60
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /opt/var/log/apcupsd.status
LOGSTATS off
DATATIME 0
#FACILITY DAEMON
#UPSNAME UPS_IDEN
#BATTDATE mm/dd/yy
#SENSITIVITY H
#WAKEUP 60
#SLEEP 180
#LOTRANSFER 208
#HITRANSFER 253
#RETURNCHARGE 15
#BEEPSTATE T
#LOWBATT 2
#OUTPUTVOLTS 230
#SELFTEST 336
 
Type dmesg to see what the USB-to-serial driver is not loading. It would be /dev/ttyUSB0, for example.
 
Type dmesg to see what the USB-to-serial driver is not loading. It would be /dev/ttyUSB0, for example.

ASUSWRT-Merlin RT-AC66U_3.0.0.4 Mon Nov 2 14:59:04 UTC 2015
admin@RT-AC66U-9EE8:/tmp/home/root# dmesg
start_kernel
Linux version 2.6.22.19 (root@asus) (gcc version 4.2.3) #1 Mon Nov 2 09:59:58 EST 2015
CPU revision is: 00019749
Found an ST compatible serial flash with 32 64KB blocks; total size 2MB
Determined physical RAM map:
memory: 07fff000 @ 00000000 (usable)
memory: 08000000 @ 87fff000 (usable)
On node 0 totalpages: 589823
Normal zone: 1024 pages used for memmap
Normal zone: 0 pages reserved
Normal zone: 130048 pages, LIFO batch:31
HighMem zone: 3583 pages used for memmap
HighMem zone: 455168 pages, LIFO batch:31
Built 1 zonelists. Total pages: 585216
Kernel command line: root=/dev/mtdblock3 console=ttyS0,115200 init=/sbin/preinit
Primary instruction cache 32kB, physically tagged, 4-way, linesize 32 bytes.
Primary data cache 32kB, 4-way, linesize 32 bytes.
Synthesized TLB refill handler (20 instructions).
Synthesized TLB load handler fastpath (32 instructions).
Synthesized TLB store handler fastpath (32 instructions).
Synthesized TLB modify handler fastpath (31 instructions).
PID hash table entries: 2048 (order: 11, 8192 bytes)
CPU: BCM5300 rev 1 pkg 0 at 600 MHz
Using 300.000 MHz high precision timer.
console [ttyS0] enabled
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 238352k/131068k available (2667k kernel code, 22808k reserved, 532k data, 200k init, 131072k highmem)
Calibrating delay loop... 299.82 BogoMIPS (lpj=1499136)
Mount-cache hash table entries: 512
NET: Registered protocol family 16
PCI: Initializing host
PCI: Reset RC
PCI: Initializing host
PCI: Reset RC
PCI: Fixing up bus 0
PCI/PCIe coreunit 0 is set to bus 1.
PCI: Fixing up bridge
PCI: Setting latency timer of device 0000:01:00.0 to 64
PCI: Fixing up bridge
PCI: Setting latency timer of device 0000:01:00.1 to 64
PCI: Enabling device 0000:01:00.1 (0004 -> 0006)
PCI: Fixing up bus 1
PCI/PCIe coreunit 1 is set to bus 2.
PCI: Fixing up bridge
PCI: Setting latency timer of device 0000:02:00.0 to 64
PCI: Fixing up bridge
PCI: Setting latency timer of device 0000:02:00.1 to 64
PCI: Enabling device 0000:02:00.1 (0004 -> 0006)
PCI: Fixing up bus 2
NET: Registered protocol family 2
Time: MIPS clocksource has been installed.
IP route cache hash table entries: 4096 (order: 2, 16384 bytes)
TCP established hash table entries: 16384 (order: 5, 131072 bytes)
TCP bind hash table entries: 16384 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 16384 bind 16384)
TCP reno registered
highmem bounce pool size: 64 pages
squashfs: version 3.2-r2 (2007/01/15) Phillip Lougher
io scheduler noop registered (default)
HDLC line discipline: version $Revision: 4.8 $, maxframe=4096
N_HDLC line discipline registered.
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
serial8250: ttyS0 at MMIO 0x0 (irq = 8) is a 16550A
serial8250: ttyS1 at MMIO 0x0 (irq = 8) is a 16550A
PPP generic driver version 2.4.2
MPPE/MPPC encryption/compression module registered
NET: Registered protocol family 24
PPPoL2TP kernel driver, V0.18.3
PPTP driver version 0.8.5
pflash: found no supported devices
Boot partition size = 262144(0x40000)
Creating 2 MTD partitions on "sflash":
0x00000000-0x00040000 : "pmon"
0x001f0000-0x00200000 : "nvram"
Found a Zentel NAND flash with 2048B pages or 128KB blocks; total size 128MB
lookup_nflash_rootfs_offset: offset = 0x0
nflash: squash filesystem with lzma found at block 9
Creating 2 MTD partitions on "nflash":
0x00000000-0x02000000 : "linux"
0x0013d26c-0x02000000 : "rootfs"
NAND device: Manufacturer ID: 0x92, Chip ID: 0xf1 (Zentel NAND 128MiB 3,3V 8-bit)
Bad block table found at page 65408, version 0x01
Bad block table found at page 65344, version 0x01
nand_read_bbt: Bad block at 0x07fe0000
Creating 3 MTD partitions on "brcmnand":
0x00000000-0x02000000 : "trx"
0x02000000-0x04000000 : "jffs2"
0x04000000-0x07f00000 : "brcmnand"
dev_nvram_init: _nvram_init
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
u32 classifier
OLD policer on
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (2048 buckets, 16384 max)
ip_tables: (C) 2000-2006 Netfilter Core Team
net/ipv4/netfilter/tomato_ct.c [Nov 2 2015 09:59:57]
ipt_account 0.1.21 : Piotr Gasidlo <quaker@barbara.eu.org>, http://code.google.com/p/ipt-account/
NET: Registered protocol family 1
NET: Registered protocol family 10
ip6_tables: (C) 2000-2006 Netfilter Core Team
NET: Registered protocol family 17
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
All bugs added by David S. Miller <davem@redhat.com>
VFS: Mounted root (squashfs filesystem) readonly.
Freeing unused kernel memory: 200k freed
Warning: unable to open an initial console.
Failed to execute /sbin/preinit. Attempting defaults...
Algorithmics/MIPS FPU Emulator v1.5
ctf: module license 'Proprietary' taints kernel.
et_module_init: passivemode set to 0x0
et_module_init: et_txq_thresh set to 0xce4
PCI: Setting latency timer of device 0000:00:01.0 to 64
bcm_robo_enable_switch: EEE is disabled
eth0: Broadcom BCM47XX 10/100/1000 Mbps Ethernet Controller 6.30.163.2002 (r382208)
wl_module_init: passivemode set to 0x0
PCI: Enabling device 0000:01:01.0 (0000 -> 0002)
PCI: Setting latency timer of device 0000:01:01.0 to 64
eth1: Broadcom BCM4331 802.11 Wireless Controller 6.30.163.2002 (r382208)
PCI: Enabling device 0000:02:01.0 (0000 -> 0002)
PCI: Setting latency timer of device 0000:02:01.0 to 64
eth2: Broadcom BCM4360 802.11 Wireless Controller 6.30.163.2002 (r382208)
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
br0: starting userspace STP failed, staring kernel STP
vlan1: add 33:33:00:00:00:01 mcast address to master interface
vlan1: add 01:00:5e:00:00:01 mcast address to master interface
vlan1: dev_set_promiscuity(master, 1)
device eth0 entered promiscuous mode
device vlan1 entered promiscuous mode
device eth1 entered promiscuous mode
wlc_phy_cal_init_acphy: NOT Implemented
device eth2 entered promiscuous mode
br0: port 3(eth2) entering listening state
br0: port 2(eth1) entering listening state
br0: port 1(vlan1) entering listening state
br0: port 3(eth2) entering learning state
br0: port 2(eth1) entering learning state
br0: port 1(vlan1) entering learning state
vlan1: add 33:33:00:00:00:02 mcast address to master interface
br0: topology change detected, propagating
br0: port 3(eth2) entering forwarding state
br0: topology change detected, propagating
br0: port 2(eth1) entering forwarding state
br0: topology change detected, propagating
br0: port 1(vlan1) entering forwarding state
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
SCSI subsystem initialized
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
ufsd: driver (8.6 U86_r187446_b122, LBD=ON, acl, ioctl, rwm, ws, sd) loaded at c027c000
NTFS (with native replay) support included
optimized: speed
Build_for__asus_n66u_2011-10-27_U86_r187446_b122

ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
PCI: Setting latency timer of device 0000:00:04.1 to 64
ehci_hcd 0000:00:04.1: EHCI Host Controller
ehci_hcd 0000:00:04.1: new USB bus registered, assigned bus number 1
ehci_hcd 0000:00:04.1: EHCI Fastpath: New EHCI driver starting
ehci_hcd 0000:00:04.1: irq 6, io mem 0x18004000
ehci_hcd 0000:00:04.1: USB 0.0 started, EHCI 1.00
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
PCI: Setting latency timer of device 0000:00:04.0 to 64
ohci_hcd 0000:00:04.0: OHCI Host Controller
ohci_hcd 0000:00:04.0: new USB bus registered, assigned bus number 2
ohci_hcd 0000:00:04.0: irq 6, io mem 0x18009000
usb usb2: configuration #1 chosen from 1 choice
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
usbcore: registered new interface driver usblp
drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver
usb 1-1: new high speed USB device using ehci_hcd and address 2
usb 1-1: configuration #1 chosen from 1 choice
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
usbcore: registered new interface driver asix
usbcore: registered new interface driver cdc_ether
usbcore: registered new interface driver rndis_host
cdc_ncm: 14-Mar-2012
usbcore: registered new interface driver cdc_ncm
usbcore: registered new interface driver cdc_wdm
usbcore: registered new interface driver qmi_wwan
cdc_mbim: loaded
usbcore: registered new interface driver cdc_mbim
usb 1-1.1: new full speed USB device using ehci_hcd and address 3
usb 1-1.1: configuration #1 chosen from 1 choice
usb 1-1.2: new high speed USB device using ehci_hcd and address 4
usb 1-1.2: configuration #1 chosen from 1 choice
scsi0 : SCSI emulation for USB Mass Storage devices
scsi 0:0:0:0: Direct-Access PNY USB Flash Drive 1100 PQ: 0 ANSI: 4
sd 0:0:0:0: [sda] 31299584 512-byte hardware sectors (16025 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda: sda1 sda2
sd 0:0:0:0: [sda] Attached SCSI removable disk
sd 0:0:0:0: Attached scsi generic sg0 type 0
nf_conntrack_rtsp v0.6.21 loading
nf_nat_rtsp v0.6.21 loading
usb 1-1.1: USB disconnect, address 3
usb 1-1.1: new full speed USB device using ehci_hcd and address 5
usb 1-1.1: configuration #1 chosen from 1 choice
usb 1-1.1: USB disconnect, address 5
usb 1-1.1: new full speed USB device using ehci_hcd and address 6
usb 1-1.1: configuration #1 chosen from 1 choice
 
Last edited:
I really don't know what to look for
Which USB-to-serial chip does your RS232-to-USB cable use? Here's the choices:
PL2303
FTDI
CH340
KEYSPAN

Now you want someone to compile a USB-to-serial driver for the MIPS platform because ASUS failed to do so.
 
Well I guess this is the end of the line for me. I need to read up on this and find out what chip the Back-UPS 1100va is using.

Thanks for pointing to the right direction
 
I need to read up on this and find out what chip the Back-UPS 1100va is using?
No. The chip is built into the cable. The cable also does level shifting from the UPS RS232 voltage of -12V/+12V down to the USB TTL-level voltage of 0V/+5V. You can buy these cables on eBay for $2 a piece. The cheap ones have a PL2303 chip. My UPS is not yet connected to the router, therefore I am not 100% sure.
 
Oh, I see. My UPS doesn't have this RS-232 port on it. It uses USB Type B port like the one used for printers. Could it be that the firmware doesn't have the proper driver for my UPS?
 
My UPS doesn't have this RS-232 port on it. It uses USB Type B port like the one used for printers.
Do you have a modern Linux OS where you can plug it in? Then you can type dmesg to see what USB-to-serial driver it loads. I would be surprise if it requires a proprietary USB driver for the APC UPS.

Unplug the UPS' USB cable from the computer. Boot your modern Linux OS. Wait 'til it finishes booting. Plug in the UPS' USB cable to the computer. Now type dmesg to see what USB-to-serial driver got loaded.
 
I've found what modules was used with my APC BackUPS 650.
Code:
# cat /opt/etc/init.d/S00firmware_modules
#!/bin/sh

prefix="/opt"
PATH=${prefix}/bin:${prefix}/sbin:/sbin:/bin:/usr/sbin:/usr/bin

start() {
   insmod /opt/lib/modules/input-core.ko
   insmod /opt/lib/modules/hid.ko
   insmod /opt/lib/modules/usbhid.ko
   }

stop() {
   rmmod usbhid
   rmmod hid
   rmmod input-core
   }

status() {
   echo "nothing to do..."
   }

case "$1" in
   start)
     start
     ;;
   stop)
     stop
     ;;
   restart)
#     stop
     sleep 2
#     start
     ;;
   status) status
     ;;
   *)
     echo "Usage: $0 (start|stop|restart|status)"
     exit 1
     ;;
esac

exit 0
I hope they are still compiled with kernel, but not included into f\w image.
 
For Linux Mint 13, my CyberPower 1325VA shows this dmesg.
Code:
usb 2-2.2: new low-speed USB device number 5 using uhci_hcd
generic-usb 0003:0764:0501.0002: hiddev0,hidraw1: USB HID v1.10 Device [CPS  CP 1350C] on usb-0000:02:00.0-2.2/input0


For ASUS RT-AC68U router, my CyberPower 1325VA shows only this single line dmesg.
Code:
usb 2-2.4: new low speed USB device using ehci_hcd and address 16


So now I will try and see what happens when those USB_HID is complied back in. I want to see this working too.
 
Thank you to ryzhov_al for the excellent patch. I got it working with the RT-AC68U router and the CyberPower 1325VA UPS.

cat /opt/var/log/apcupsd.events
Code:
2016-02-16 17:24:25 -0500  apcupsd 3.14.13 (02 February 2015) unknown startup succeeded
2016-02-16 17:25:15 -0500  Power failure.
2016-02-16 17:25:21 -0500  Running on UPS batteries.
2016-02-16 17:25:50 -0500  Mains returned. No longer on UPS batteries.
2016-02-16 17:25:50 -0500  Power is back. UPS running on mains.


I made this changes to the kernel config of the Asuswrt-Merlin firmware 380.57 for RT-AC68U router. Rebuilding the firmware will produce the three new kernel modules that will allow the router to communicate with the UPS's USB port.
~/asuswrt-merlin/release/src-rt-6.x.4708/linux/linux-2.6.36/config_base.6a
Code:
CONFIG_HID_SUPPORT=y
CONFIG_HID=m
CONFIG_HIDRAW=y
CONFIG_USB_HID=m
CONFIG_USB_HIDDEV=y


Copy the kernel modules (input-core.ko, hid.ko, usbhid.ko) to the router /jffs/bin and manually loaded them.
Code:
/sbin/insmod /jffs/bin/input-core.ko
/sbin/insmod /jffs/bin/hid.ko
/sbin/insmod /jffs/bin/usbhid.ko


The dmesg shows the kernel modules loaded OK.
Code:
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver


Connect the USB cable from the UPS to the router's USB 2.0 port. And dmesg shows that the router can see the UPS now.
Code:
usb 2-2.2: new low speed USB device using ehci_hcd and address 17
generic-usb 0003:0764:0501.0001: hiddev0,hidraw0: USB HID v1.10 Device [CPS  CP 1350C] on usb-0000:00:0a.1-2.2/input0


Install the apcupsd package from Entware-ng and change some configuration options.
/opt/etc/apcupsd/apcupsd.conf
Code:
UPSNAME cyberpower
UPSCABLE usb
UPSTYPE usb
#DEVICE /dev/ttyS0


Here's the kernel modules for RT-AC68U router. It is not for MIPS routers. Sorry I don't own an AC66U.
asuswrt-merlin-380.57-ARM-usbhid-modules.tar.gz
Code:
md5sum: a49752a82328b5b14963c3fea1bfca59
sha256sum: e45085820393e903428b8f799db1352b31eb2065f5c0addf1a35c6bb1c71580d
 
Last edited:
For someone with little knowledge but is interested for things like this, I guess this is a learning challenge for me this weekend. Hoping you guys, ryzhov_al and ASAT, will be around to guide me. Thanks.
 
Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top