# USB UPS control

## bjlockie

I bought a CyberPower CP550SLG UPS and I am trying to get it to work with nut.

 *Quote:*   

> if you use a USB UPS you may need to look at the udev or
> 
>  * hotplug rules that are installed, and alter them suitably.
> 
> 

 

I am using the usbhid-ups driver.

 *Quote:*   

> 
> 
> # upsdrvctl start
> 
> Network UPS Tools - UPS driver controller 2.4.3
> ...

 

What udev rules do I need and why didn't the ebuild install them?

----------

## Malvineous

You probably need udev rules to create a nice device like /dev/ups which you can then use in your config file.  The ebuild doesn't install them because the rules are specific to your device - you might only have one device so you want to use the device and manufacturer ID, or you might have a bunch of devices so you want to use serial numbers or something.  However the usbhid-ups driver might check all HID devices regardless, so you may not need any udev rules (from your error messages it looks like it has discovered a device - if lsusb reports your UPS as 0764:0501 then it's being detected fine as-is.)

The error about being unable to detach the kernel driver is a bit worrying though, perhaps you have some program running that opens and uses the device so the NUT driver can't get hold of it?

----------

## bjlockie

 *Malvineous wrote:*   

> You probably need udev rules to create a nice device like /dev/ups which you can then use in your config file.  The ebuild doesn't install them because the rules are specific to your device - you might only have one device so you want to use the device and manufacturer ID, or you might have a bunch of devices so you want to use serial numbers or something.  However the usbhid-ups driver might check all HID devices regardless, so you may not need any udev rules (from your error messages it looks like it has discovered a device - if lsusb reports your UPS as 0764:0501 then it's being detected fine as-is.)
> 
> The error about being unable to detach the kernel driver is a bit worrying though, perhaps you have some program running that opens and uses the device so the NUT driver can't get hold of it?

 

I got this far by installing the udev rules from source (it has a rule for 0764:0501).

```

$ sudo upsdrvctl start

Network UPS Tools - UPS driver controller 2.4.3

Network UPS Tools - Generic HID driver 0.34 (2.4.3)

USB communication driver 0.31

Using subdriver: CyberPower HID 0.3

libusb_get_report: could not claim interface 0: Device or resource busy

Got disconnected by another driver: Device or resource busy

Can't initialize data from HID UPS

Driver failed to start (exit status=1)

```

----------

## nanoczar

I'm getting this same error trying to use nuts. It was working until I did a system update and I cannot find the problem. I've been working on it for about 3 days and can't find the problem. Grrrr.

I logged onto the forums to post a "Help" and saw your post. Maybe someone can help us???

Is it something with NUTS or maybe the USB system?

----------

## bjlockie

 *nanoczar wrote:*   

> I'm getting this same error trying to use nuts. It was working until I did a system update and I cannot find the problem. I've been working on it for about 3 days and can't find the problem. Grrrr.
> 
> I logged onto the forums to post a "Help" and saw your post. Maybe someone can help us???
> 
> Is it something with NUTS or maybe the USB system?

 

Try this patch, it didn't work for me but it worked for someone else.

http://boxster.ghz.cc/projects/nut/changeset/2407?format=diff&new=2407

I think my problem is with libusb.

----------

## nanoczar

bjlockie,

I have seen that too but I don't seem to have this libhid.c file anywhere. I have libhid installed though...

Are you having any issues with other USB devices? I seem to remember that I started having USB printer issues about the same time - my computer just lost all communication with it, but I never went back to address the issue due to time limitations.

----------

## bjlockie

 *nanoczar wrote:*   

> bjlockie,
> 
> I have seen that too but I don't seem to have this libhid.c file anywhere. I have libhid installed though...
> 
> Are you having any issues with other USB devices? I seem to remember that I started having USB printer issues about the same time - my computer just lost all communication with it, but I never went back to address the issue due to time limitations.

 

libhid.c is the source.

I tried installing directly from the source but that didn't help.

My USB printer works fine.

----------

## bjlockie

nut started working for me.  :Smile: 

I don't know why.  :Sad: 

I have a theory that is hard to test.

If you can, use the Windows software one time.

I used it under VirtualBox and nut started working.

It may have just been a coincidence.

----------

## nanoczar

Did you somehow reset your UPS in Windows? I don't see how this will help...

----------

## Malvineous

