Controlling Multiple UPSes on one Machine (using USB devices)

View: New views
3 Messages — Rating Filter:   Alert me  

Controlling Multiple UPSes on one Machine (using USB devices)

by Ronald J. Yacketta-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Good Morning List!

I have been going over http://www.apcupsd.org/manual/Controlli_Multiple_UPSes_on.html and doing some minor research to determine if it is possible to connect a single Linux box to multiple APC using USB. The method described in the doc listed assumes the usage of a tty (either a standard serial or a USB serial).

After connecting both APC's I see the following in dmesg :

usb 5-2: new low speed USB device using uhci_hcd and address 2
usb 5-2: configuration #1 chosen from 1 choice
hiddev96hidraw0: USB HID v1.10 Device [APC Back-UPS ES 550 FW:840.B2.D USB FW:B2] on usb-0000:00:1d.3-2
usb 5-2: New USB device found, idVendor=051d, idProduct=0002
usb 5-2: New USB device strings: Mfr=3, Product=1, SerialNumber=2
usb 5-2: Product: Back-UPS ES 550 FW:840.B2.D USB FW:B2
usb 5-2: Manufacturer: APC
usb 5-2: SerialNumber: 3B0749X50644 
usb 5-1: new low speed USB device using uhci_hcd and address 3
usb 5-1: configuration #1 chosen from 1 choice
hiddev97hidraw1: USB HID v1.10 Device [APC Back-UPS ES 550 FW:840.B3.D USB FW:B3] on usb-0000:00:1d.3-1
usb 5-1: New USB device found, idVendor=051d, idProduct=0002
usb 5-1: New USB device strings: Mfr=3, Product=1, SerialNumber=2
usb 5-1: Product: Back-UPS ES 550 FW:840.B3.D USB FW:B3
usb 5-1: Manufacturer: APC
usb 5-1: SerialNumber: 3B0751X42018

I then ran the examples/make-hiddev script and compiled examples/hid-ups.c as well as some random C code I found on the net (http://www.frogmouth.net/hid-doco/c514.html) specifically Example 2. I used both programs to ensure that I could communicate to the HID devices (yah, not needed but wanted to be sure :) ). After that was all said and done I then proceeded to configure the conf files using the /dev/usb/hid/hiddev[0-15] device(s).

Output from Example 2 code:
[root@zedd ~]# ./a.out /dev/usb/hid/hiddev0
vendor 0x051d product 0x0002 version 0x0106 has 1 application and is on bus: 5 devnum: 2 ifnum: 0
[root@zedd ~]# ./a.out /dev/usb/hid/hiddev1
vendor 0x051d product 0x0002 version 0x0106 has 1 application and is on bus: 2 devnum: 2 ifnum: 0
[root@zedd ~]#

When I attempted to start up both apcupsd's only one would start, did some digging and noticed that on FC9 the pid file is /var/run/${base}.pid which expands to /var/run/apcupsd.pid for BOTH init scripts. Did some more digging and found that you can pass a --pidfile argument to the daemon function (which resides in /etc/rc.d/init.d/functions), so off I went and modified the apcupsd init scripts and added --pidfile=${APCPID} to the daemon call.

Here is the before and after init script changes:

    start)
       rm -f /usr/apcuspd1/etc/powerfail
       rm -f /etc/nologin
       echo -n "Starting UPS monitoring:"
       daemon  /sbin/apcupsd1/apcupsd -f /usr/apcuspd1/etc/apcupsd.conf
       RETVAL=$?
       echo
       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apcupsd1
       ;;

=====

    start)
       rm -f /usr/apcuspd1/etc/powerfail
       rm -f /etc/nologin
       echo -n "Starting UPS monitoring:"
       daemon --pidfile=${APCPID} /sbin/apcupsd1/apcupsd -f /usr/apcuspd1/etc/apcupsd.conf
       RETVAL=$?
       echo
       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apcupsd1
       ;;


Hope this helps someone on this list :)


-Ron


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Apcupsd-users mailing list
Apcupsd-users@...
https://lists.sourceforge.net/lists/listinfo/apcupsd-users

Re: Controlling Multiple UPSes on one Machine (using USB devices)

by Ronald J. Yacketta-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Minor update ;)

