Open dvd604 opened 3 months ago
One idea that comes to mind so far is whether these devices use a non-zero "interface" number for data that would be interesting to NUT? Older practice (and de-facto hard-coded expectation) was to use interface 0 but later some composite devices were seen to challenge this assumption.
So my current guess is that the "Invalid parameter" refers to us asking for an entity which is not there at the address we ask for.
Currently (as of NUT v2.8.2 release) these values should be configurable via driver options, but it may well be that some code still passes certain numbers and not the variables to libusb
calls (so testing is welcome - more so on devices which use values we did not have to expect for two decades prior):
Would you have a chance to build current NUT code base (e.g. on your Ubuntu machine) per https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests and test the built driver from that workspace with such options?
Also, to clarify: the HA and the Ubuntu machines, are they technologically different (CPU arch, USB chip, etc.) so we can rule out platform specifics? Notably, is any of them a Raspberry Pi? (RPi 3 and 5 had a fair share of complaints about USB; 4 fared better; no idea if that reflects popularity of the platform or its quality though)
And this is not a case of trying to monitor several devices from same vendor, and ambiguous identification parameters, right?
And just in case, check to rule out conflicts with sibling driver instances that may have been started by systemd instances generated by NDE => https://github.com/networkupstools/nut/wiki/nut%E2%80%90driver%E2%80%90enumerator-(NDE)
Also, to clarify: the HA and the Ubuntu machines, are they technologically different
The HA machine is a ProxMox VM - the ProxMox host and Ubuntu machine are both running x86 processors. Neither are RPis.
this is not a case of trying to monitor several devices from same vendor
Correct, one UPS only.
sibling driver instances that may have been started by systemd
No other instances appear to be running.
Would you have a chance to build current NUT code base and test the built driver from that workspace with such options?
Sure!
Also, after looking at the lsusb -v
output, I suspect the interface number is indeed 0, although I'm not 100% certain what I'm looking at here:
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 16
idVendor 0x4234
idProduct 0x0002
bcdDevice 0.02
iManufacturer 1 AMETEK-POWERVAR Corporation
iProduct 2 UPM UPS (v01.52, Jan 24 2020)
iSerial 4 5114403R-2040100
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0022
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 3 UPM CUSPP
bmAttributes 0xc0
Self Powered
MaxPower 36mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 27
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 10
Device Status: 0x0001
Self Powered
And lastly, the output from the usbhid-ups driver I built (which looks largely the same). I have tried a range of numbers for usb_set_altinterface
from 0 to 10, although after looking at the lsusb output I'm pretty sure it's at interface 0.
Network UPS Tools driver 2.8.2.863-863-g3679d49b5 (development iteration after 2.8.2) - Generic HID driver 0.55
USB communication driver (libusb 1.0) 0.48
0.000000 [D1] upsdrv_makevartable...
0.000039 [D1] Using USB implementation: libusb-1.0.25 (API: 0x1000109)
0.000047 [D3] main_arg: var='bus' val='001'
0.000056 [D3] main_arg: var='device' val='003'
0.000086 [D3] main_arg: var='vendorid' val='4234'
0.000092 [D3] main_arg: var='productid' val='0002'
0.000100 [D3] main_arg: var='port' val='auto'
0.000105 [D3] main_arg: var='usb_set_altinterface' val='0'
0.000110 [D3] main_arg: var='usb_hid_ep_in' val='<null>'
0.000115 [D1] Network UPS Tools version 2.8.2.863-863-g3679d49b5 (development iteration after 2.8.2) built with gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 and configured with flags: --sysconfdir=/etc/nut --with-group=nut --with-user=nut --enable-Wcolor --enable-warnings --enable-Werror --enable-keep_nut_report_feature --with-all=auto --with-cgi=auto --with-serial=auto --with-dev=auto --with-doc=skip --with-nut_monitor=auto --with-pynut=auto --disable-force-nut-version-header --enable-check-NIT --enable-maintainer-mode --with-debuginfo=auto
0.000122 [D1] debug level is '4'
0.001133 [D1] Succeeded to become_user(nut): now UID=114 GID=119
0.001167 [D1] Signalling UPS [tempups]: driver.exit (quietly, no fuss if no driver is running or responding)
0.001187 [D1] Request for other driver to exit returned code -1
0.001193 [D1] Socket dialog with the other driver instance (may be absent) failed: No such file or directory
0.001202 [D1] upsdrv_initups (non-SHUT)...
0.001208 [D2] Initializing an USB-connected UPS with library libusb-1.0.25 (API: 0x1000109) (NUT subdriver name='USB communication driver (libusb 1.0)' ver='0.48')
0.003868 [D2] Checking device 1 of 4 (152D/0562)
0.003898 [D1] Failed to open device (152D/0562), skipping: Access denied (insufficient permissions)
0.003904 [D2] Checking device 2 of 4 (1D6B/0003)
0.003913 [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions)
0.003918 [D2] Checking device 3 of 4 (4234/0002)
0.005149 [D2] - VendorID: 4234
0.005159 [D2] - ProductID: 0002
0.005167 [D2] - Manufacturer: AMETEK-POWERVAR Corporation
0.005171 [D2] - Product: UPM UPS (v01.52, Jan 24 2020)
0.005175 [D2] - Serial Number: 5xxxxxx-xxxxxx
0.005178 [D2] - Bus: 001
0.005181 [D2] - Bus Port: 011
0.005185 [D2] - Device: 003
0.005189 [D2] - Device release number: 0002
0.005193 [D2] Trying to match device
0.005198 [D2] match_function_subdriver (non-SHUT mode): matching a device...
0.005206 [D3] match_function_regex: matching a device...
0.005248 [D2] Device matches
0.005254 [D2] Reading configuration descriptor 1 of 1
0.005263 [D3] libusb_kernel_driver_active() returned 0: Success
0.005268 [D2] failed to claim USB device: Entity not found
0.005275 [D1] failed to detach kernel driver from USB device: Invalid parameter
0.005283 [D2] failed to claim USB device: Entity not found
0.005291 [D1] failed to detach kernel driver from USB device: Invalid parameter
0.005295 [D2] failed to claim USB device: Entity not found
0.005301 [D1] failed to detach kernel driver from USB device: Invalid parameter
0.005306 [D2] failed to claim USB device: Entity not found
0.005312 [D1] failed to detach kernel driver from USB device: Invalid parameter
0.005317 Can't claim USB device [4234:0002]@0/1/0: Invalid parameter
I have an AMETEK Powervar 2 connected via USB to a Home Assistant box running the NUT addon. I have tried NUT running directly on a Ubuntu machine and had the same outcome. At least one other user is having the same issue with NUT and Ametek devices: https://www.mail-archive.com/nut-upsuser@alioth-lists.debian.net/msg02385.html
Apologies for the screengrab and not a copy/paste log - security on HAOS made getting a copy/pastable log very difficult.