The problem is that the kernel HID driver attached to the UPS device, and NUT has to tell it to let go so NUT can access it.  This is failing for some reason - perhaps some application has opened all HID devices to see what is attached to the system, e.g. a keyboard configuration program.

You should be able to look in sysfs to see which driver is using the device, e.g.

```
$ lsusb -d 046d:c223

Bus 003 Device 002: ID 046d:c223 Logitech, Inc. G15 Keyboard / USB Hub

# Take the bus and device numbers, here it is 3-2

$ ls /sys/bus/usb/devices/3-2*/driver

lrwxrwxrwx 1 root root 0 May 16 15:27 /sys/bus/usb/devices/3-2.1:1.0/driver -> ../../../../../../../bus/usb/drivers/usbhid

```

Here you can see the device is being used by the usbhid driver.

While libusb should be able to do it automatically, you can manually tell the driver to let go of the device with something like this:

```
$ echo '3-2.1:1.0' > /sys/bus/usb/drivers/usbhid/unbind

```

Of course replacing "usbhid" and "3-2.1:1.0" with the values reported above.  You may need to play around with the device ID formatting and the order in which you unbind them, but if you succeed you should see the device disappear from the list when you do this:

```
$ ls /sys/bus/usb/drivers/usbhid/

```

Once it's gone NUT should be able to claim the device without any problems.

----------

## imbiea

I'm having the same problem..

i.e.

 *Quote:*   

>  /etc/init.d/upsdrv restart
> 
>  * Service upsdrv starting
> 
>  * Starting UPS drivers ...
> ...

 

This is since my nut upgrade.

I tried to do as mentioned above:  i.e.

 *Quote:*   

> 
> 
> $ lsusb -d 046d:c223
> 
> Bus 003 Device 002: ID 046d:c223 Logitech, Inc. G15 Keyboard / USB Hub
> ...

 

However...

```

lsusb -d 0764:0501

Bus 004 Device 003: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS

```

So, when I try to look at device...in my case... 4-3??

it isn't there?

 *Quote:*   

> 
> 
> ls /sys/bus/usb/devices/
> 
> 1-0:1.0  1-3.1      1-3.1:1.1  1-3.2:1.0  1-3:1.0  3-0:1.0  3-1:1.0  4-0:1.0  4-2:1.0  usb2  usb4
> ...

 

My usb printer looks fine...

Just moved my usb cable from one port to another and got this... but it still doesn't work..

 *Quote:*   

> 
> 
> hub 4-0:1.0: state 7 ports 2 chg 0000 evt 0004
> 
> uhci_hcd 0000:00:1f.2: port 2 portsc 008a,00
> ...

 

----------

## imbiea

Oh, and I should have stated..

In looking though my 70-nut-usbups.rules 

I see:

```

#  Dynex DX-800U?  - usbhid-ups

 76 ATTR{idVendor}=="0764", ATTR{idProduct}=="0501", MODE="664", GROUP="nut"

```

which matches my lsusb output:

```
0764:0501 Cyber Power System, Inc. CP1500 AVR UPS

```

So am I to take the upsdrv won't start because hal is already taking care of things?

i.e. 

 *Quote:*   

> * If you use hald, you may be able to skip the normal init scripts.
> 
> 

 

from the emerge ... however my upsc results are:

 *Quote:*   

> upsc server@localhost
> 
> Error: Driver not connected
> 
> 

 

And... I just tried this in debug mode... does this help?

