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). -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 194 bytes Desc: not available URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20220811/7b8325fe/attachment.sig>
Marc-André Harbec
2022-Oct-03 18:40 UTC
[Nut-upsuser] NUT can't connect to USB UPS on OpenBSD
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).
Glad you got it working. Marc-Andr? Harbec <maharbec at gmail.com> writes:> 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/kshIn pkgsrc (and hence on NetBSD), there is a /etc/rc.d/upsdriver and that seems to run something that looks in /usr/pkg/etc/nut/ups.conf. I have a Best unit and that starts it at boot. So you could perhaps create a generic driver rcfile and use 'upsdrvctl start'. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 194 bytes Desc: not available URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20221003/467026b8/attachment.sig>