No need to run make-hiddev on FC9, looks like udev takes care of that for us and creates the /dev/hiddev[0-#] devices. So, we can use /dev/hiddev[0-#] in the apcupsd.conf files.

-Ron

Ronald J. Yacketta wrote:
Good Morning List!

I have been going over http://www.apcupsd.org/manual/Controlli_Multiple_UPSes_on.html and doing some minor research to determine if it is possible to connect a single Linux box to multiple APC using USB. The method described in the doc listed assumes the usage of a tty (either a standard serial or a USB serial).

After connecting both APC's I see the following in dmesg :

usb 5-2: new low speed USB device using uhci_hcd and address 2
usb 5-2: configuration #1 chosen from 1 choice
hiddev96hidraw0: USB HID v1.10 Device [APC Back-UPS ES 550 FW:840.B2.D USB FW:B2] on usb-0000:00:1d.3-2
usb 5-2: New USB device found, idVendor=051d, idProduct=0002
usb 5-2: New USB device strings: Mfr=3, Product=1, SerialNumber=2
usb 5-2: Product: Back-UPS ES 550 FW:840.B2.D USB FW:B2
usb 5-2: Manufacturer: APC
usb 5-2: SerialNumber: 3B0749X50644 
usb 5-1: new low speed USB device using uhci_hcd and address 3
usb 5-1: configuration #1 chosen from 1 choice
hiddev97hidraw1: USB HID v1.10 Device [APC Back-UPS ES 550 FW:840.B3.D USB FW:B3] on usb-0000:00:1d.3-1
usb 5-1: New USB device found, idVendor=051d, idProduct=0002
usb 5-1: New USB device strings: Mfr=3, Product=1, SerialNumber=2
usb 5-1: Product: Back-UPS ES 550 FW:840.B3.D USB FW:B3
usb 5-1: Manufacturer: APC
usb 5-1: SerialNumber: 3B0751X42018

I then ran the examples/make-hiddev script and compiled examples/hid-ups.c as well as some random C code I found on the net (http://www.frogmouth.net/hid-doco/c514.html) specifically Example 2. I used both programs to ensure that I could communicate to the HID devices (yah, not needed but wanted to be sure :) ). After that was all said and done I then proceeded to configure the conf files using the /dev/usb/hid/hiddev[0-15] device(s).

Output from Example 2 code:
[root@zedd ~]# ./a.out /dev/usb/hid/hiddev0
vendor 0x051d product 0x0002 version 0x0106 has 1 application and is on bus: 5 devnum: 2 ifnum: 0
[root@zedd ~]# ./a.out /dev/usb/hid/hiddev1
vendor 0x051d product 0x0002 version 0x0106 has 1 application and is on bus: 2 devnum: 2 ifnum: 0
[root@zedd ~]#

When I attempted to start up both apcupsd's only one would start, did some digging and noticed that on FC9 the pid file is /var/run/${base}.pid which expands to /var/run/apcupsd.pid for BOTH init scripts. Did some more digging and found that you can pass a --pidfile argument to the daemon function (which resides in /etc/rc.d/init.d/functions), so off I went and modified the apcupsd init scripts and added --pidfile=${APCPID} to the daemon call.

Here is the before and after init script changes:

    start)
       rm -f /usr/apcuspd1/etc/powerfail
       rm -f /etc/nologin
       echo -n "Starting UPS monitoring:"
       daemon  /sbin/apcupsd1/apcupsd -f /usr/apcuspd1/etc/apcupsd.conf
       RETVAL=$?
       echo
       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apcupsd1
       ;;

=====

    start)
       rm -f /usr/apcuspd1/etc/powerfail
       rm -f /etc/nologin
       echo -n "Starting UPS monitoring:"
       daemon --pidfile=${APCPID} /sbin/apcupsd1/apcupsd -f /usr/apcuspd1/etc/apcupsd.conf
       RETVAL=$?
       echo
       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apcupsd1
       ;;


Hope this helps someone on this list :)


-Ron


------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________ Apcupsd-users mailing list Apcupsd-users@... https://lists.sourceforge.net/lists/listinfo/apcupsd-users

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Apcupsd-users mailing list
Apcupsd-users@...
https://lists.sourceforge.net/lists/listinfo/apcupsd-users

Re: Controlling Multiple UPSes on one Machine (usingUSB devices)

by Adam Kropelin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ronald J. Yacketta wrote:
> I have been going over
> http://www.apcupsd.org/manual/Controlli_Multiple_UPSes_on.html and
> doing some minor research to determine if it is possible to connect
> a single
> Linux box to multiple APC using USB.

This is actually much easier these days. The docs are out of date. I should
replace that section of the manual with this:
<http://www.kroptech.com/mailimport/showmsg.php?msg_id=3120658615&db_name=apcupsd-users>

On Linux I highly recommend using a udev rule to name your UPSes based on
serial number. This prevents the device node names from changing if the
UPSes happen to be plugged into different USB ports. See the Linux USB
section of the apcupsd manual for info on how to do that.

--Adam


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Apcupsd-users mailing list
Apcupsd-users@...
https://lists.sourceforge.net/lists/listinfo/apcupsd-users
LightInTheBox - Buy quality products at wholesale price!