```
/lib/nut/usbhid-ups -D -D -a server

Network UPS Tools - Generic HID driver 0.34 (2.4.3)

USB communication driver 0.31

   0.000000   debug level is '2'

   0.017651   upsdrv_initups...

   0.078776   Checking device (1D6B/0001) (002/001)

   0.078968   - VendorID: 1d6b

   0.078996   - ProductID: 0001

   0.079018   - Manufacturer: Linux 2.6.32-gentoo-r7 ohci_hcd

   0.079040   - Product: OHCI Host Controller

   0.079063   - Serial Number: 0000:01:07.0

   0.079085   - Bus: 002

   0.079106   Trying to match device

   0.079160   Device does not match - skipping

   0.079202   Checking device (04B8/0808) (003/002)

   0.079311   - VendorID: 04b8

   0.079339   - ProductID: 0808

   0.079361   - Manufacturer: unknown

   0.079383   - Product: unknown

   0.079404   - Serial Number: unknown

   0.079426   - Bus: 003

   0.079447   Trying to match device

   0.079472   Device does not match - skipping

   0.079504   Checking device (1D6B/0001) (003/001)

   0.080066   - VendorID: 1d6b

   0.080115   - ProductID: 0001

   0.080137   - Manufacturer: Linux 2.6.32-gentoo-r7 ohci_hcd

   0.080160   - Product: OHCI Host Controller

   0.080182   - Serial Number: 0000:01:07.1

   0.080204   - Bus: 003

   0.080226   Trying to match device

   0.080255   Device does not match - skipping

   0.080293   Checking device (046D/C52F) (001/005)

   0.082916   - VendorID: 046d

   0.082964   - ProductID: c52f

   0.082986   - Manufacturer: Logitech

   0.083008   - Product: USB Receiver

   0.083031   - Serial Number: unknown

   0.083053   - Bus: 001

   0.083074   Trying to match device

   0.083104   Device does not match - skipping

   0.083145   Checking device (1058/0400) (001/006)

   0.085420   - VendorID: 1058

   0.085475   - ProductID: 0400

   0.085498   - Manufacturer: Western Digital

   0.085520   - Product: External HDD

   0.085542   - Serial Number: 574D41455431363732343232

   0.085797   - Bus: 001

   0.085819   Trying to match device

   0.085849   Device does not match - skipping

   0.085895   Checking device (1058/0500) (001/003)

   0.085974   - VendorID: 1058

   0.086000   - ProductID: 0500

   0.086021   - Manufacturer: unknown

   0.086044   - Product: unknown

   0.086065   - Serial Number: unknown

   0.086087   - Bus: 001

   0.086108   Trying to match device

   0.086133   Device does not match - skipping

   0.086167   Checking device (1D6B/0002) (001/001)

   0.086268   - VendorID: 1d6b

   0.086295   - ProductID: 0002

   0.086317   - Manufacturer: Linux 2.6.32-gentoo-r7 ehci_hcd

   0.086340   - Product: EHCI Host Controller

   0.086362   - Serial Number: 0000:01:07.2

   0.086384   - Bus: 001

   0.086405   Trying to match device

   0.086430   Device does not match - skipping

   0.086464   Checking device (0764/0501) (004/002)

   0.109120   - VendorID: 0764

   0.109180   - ProductID: 0501

   0.109201   - Manufacturer: CPS

   0.109223   - Product: UPS BF700

   0.109244   - Serial Number: unknown

   0.109266   - Bus: 004

   0.109287   Trying to match device

   0.109366   Device matches

   0.109431   failed to claim USB device: could not claim interface 0: Device or resource busy

   0.118284   detached kernel driver from USB device...

   0.126156   HID descriptor length 374

   0.176136   Report Descriptor size = 374

   0.177125   Using subdriver: CyberPower HID 0.3

   0.182116   libusb_get_report: could not claim interface 0: Device or resource busy

   0.182199   Can't retrieve Report 01: Device or resource busy

   0.182267   Path: UPS.PowerSummary.iProduct, Type: Feature, ReportID: 0x01, Offset: 0, Size: 8

   0.187111   libusb_get_report: could not claim interface 0: Device or resource busy

   0.187174   Can't retrieve Report 02: Device or resource busy

   0.187216   Path: UPS.PowerSummary.iSerialNumber, Type: Feature, ReportID: 0x02, Offset: 0, Size: 8

   0.192111   libusb_get_report: could not claim interface 0: Device or resource busy

   0.192177   Can't retrieve Report 03: Device or resource busy

   0.192221   Path: UPS.PowerSummary.iDeviceChemistry, Type: Feature, ReportID: 0x03, Offset: 0, Size: 8

   0.197108   libusb_get_report: could not claim interface 0: Device or resource busy

   0.197167   Can't retrieve Report 04: Device or resource busy

   0.197210   Path: UPS.PowerSummary.iOEMInformation, Type: Feature, ReportID: 0x04, Offset: 0, Size: 8

   0.202111   libusb_get_report: could not claim interface 0: Device or resource busy

   0.202173   Can't retrieve Report 05: Device or resource busy

   0.202216   Path: UPS.PowerSummary.Rechargeable, Type: Feature, ReportID: 0x05, Offset: 0, Size: 8

   0.207107   libusb_get_report: could not claim interface 0: Device or resource busy

   0.207162   Can't retrieve Report 06: Device or resource busy

   0.207204   Path: UPS.PowerSummary.CapacityMode, Type: Feature, ReportID: 0x06, Offset: 0, Size: 8

   0.212106   libusb_get_report: could not claim interface 0: Device or resource busy

   0.212159   Can't retrieve Report 07: Device or resource busy

   0.212202   Path: UPS.PowerSummary.DesignCapacity, Type: Feature, ReportID: 0x07, Offset: 0, Size: 8

   0.217109   libusb_get_report: could not claim interface 0: Device or resource busy

   0.217170   Can't retrieve Report 07: Device or resource busy

   0.217214   Path: UPS.PowerSummary.CapacityGranularity1, Type: Feature, ReportID: 0x07, Offset: 8, Size: 8

   0.222105   libusb_get_report: could not claim interface 0: Device or resource busy

   0.222161   Can't retrieve Report 07: Device or resource busy

   0.222204   Path: UPS.PowerSummary.CapacityGranularity2, Type: Feature, ReportID: 0x07, Offset: 16, Size: 8

   0.227108   libusb_get_report: could not claim interface 0: Device or resource busy

   0.227170   Can't retrieve Report 07: Device or resource busy

   0.227214   Path: UPS.PowerSummary.WarningCapacityLimit, Type: Feature, ReportID: 0x07, Offset: 24, Size: 8

   0.232105   libusb_get_report: could not claim interface 0: Device or resource busy

   0.232162   Can't retrieve Report 07: Device or resource busy

   0.232204   Path: UPS.PowerSummary.RemainingCapacityLimit, Type: Feature, ReportID: 0x07, Offset: 32, Size: 8

   0.237112   libusb_get_report: could not claim interface 0: Device or resource busy

   0.237175   Can't retrieve Report 07: Device or resource busy

   0.237219   Path: UPS.PowerSummary.FullChargeCapacity, Type: Feature, ReportID: 0x07, Offset: 40, Size: 8

   0.242106   libusb_get_report: could not claim interface 0: Device or resource busy

   0.242163   Can't retrieve Report 08: Device or resource busy

   0.242225   Path: UPS.PowerSummary.RemainingCapacity, Type: Input, ReportID: 0x08, Offset: 0, Size: 8

   0.247101   libusb_get_report: could not claim interface 0: Device or resource busy

   0.247160   Can't retrieve Report 08: Device or resource busy

   0.247203   Path: UPS.PowerSummary.RemainingCapacity, Type: Feature, ReportID: 0x08, Offset: 0, Size: 8

   0.252101   libusb_get_report: could not claim interface 0: Device or resource busy

   0.252164   Can't retrieve Report 08: Device or resource busy

   0.252208   Path: UPS.PowerSummary.RunTimeToEmpty, Type: Input, ReportID: 0x08, Offset: 8, Size: 16

   0.258811   libusb_get_report: could not claim interface 0: Device or resource busy

   0.258920   Can't retrieve Report 08: Device or resource busy

   0.258967   Path: UPS.PowerSummary.RunTimeToEmpty, Type: Feature, ReportID: 0x08, Offset: 8, Size: 16

   0.263114   libusb_get_report: could not claim interface 0: Device or resource busy

   0.263181   Can't retrieve Report 08: Device or resource busy

   0.263226   Path: UPS.PowerSummary.RemainingTimeLimit, Type: Input, ReportID: 0x08, Offset: 24, Size: 16

   0.268105   libusb_get_report: could not claim interface 0: Device or resource busy

   0.268161   Can't retrieve Report 08: Device or resource busy

   0.268204   Path: UPS.PowerSummary.RemainingTimeLimit, Type: Feature, ReportID: 0x08, Offset: 24, Size: 16

   0.273108   libusb_get_report: could not claim interface 0: Device or resource busy

   0.273171   Can't retrieve Report 09: Device or resource busy

   0.273213   Path: UPS.PowerSummary.ConfigVoltage, Type: Feature, ReportID: 0x09, Offset: 0, Size: 8

   0.278101   libusb_get_report: could not claim interface 0: Device or resource busy

   0.278157   Can't retrieve Report 0a: Device or resource busy

   0.278197   Path: UPS.PowerSummary.Voltage, Type: Feature, ReportID: 0x0a, Offset: 0, Size: 8

   0.283100   libusb_get_report: could not claim interface 0: Device or resource busy

   0.283151   Can't retrieve Report 0b: Device or resource busy

   0.283195   Path: UPS.PowerSummary.PresentStatus.ACPresent, Type: Input, ReportID: 0x0b, Offset: 0, Size: 1

   0.288105   libusb_get_report: could not claim interface 0: Device or resource busy

   0.288166   Can't retrieve Report 0b: Device or resource busy

   0.288212   Path: UPS.PowerSummary.PresentStatus.Charging, Type: Input, ReportID: 0x0b, Offset: 1, Size: 1

   0.293102   libusb_get_report: could not claim interface 0: Device or resource busy

   0.293157   Can't retrieve Report 0b: Device or resource busy

   0.293201   Path: UPS.PowerSummary.PresentStatus.Discharging, Type: Input, ReportID: 0x0b, Offset: 2, Size: 1

   0.298104   libusb_get_report: could not claim interface 0: Device or resource busy

   0.298166   Can't retrieve Report 0b: Device or resource busy

   0.298212   Path: UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit, Type: Input, ReportID: 0x0b, Offset: 3, Size: 1

   0.303101   libusb_get_report: could not claim interface 0: Device or resource busy

   0.303159   Can't retrieve Report 0b: Device or resource busy

   0.303203   Path: UPS.PowerSummary.PresentStatus.FullyCharged, Type: Input, ReportID: 0x0b, Offset: 4, Size: 1

   0.308104   libusb_get_report: could not claim interface 0: Device or resource busy

   0.308167   Can't retrieve Report 0b: Device or resource busy

   0.308212   Path: UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired, Type: Input, ReportID: 0x0b, Offset: 5, Size: 1

   0.313101   libusb_get_report: could not claim interface 0: Device or resource busy

   0.313158   Can't retrieve Report 0b: Device or resource busy

   0.313204   Path: UPS.PowerSummary.PresentStatus.ACPresent, Type: Feature, ReportID: 0x0b, Offset: 0, Size: 1

   0.318099   libusb_get_report: could not claim interface 0: Device or resource busy

   0.318153   Can't retrieve Report 0b: Device or resource busy

   0.318197   Path: UPS.PowerSummary.PresentStatus.Charging, Type: Feature, ReportID: 0x0b, Offset: 1, Size: 1

   0.323104   libusb_get_report: could not claim interface 0: Device or resource busy

   0.323167   Can't retrieve Report 0b: Device or resource busy

   0.323212   Path: UPS.PowerSummary.PresentStatus.Discharging, Type: Feature, ReportID: 0x0b, Offset: 2, Size: 1

   0.328099   libusb_get_report: could not claim interface 0: Device or resource busy

   0.328154   Can't retrieve Report 0b: Device or resource busy

   0.328198   Path: UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit, Type: Feature, ReportID: 0x0b, Offset: 3, Size: 1

   0.333103   libusb_get_report: could not claim interface 0: Device or resource busy

   0.333165   Can't retrieve Report 0b: Device or resource busy

   0.333211   Path: UPS.PowerSummary.PresentStatus.FullyCharged, Type: Feature, ReportID: 0x0b, Offset: 4, Size: 1

   0.338099   libusb_get_report: could not claim interface 0: Device or resource busy

   0.338155   Can't retrieve Report 0b: Device or resource busy

   0.338200   Path: UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired, Type: Feature, ReportID: 0x0b, Offset: 5, Size: 1

   0.343103   libusb_get_report: could not claim interface 0: Device or resource busy

   0.343165   Can't retrieve Report 0c: Device or resource busy

   0.343206   Path: UPS.PowerSummary.AudibleAlarmControl, Type: Feature, ReportID: 0x0c, Offset: 0, Size: 8

   0.348828   libusb_get_report: could not claim interface 0: Device or resource busy

   0.348932   Can't retrieve Report 0d: Device or resource busy

   0.348978   Path: UPS.PowerSummary.iManufacturer, Type: Feature, ReportID: 0x0d, Offset: 0, Size: 8

   0.353105   libusb_get_report: could not claim interface 0: Device or resource busy

   0.353167   Can't retrieve Report 0e: Device or resource busy

   0.353208   Path: UPS.Input.ConfigVoltage, Type: Feature, ReportID: 0x0e, Offset: 0, Size: 8

   0.358101   libusb_get_report: could not claim interface 0: Device or resource busy

   0.358160   Can't retrieve Report 0f: Device or resource busy

   0.358199   Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x0f, Offset: 0, Size: 8

   0.363099   libusb_get_report: could not claim interface 0: Device or resource busy

   0.363155   Can't retrieve Report 10: Device or resource busy

   0.363196   Path: UPS.Input.LowVoltageTransfer, Type: Feature, ReportID: 0x10, Offset: 0, Size: 8

   0.368101   libusb_get_report: could not claim interface 0: Device or resource busy

   0.368166   Can't retrieve Report 10: Device or resource busy

   0.368206   Path: UPS.Input.HighVoltageTransfer, Type: Feature, ReportID: 0x10, Offset: 8, Size: 8

   0.373097   libusb_get_report: could not claim interface 0: Device or resource busy

   0.373153   Can't retrieve Report 12: Device or resource busy

   0.373193   Path: UPS.Output.Voltage, Type: Feature, ReportID: 0x12, Offset: 0, Size: 8

   0.378101   libusb_get_report: could not claim interface 0: Device or resource busy

   0.378162   Can't retrieve Report 13: Device or resource busy

   0.378203   Path: UPS.Output.PercentLoad, Type: Feature, ReportID: 0x13, Offset: 0, Size: 8

   0.383097   libusb_get_report: could not claim interface 0: Device or resource busy

   0.383153   Can't retrieve Report 14: Device or resource busy

   0.383193   Path: UPS.Output.Test, Type: Feature, ReportID: 0x14, Offset: 0, Size: 8

   0.388096   libusb_get_report: could not claim interface 0: Device or resource busy

   0.388150   Can't retrieve Report 15: Device or resource busy

   0.388191   Path: UPS.Output.DelayBeforeShutdown, Type: Feature, ReportID: 0x15, Offset: 0, Size: 8

   0.393099   libusb_get_report: could not claim interface 0: Device or resource busy

   0.393161   Can't retrieve Report 16: Device or resource busy

   0.393203   Path: UPS.Output.DelayBeforeStartup, Type: Feature, ReportID: 0x16, Offset: 0, Size: 8

   0.398097   libusb_get_report: could not claim interface 0: Device or resource busy

   0.398151   Can't retrieve Report 17: Device or resource busy

   0.398192   Path: UPS.Output.Boost, Type: Feature, ReportID: 0x17, Offset: 0, Size: 1

   0.403099   libusb_get_report: could not claim interface 0: Device or resource busy

   0.403160   Can't retrieve Report 17: Device or resource busy

   0.403202   Path: UPS.Output.Overload, Type: Feature, ReportID: 0x17, Offset: 1, Size: 1

   0.408095   libusb_get_report: could not claim interface 0: Device or resource busy

   0.408150   Can't retrieve Report 18: Device or resource busy

   0.408190   Path: UPS.Output.ConfigActivePower, Type: Feature, ReportID: 0x18, Offset: 0, Size: 16

   0.408282   Report descriptor retrieved (Reportlen = 374)

   0.408308   Found HID device

   0.408334   Detected a UPS: CPS/UPS BF700

   0.413135   libusb_get_report: could not claim interface 0: Device or resource busy

   0.413202   Can't retrieve Report 03: Device or resource busy

   0.413232   Got disconnected by another driver: Device or resource busy

   0.413257   Can't initialize data from HID UPS

```

