Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: MGE Ellipse 300 on gentoo
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Sat Aug 20, 2005 3:01 pm    Post subject: HOWTO: MGE Ellipse 300 on gentoo Reply with quote

I recently bought a UPS and wanted to take full advantage of this. I found some guidelines, but had to figure out a lot myself. Since I don't want this knowledge to void I'm writing my first howto.
Other related howto's:

What is it about?

  • MGE pulsar ellipse 300 USBS (probabely other MGE's too)
  • Connected via USB, NOT serial.
  • hardened kernel, 2.6 series (currently 2.6.11-r15)
  • My computer: some drivers may differ

I chose MGE because they officialy support linux and have done a lot of work to get UPSes to work on linux!!

Step 1: Kernel
You need the following
Code:

Device Drivers  --->
  USB support  --->
    [*] Support for Host-side USB

    [?] EHCI HCD (USB 2.0) support
    [?] OHCI HCD support
    [?] UHCI HCD (most Intel and VIA) support

    [*] USB Human Interface Device (full HID) support
      [*]   /dev/hiddev raw HID device support

EHCI, OHCI, UHCI depends on your hardware, I need only UHCI. use lspci (from sys-apps/pciutils) to find out.
Recompile it and reboot.

I use udev with hotplug. Arnaud Quette (from opensource.mgeups.com and nut and ...) noted that you NEED hotplug because the default permissions on /proc/bus/usb/XXX/YYY are not sufficient. How to setup udev is beyond the scope of this howto. Go here for more details: http://www.gentoo.org/doc/en/udev-guide.xml

Step 2: Patching and changing
I tried several packages, but they didn't work. So I looked for bugs relating and adapted some more things.
Related bugs:
Make a portage overlay by creating /usr/local/portage
Code:
# mkdir /usr/local/portage
and by editing /etc/make.conf to reflect this: uncomment (or add) this line
Code:
PORTDIR_OVERLAY="/usr/local/portage"


add the following files to the newly created portage overlay (create directories if necessary):

  • http://134.184.38.93/niels/mge/libusb-0.1.10a-r1.ebuild --> /usr/local/portage/dev-libs/libusb/libusb-0.1.10a-r1.ebuild
  • http://134.184.38.93/niels/mge/nut-2.0.1.ebuild --> /usr/local/portage/www-apps/nut/nut-2.0.1.ebuild

also copy over the start-up scripts:
Code:
cp /usr/portage/www-apps/nut/files/ups{mon,d,drv}.rc6 /usr/local/portage/www-apps/nut/files/.

and create their digest
Code:
# ebuild /usr/local/portage/dev-libs/libusb/libusb-0.1.10a-r1.ebuild digest
# ebuild /usr/local/portage/www-apps/nut/nut-2.0.1.ebuild digest


Step 3: instalation
To tell nut to build the newhidups-driver you need to add the line
Code:
NUT_DRIVERS="newhidups"
to your /etc/make.conf.
Since we want to use our newly added ebuilds, you need to tell emerge about this:
Code:
# mkdir /etc/portage
# echo "dev-libs/libusb ~x86" >> /etc/portage/package.keywords
# echo "www-apps/nut ~x86" >> /etc/portage/package.keywords

next, build nut
Code:
# emerge www-apps/nut


Step 4: Configuration
next we need to configure NUT to talk to our UPS. Make sure the UPS is connected by now.
add these lines to /etc/nut/ups.conf:
Code:
[mge]
        driver = newhidups
        port = auto
        desc = "MGE Pulsar Ellipse 300 USBS"

add these line to /etc/nut/upsd.users:
Code:
[monuser]
        password        = S0mePa55W0Rd
        allowfrom       = localhost
        upsmon          master

add (or uncomment and change) this line to upsmon.conf:
Code:
MONITOR mge@localhost 1 monuser S0mePa55W0Rd master

The values "mge", "MGE Pulsar Ellipse 300 USBS", "monuser" and "S0mePa55W0Rd" are arbitry and can be whatever, just make sure that they remain the same across files.

Step 5:Testing
If all went well, you can start testing.
load the driver
Code:
# /etc/init.d/upsdrv start
 * Starting UPS drivers ...
Network UPS Tools - UPS driver controller 2.0.1
Network UPS Tools: New HID UPS driver 0.12 (2.0.1)

Warning: This is an experimental driver.
Some features may not function correctly.

Detected an UPS: MGE/ELLIPSE
[ ok ]

start the server
Code:
# /etc/init.d/upsd start
 * Starting upsd ...
Network UPS Tools upsd 2.0.1
Connected to UPS [mge]: newhidups-auto
Synchronizing...done
[ ok ]

Test server
Code:
# upsc mge@localhost
battery.charge: 91
battery.charge.low: 30
battery.runtime: 1561
driver.name: newhidups
driver.parameter.port: auto
driver.version: 2.0.1
driver.version.data: MGE HID 0.6
driver.version.internal: 0.12
input.transfer.high: 264.0
input.transfer.low: 184.0
output.voltage: 230.0
ups.delay.shutdown: -1
ups.delay.start: -10
ups.load: 3
ups.mfr: MGE
ups.model: ellipse 300
ups.serial: unknown
ups.status: OL CHRG

start monitor
Code:
# /etc/init.d/upsmon start
 * Starting upsmon ...
Network UPS Tools upsmon 2.0.1
UPS: mge@localhost (master) (power value 1)
Using power down flag file /etc/killpower
[ ok ]

If everything goes well, tell gentoo to start them automaticaly
Code:
rc-update add upsd default
rc-update add upsmon default


Step 6: More hacks
when the UPS goes on low battery, upsmon will start the shutdown of the computer. the last command will signal the UPS that it may kill the power to us.
The problem is that the newhidups-driver needs /proc/bus/usb to be mounted read-write (see bug #103133).
The ugly workaround is to manualy edit /etc/init.d/halt.sh and add this line:
Code:
# This is a function because its used twice below
ups_kill_power() {
        local UPS_CTL UPS_POWERDOWN
        if [[ -f /etc/killpower ]] ; then
                UPS_CTL=/sbin/upsdrvctl
                UPS_POWERDOWN="${UPS_CTL} shutdown"
        elif [[ -f /etc/apcupsd/powerfail ]] ; then
                UPS_CTL=/etc/apcupsd/apccontrol
                UPS_POWERDOWN="${UPS_CTL} killpower"
        else
                return 0
        fi
        if [[ -x ${UPS_CTL} ]] ; then
                ewarn "Signalling ups driver(s) to kill the load!"
                mount -n -o remount,rw /proc/bus/usb                              <=========== add this
                ${UPS_POWERDOWN}
                ewarn "Halt system and wait for the UPS to kill our power"
                /sbin/halt -id
                while [ 1 ]; do sleep 60; done
        fi
}


Step 7: More tests
you can now pull the plug and wait until the battery runs empty to test the setup.
However, you can also fake this.
Code:
upsmon -c fsd
will have the same effect than a low-batt condition and initiate shutdown. My UPS waits about 10 seconds between receiving the command to kill the power, and actualy doing in. If the power comes back on, the power to the computer is restored.
Even if the power came back on in these 10 seconds, or didn't go off at all, the UPS will still kill power for approx 5 seconds.

Side-notes
I hope this guide is helpful to some people struggeling with the same problem I had. Let me know about any mistakes/omissions/...

yes, NUT is is www-apps, don't ask me why.... there are bug-reports that reqeust a change to sys-power, but they're not yet heard....

For people having trouble with hotplug: http://lists.alioth.debian.org/pipermail/nut-upsuser/2005-August/000108.html
Back to top
View user's profile Send private message
PaRaNo
n00b
n00b


Joined: 25 Oct 2003
Posts: 66
Location: Dans le sud

PostPosted: Sun Dec 04, 2005 3:30 pm    Post subject: Reply with quote

Thank you!
this Howto works great with my Ellipse 800 even with the ~amd64 use flag
Back to top
View user's profile Send private message
BlackB1rd
Tux's lil' helper
Tux's lil' helper


Joined: 13 Aug 2003
Posts: 131
Location: /Europe/Netherlands/Haarlem

PostPosted: Thu Mar 02, 2006 5:37 pm    Post subject: Reply with quote

Also works great with a Ellipse 500 8) But I emerged a newer version of libusb, which is currently in portage.
Back to top
View user's profile Send private message
kdvgent
Guru
Guru


Joined: 29 Sep 2004
Posts: 352
Location: Belgium

PostPosted: Sat Mar 11, 2006 1:16 pm    Post subject: Used HOWTO with MGE Protection Center 500 on AMD64 Reply with quote

Worked like a charm.

Some comments:
  • I am working under ~AMD64
  • Step 2 "Patching and changing" is not needed anymore - I used libusb-0.1.11 and nut-2.0.1_pre4 that are both in portage (be it in the testing branch)
  • In Step 3, you no longer need to tell nut to build the newhidups driver (and of course, you no longer need to specify the overlays)
  • In Step 4, the user "monuser" (with the correct password) must of course be created. I made this user member of the group "nut"
  • I also emerged ups-monitor (although the ~AMD64 keyword is not yet there, things work out fine)
I had in the past several attempts to install the UPS driver but was always "blocked" by "data stale" problems. Seems to have gone with my present combination of HW/SW

Thanks a lot for this HOWTO.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum