[Nut-upsuser] NUT can't connect to USB UPS on OpenBSD
Marc-André Harbec
maharbec at gmail.com
Mon Oct 3 19:40:22 BST 2022
I found the solution, thanks to both of you for suggesting `ktrace`!
I know it's been a couple of months, but it was just a side project
and I finally got time to get back to it. And I thought it would maybe
help others by putting my findings into the mailing archive.
With `ktrace`, I was able to deduce that there was something weird
going on with my permissions on the USB device `/dev/usb0` (the one
where everything resides in my OpenBSD setup).
$ doas ls -l /dev/usb0
crw-r----- 1 root usb 61, 0 Jun 24 16:21 /dev/usb0
Turns out, if I want to run NUT with a user found within the group
`usb` (user is `_ups`), I need to allow write access to the group on
the device.
Also, I found I had to manually start the USB driver. In my case:
`usbhid-ups`. I don't know if it's something that needs to be done on
all platforms (or it's OpenBSD specific), but I haven't read anything
on this in the official documentation. The `upsd` daemon won't start
if the driver is not already running, and it won't spawn it itself. I
had too create my own service file for it:
$ cat /etc/rc.d/usbhid_ups
#!/bin/ksh
daemon="/usr/local/bin/usbhid-ups"
daemon_user="_ups"
daemon_flags="-a eaton1"
. /etc/rc.d/rc.subr
pexp="${daemon} ${daemon_flags}"
rc_reload=NO
rc_cmd $1
With all that (read/write on the device + usb driver), and with all
the same config as found in my original email, I can finally make NUT
work on OpenBSD via only `rcctl`:
$ doas rcctl start usbhid_ups
$ doas rcctl start upsd
$ doas rcctl start upsmon
On Thu, Aug 11, 2022 at 11:23 AM Greg Troxel <gdt at lexort.com> wrote:
>
>
> Charles Lepple via Nut-upsuser <nut-upsuser at alioth-lists.debian.net>
> writes:
>
> > If that fails, I'd recommend using ktrace to find out what is failing,
> > such that you get the "no USB buses found" error.
>
> Definitely. I would actually recommend ktrace first. Then just
> `kdump | egrep NAMI` will probably find the issue fast.
>
> I use nut on NetBSD, and have done "manual kludge udev" by knowing what
> serial port my UPS is going to be on and in rc.local chowning it to nut
> and linking it to /dev/tty.ups which is in the config. That's serial,
> not USB, but the same thing should work.
>
> And agreed on /dev/ugen; I have a USB printer on /dev/ugen1.01
>
> I suspect that nut needs to read /dev/usbN (for the bus that the UPS is
> on) and read-write access to the ugen file for the HID endpoint, which
> might be ugen, or it might be /dev/uhid2 (assuming it's like NetBSD in
> this regard).
More information about the Nut-upsuser
mailing list