----------

## keyson

OK imbiea,

To run NUT with upsd and upsmon you have to emerge it without the hal flag.

The hal driver is started by udev and take the device.

The hal driver is talking to the hal backend and you may use the battery monitor,

as you do on a laptop. But it can not speak to the upsd.

So it is two drivers one for normal NUT usbups-hid and one for hal 'hald-addon-usbhid-ups'.

So enter -hal for sys-power/nut in /etc/portage/package.use

----------

## imbiea

 *keyson wrote:*   

> 
> 
> To run NUT with upsd and upsmon you have to emerge it without the hal flag.
> 
> The hal driver is started by udev and take the device.
> ...

 

OK, I did wonder if this was maybe the issue.  Which then leads me to ask..

Which way should/could NUT be run?  let's just say I leave it with hal options compiled in.  How then should the UPS be managed?

what are the advantages one way or the other?

----------

## imbiea

NO go.

I just recompiled nut with NO hal support.

```

/etc/init.d/upsdrv restart

 * Service upsdrv starting

 * Starting UPS drivers ...

Network UPS Tools - UPS driver controller 2.4.3

Network UPS Tools - Generic HID driver 0.34 (2.4.3)

USB communication driver 0.31

Using subdriver: CyberPower HID 0.3

libusb_get_report: No error

Can't initialize data from HID UPS

Driver failed to start (exit status=1)

```

```

/lib/nut/usbhid-ups -D -D -D -D -D -D -D -D -a server

Network UPS Tools - Generic HID driver 0.34 (2.4.3)

USB communication driver 0.31

   0.000000   send_to_all: SETINFO driver.parameter.port "auto"

   0.001341   debug level is '8'

   0.004239   upsdrv_initups...

   0.065937   Checking device (0764/0501) (004/002)

   0.088284   - VendorID: 0764

   0.088349   - ProductID: 0501

   0.088371   - Manufacturer: CPS

   0.088393   - Product: UPS BF700

   0.088414   - Serial Number: unknown

   0.088436   - Bus: 004

   0.088487   Trying to match device

   0.088845   Device matches

   0.096299   HID descriptor, method 1: (9 bytes) => 09 21 10 01 21 01 22 76 01

   0.096357   i=0, extra[i]=09, extra[i+1]=21

   0.096397   HID descriptor, method 2: (9 bytes) => 09 21 10 01 21 01 22 76 01

   0.096421   HID descriptor length 374

   0.146292   Report Descriptor size = 374

   0.146373   Report Descriptor: (374 bytes) => 05 84 09 04 a1 01 09 24 a1 00 85 01 09 fe

   0.146431    75 08 95 01 15 00 26 ff 00 b1 22 85 02 09 ff b1 22 85 03 05 85 09 89 b1 22

   0.146729    85 04 09 8f b1 22 85 05 09 8b b1 22 85 06 09 2c b1 22 85 07 75 08 95 06 25

   0.146800    78 09 83 09 8d 09 8e 09 8c 09 29 09 67 b1 22 85 08 75 08 95 01 65 00 09 66

   0.146856    81 a2 09 66 b1 a2 09 68 75 10 27 ff ff 00 00 66 01 10 81 a2 09 68 b1 a2 09

   0.146912    2a 26 58 02 81 a2 09 2a b1 a2 85 09 75 08 26 ff 00 05 84 09 40 67 21 d1 f0

   0.146969    00 55 06 b1 22 85 0a 09 30 b1 a2 65 00 55 00 09 02 a1 02 85 0b 75 01 95 06

   0.147026    25 01 05 85 09 d0 09 44 09 45 09 42 09 46 09 43 81 a2 09 d0 09 44 09 45 09

   0.147083    42 09 46 09 43 b1 a2 75 02 95 01 81 01 b1 01 c0 85 0c 05 84 09 5a 75 08 15

   0.147139    01 25 03 b1 a2 85 0d 09 fd 15 00 26 ff 00 b1 22 c0 05 84 09 1a a1 00 85 0e

   0.147195    05 84 09 40 75 08 67 21 d1 f0 00 55 07 b1 22 85 0f 09 30 b1 a2 85 10 09 53

   0.147251    15 5a 25 5a b1 22 09 54 16 8c 00 26 8c 00 b1 22 c0 09 1c a1 00 85 12 09 30

   0.147307    15 00 26 ff 00 b1 a2 65 00 55 00 85 13 09 35 b1 a2 85 14 09 58 25 06 b1 a2

   0.147363    85 15 09 57 15 ff 26 7f 00 66 01 10 b1 a2 85 16 09 56 b1 a2 85 17 09 6e 75

   0.147420    01 15 00 25 01 65 00 b1 a2 09 65 b1 a2 75 06 b1 01 85 18 75 10 09 44 26 c2

   0.147456    01 66 21 d1 55 07 b1 a2 c0 c0

   0.148007   Using subdriver: CyberPower HID 0.3

   0.148053   Entering libusb_get_report

   0.152282   libusb_get_report: No error

   0.152388   Can't retrieve Report 01: Operation not permitted

   0.152436   hid_lookup_path: 00840004 -> UPS

   0.152707   hid_lookup_path: 00840024 -> PowerSummary

   0.152749   hid_lookup_path: 008400fe -> iProduct

   0.152778   Path: UPS.PowerSummary.iProduct, Type: Feature, ReportID: 0x01, Offset: 0, Size: 8

   0.152804   Entering libusb_get_report

   0.157269   libusb_get_report: No error

   0.157337   Can't retrieve Report 02: Operation not permitted

   0.157369   hid_lookup_path: 00840004 -> UPS

   0.157397   hid_lookup_path: 00840024 -> PowerSummary

   0.157424   hid_lookup_path: 008400ff -> iSerialNumber

   0.157452   Path: UPS.PowerSummary.iSerialNumber, Type: Feature, ReportID: 0x02, Offset: 0, Size: 8

   0.157713   Entering libusb_get_report

   0.162279   libusb_get_report: No error

   0.162361   Can't retrieve Report 03: Operation not permitted

   0.162396   hid_lookup_path: 00840004 -> UPS

   0.162424   hid_lookup_path: 00840024 -> PowerSummary

   0.162454   hid_lookup_path: 00850089 -> iDeviceChemistry

   0.162785   Path: UPS.PowerSummary.iDeviceChemistry, Type: Feature, ReportID: 0x03, Offset: 0, Size: 8

   0.162816   Entering libusb_get_report

   0.167266   libusb_get_report: No error

   0.167330   Can't retrieve Report 04: Operation not permitted

   0.167361   hid_lookup_path: 00840004 -> UPS

   0.167389   hid_lookup_path: 00840024 -> PowerSummary

   0.167417   hid_lookup_path: 0085008f -> iOEMInformation

   0.167446   Path: UPS.PowerSummary.iOEMInformation, Type: Feature, ReportID: 0x04, Offset: 0, Size: 8

   0.167732   Entering libusb_get_report

   0.172257   libusb_get_report: No error

   0.172310   Can't retrieve Report 05: Operation not permitted

   0.172341   hid_lookup_path: 00840004 -> UPS

   0.172369   hid_lookup_path: 00840024 -> PowerSummary

   0.172396   hid_lookup_path: 0085008b -> Rechargeable

   0.172425   Path: UPS.PowerSummary.Rechargeable, Type: Feature, ReportID: 0x05, Offset: 0, Size: 8

   0.172450   Entering libusb_get_report

   0.177261   libusb_get_report: No error

   0.177317   Can't retrieve Report 06: Operation not permitted

   0.177349   hid_lookup_path: 00840004 -> UPS

   0.177376   hid_lookup_path: 00840024 -> PowerSummary

   0.177403   hid_lookup_path: 0085002c -> CapacityMode

   0.177431   Path: UPS.PowerSummary.CapacityMode, Type: Feature, ReportID: 0x06, Offset: 0, Size: 8

   0.177456   Entering libusb_get_report

   0.182257   libusb_get_report: No error

   0.182310   Can't retrieve Report 07: Operation not permitted

...

```

----------

## keyson

OK.

The hald driver was a way to make ups handling 'plug and play'. When the ups was plugged in, the

battery applet was started and would give you info on charge and if it was on line or on battery.

If it went to battery and it got low you could shut down the computer by the acpi that hook to the battery applet.

The problem with this was that hal could not signalling the power off to the ups.

This was only for workstations.

To run nut in the 'right' way you use the usbups-hid driver and connect to upsd. This make the setup more complex,

no 'plug and play' but you can monitor many ups'es from one daemon (upsd). And you can run the monitor on any

computer that you want to shutdown.

Say that you have two ups'es. One for the server and one for the workstations. The server handle both and run the upsd.

One upsmon on the server monitor one ups, and the workstation upsmon is connected to upsd on the server to monitor the other ups.

There are many ways to setup NUT.

Check the doc's on www.networkupstools.org/doc/

----------

## keyson

OK.

Can you give some info about the ups to the nut-upsusers mailing list.

And also the usb descriptor on the ups.

```

lsusb -v

```

It may not be supported by the usbups-hid driver.

Mail list's

http://alioth.debian.org/mail/?group_id=30602

EDIT:

Run it like this:

/lib/nut/usbhid-ups -DDDD -u root -a server

If you run it like a user you don't have the permission to the device.

----------

