<div dir="ltr"><div dir="ltr"><div>Hello all,<br></div><div><br></div><div> I think I've found the "regression" in Belkin/Liebert USB HID support which worked for NUT v2.7.4 and reports zero voltages in 2.8.0 -- it was actually caused by a bug fix: practically the only functional difference per `git diff v2.7.4..v2.8.0 drivers/belkin-hid.c` is a change from `abs()` to `fabs()` in order-of-magnitude comparisons like `if( abs(value - 1e-7) < 1e-9 ) {...}` which feel odd on their own, discussed in <a href="https://github.com/networkupstools/nut/issues/2370">https://github.com/networkupstools/nut/issues/2370</a></div><div><br></div><div> The old code worked because `abs()` is for `int` numbers, and the miniscule argument became an always-zero after casting (which is less than `10^-9`), and for existing devices it just happened to be the correct codepath to pick an exponent for USB readings. The new code made the comparisons mathematically correct, to work on `double` precision numbers using `fabs()` (to not confuse with `fabsf()` for `float` types, go figure). And boom! Something no longer clicks for `1.39e-06
=> 13.9V` and `2.206e-05
=> 220V` (with correction factor `1e7`).<br></div><div><br></div><div> Obligatory inspiring motivator : <a href="https://xkcd.com/1172/">https://xkcd.com/1172/</a></div><div><br></div><div> Thanks to Mr. Fischer for the right logs (and version-dissection findings) at the right time :)<br></div><div><br></div><div>Jim Klimov</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 25, 2024 at 7:41 AM Juan Carlos Fischer <<a href="mailto:juancarlos.fischer@gmail.com">juancarlos.fischer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="font-family:"times new roman",serif">Hello Jim!</div><div style="font-family:"times new roman",serif">First of all, allow me to thank you for your time and invaluable help. <br>Exactly <span style="font-family:Arial,Helvetica,sans-serif">arm v7l are 32 bit.</span> I will conduct several tests and keep you informed.</div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">On the other hand this is what I got</div><div style="font-family:"times new roman",serif">pi@raspberrypi:~ $ sudo /lib/nut/usbhid-ups -DDDDDD -a Liebert <br> 0.000000 [D3] do_global_args: var='maxretry' val='3'<br> 0.001309 [D3] do_global_args: var='user' val='nut'<br> 0.001604 [D1] Overriding previously specified user 'nut' with 'nut' specified in global section<br> 0.002196 [D3] main_arg: var='driver' val='usbhid-ups'<br> 0.002280 [D3] main_arg: var='port' val='auto'<br> 0.002360 [D5] send_to_all: SETINFO driver.parameter.port "auto"<br> 0.006042 [D3] main_arg: var='vendorid' val='10AF'<br> 0.006172 [D5] send_to_all: SETINFO driver.parameter.vendorid "10AF"<br> 0.006402 [D3] main_arg: var='productid' val='0001'<br> 0.006490 [D5] send_to_all: SETINFO driver.parameter.productid "0001"<br> 0.006563 [D3] main_arg: var='bus' val='001'<br> 0.006646 [D5] send_to_all: SETINFO driver.parameter.bus "001"<br> 0.006720 [D3] main_arg: var='desc' val='PSA UPS'<br> 0.006792 [D3] main_arg: var='pollinterval' val='15'<br> 0.006980 [D1] debug level is '6'<br> 0.009706 [D5] send_to_all: SETINFO device.type "ups"<br> 0.009873 [D2] Initializing an USB-connected UPS with library libusb-1.0.26 (API: 0x1000109) (NUT subdriver name='USB communication driver (libusb 1.0)' ver='0.43')<br> 0.009942 [D1] upsdrv_initups (non-SHUT)...<br> 0.064656 [D2] Checking device 1 of 12 (2109/0813)<br> 0.064792 [D1] Failed to open device (2109/0813), skipping: Access denied (insufficient permissions)<br> 0.064851 [D2] Checking device 2 of 12 (1058/2620)<br> 0.064956 [D1] Failed to open device (1058/2620), skipping: Access denied (insufficient permissions)<br> 0.065018 [D2] Checking device 3 of 12 (2109/0813)<br> 0.065074 [D1] Failed to open device (2109/0813), skipping: Access denied (insufficient permissions)<br> 0.065122 [D2] Checking device 4 of 12 (1D6B/0003)<br> 0.065171 [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions)<br> 0.065240 [D2] Checking device 5 of 12 (045E/00F5)<br> 0.065275 [D1] Failed to open device (045E/00F5), skipping: Access denied (insufficient permissions)<br> 0.065308 [D2] Checking device 6 of 12 (10AF/0001)<br> 0.077166 [D2] - VendorID: 10af<br> 0.077216 [D2] - ProductID: 0001<br> 0.077277 [D2] - Manufacturer: Emerson Network Power<br> 0.077332 [D2] - Product: LiebertPSA<br> 0.077372 [D2] - Serial Number: <br> 0.077391 [D2] - Bus: 001<br> 0.077427 [D2] - Device: unknown<br> 0.077481 [D2] - Device release number: 0014<br> 0.077560 [D2] Trying to match device<br> 0.077600 [D2] match_function_subdriver (non-SHUT mode): matching a device...<br> 0.077664 [D3] match_function_regex: matching a device...<br> 0.077905 [D2] Device matches<br> 0.077972 [D2] Reading first configuration descriptor<br> 0.078055 [D3] libusb_kernel_driver_active() returned 0<br> 0.078099 [D2] failed to claim USB device: Resource busy<br> 0.078159 [D2] Kernel driver already detached<br> 0.078199 [D2] failed to claim USB device: Resource busy<br> 0.078260 [D2] Kernel driver already detached<br> 0.078317 [D2] failed to claim USB device: Resource busy<br> 0.078379 [D2] Kernel driver already detached<br> 0.078439 [D2] failed to claim USB device: Resource busy<br> 0.078496 [D2] Kernel driver already detached<br> 0.078534 Can't claim USB device [10af:0001]@0/0: Entity not found<br></div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">The same for 2.74. has an endless output.<br>I rescue the following<br></div><div style="font-family:"times new roman",serif"> 0.278176 Path: UPS.Input.Voltage, Type: Feature, ReportID: 0x20, Offset: 0, Size: 16, Value: 2.201e-05<br> 0.278274 Input/OutputVoltage = 2.201e-05 -> assuming correction factor = 1e+07<br> 0.278384 send_to_all: SETINFO input.voltage "220.1"<br> 0.278517 hid_lookup_usage: UPS -> 00840004<br> 0.278621 hid_lookup_usage: Output -> 0084001c<br> 0.278769 hid_lookup_usage: Voltage -> 00840030<br> 0.278913 string_to_path: depth = 3<br> 0.279025 Report[buf]: (3 bytes) => 2b 9e 08<br> 0.279133 PhyMax = 0, PhyMin = 0, LogMax = 65535, LogMin = 0<br> 0.279240 Unit = 00f0d121, UnitExp = -1<br> 0.279304 Exponent = -8<br> 0.279412 Path: UPS.Output.Voltage, Type: Feature, ReportID: 0x2b, Offset: 0, Size: 16, Value: 2.206e-05<br> 0.279523 Input/OutputVoltage = 2.206e-05 -> assuming correction factor = 1e+07<br> 0.279655 send_to_all: SETINFO output.voltage "220.6"<br> 0.279793 hid_lookup_usage: UPS -> 00840004<br> 0.279893 hid_lookup_usage: PowerSummary -> 00840024<br> 0.279999 hid_lookup_usage: Voltage -> 00840030<br> 0.280100 string_to_path: depth = 3<br> 0.280209 Report[buf]: (3 bytes) => 1d 8b 00<br> 0.280313 PhyMax = 0, PhyMin = 0, LogMax = 65535, LogMin = 0<br> 0.280426 Unit = 00f0d121, UnitExp = -1<br> 0.280488 Exponent = -8<br> 0.280596 Path: UPS.PowerSummary.Voltage, Type: Feature, ReportID: 0x1d, Offset: 0, Size: 16, Value: 1.39e-06<br> 0.280707 Input/OutputVoltage = 1.39e-06 -> assuming correction factor = 1e+07<br> 0.280822 send_to_all: SETINFO battery.voltage "13.9"<br> 0.280929 hid_lookup_usage: UPS -> 00840004<br> 0.281029 hid_lookup_usage: PowerSummary -> 00840024<br> 0.281136 hid_lookup_usage: ConfigVoltage -> 00840040<br> 0.281249 string_to_path: depth = 3<br> 0.281361 Report[buf]: (3 bytes) => 1f 0c 00<br> 0.281440 PhyMax = 0, PhyMin = 0, LogMax = 65535, LogMin = 0<br> 0.281539 Unit = 00f0d121, UnitExp = -1<br></div><div style="font-family:"times new roman",serif">Sorry if it's not useful.<br></div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">Best regards</div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">Juan Carlos</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 21, 2024 at 4:57 AM Jim Klimov <<a href="mailto:jimklimov%2Bnut@gmail.com" target="_blank">jimklimov+nut@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thanks again.</div><div><br></div><div> So one more bit (other than indeed different libusb versions) that could potentially come into play is bitness - armv7l builds are 32-bit, right?</div><div><br></div><div> One idea from here is to have you run the driver programs directly with high debug verbosity, e.g. `usbhid-ups -DDDDDD -s Liebert` to compare the two walls of text (at some debug level it spews byte data seen from libusb); this might be more convenient to proceed with as a github issue.</div><div><br></div><div> Another idea, if you would be comfortable building NUT from source, would be to check if NUT v2.8.0 (and/or current git master) mis-behaves similarly if built in the Debian 11 32-bit environment against libusb-0.1. So to dissect if the issue is between NUT 2.7.4 and 2.8.0 or in the OS environment/dependencies somehow. This can get you started: <a href="https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests" target="_blank">https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests</a> (take care to `configure --with-usb=libusb-0.1 ...`) - notably, you won't have to *install* this build over what have you in the OS to just test the newly built driver.<br></div><div><br></div><div>Jim</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 21, 2024 at 7:18 AM Juan Carlos Fischer <<a href="mailto:juancarlos.fischer@gmail.com" target="_blank">juancarlos.fischer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="font-family:"times new roman",serif">Hello!</div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">NUT 2.7.4</div><div style="font-family:"times new roman",serif"><span style="color:rgb(85,85,85);font-family:Arial,Helvetica,sans-serif">Raspberry Pi 4 Model B Rev 1.5 8 GB </span><span style="font-family:Arial,Helvetica,sans-serif">"Raspbian GNU/Linux 11 (bullseye)" </span><span style="font-family:Arial,Helvetica,sans-serif">Linux raspberrypi 5.15.32-v7l+ #1538 SMP Thu Mar 31 19:39:41 BST 2022 armv7l GNU/Linux</span><br></div><div style="font-family:"times new roman",serif"><span style="font-family:Arial,Helvetica,sans-serif"><br></span></div><div style="font-family:"times new roman",serif">pi@raspberrypi:~ $ sudo ldd /lib/nut/usbhid-ups</div><div style="font-family:"times new roman",serif"><br> linux-vdso.so.1 (0xbec53000)<br> /usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0xb6f83000)<br> libusb-0.1.so.4 => /lib/arm-linux-gnueabihf/libusb-0.1.so.4 (0xb6f4e000)<br> libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6f22000)<br> libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6dce000)<br> /lib/ld-linux-armhf.so.3 (0xb6f98000)<span style="font-family:Arial,Helvetica,sans-serif"><br></span></div><div style="font-family:"times new roman",serif"><br></div></div><div style="font-family:"times new roman",serif">NUT 2.8.0</div><div style="font-family:"times new roman",serif"><span style="color:rgb(85,85,85);font-family:Arial,Helvetica,sans-serif">Raspberry Pi 4 Model B Rev 1.5 8 GB "Debian GNU/Linux 12 (bookworm)" </span>Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux<br></div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">pi@raspberrypi:~ $ sudo ldd /lib/nut/usbhid-ups<br></div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif"> linux-vdso.so.1 (0x0000007f9051c000)<br> libusb-1.0.so.0 => /lib/aarch64-linux-gnu/libusb-1.0.so.0 (0x0000007f90410000)<br> libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f90260000)<br> /lib/ld-linux-aarch64.so.1 (0x0000007f904df000)<br> libudev.so.1 => /lib/aarch64-linux-gnu/libudev.so.1 (0x0000007f90210000)<br> libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f901e0000)<br></div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">Best regards,</div><div style="font-family:"times new roman",serif">-jcf</div><div style="font-family:"times new roman",serif"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 20, 2024 at 5:10 PM Jim Klimov <<a href="mailto:jimklimov%2Bnut@gmail.com" target="_blank">jimklimov+nut@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thanks.</div><div><br></div><div> Can you please also check (e.g. with ldd `which usbhid-ups`) which `libusb` variant (1.0 or 0.1) was the 2.7.4 version of the driver running with?<br></div><div> I wonder if the two generations of that library got something differently?..</div><div><br></div><div> The commit I mentioned - <a href="https://github.com/networkupstools/nut/commit/207fed2282" target="_blank">https://github.com/networkupstools/nut/commit/207fed2282</a> - which added the exponent checks, was from 2012 and should be in 2.7.4 as well :-\<br></div><div><br></div><div> Checked: it is - <a href="https://github.com/networkupstools/nut/blob/v2.7.4/drivers/belkin-hid.c#L157-L194" target="_blank">https://github.com/networkupstools/nut/blob/v2.7.4/drivers/belkin-hid.c#L157-L194</a></div><div><br></div><div> Are the two tests running on otherwise the same HW/OS setup?</div><div><br></div><div>Jim<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 20, 2024 at 9:01 PM Juan Carlos Fischer <<a href="mailto:juancarlos.fischer@gmail.com" target="_blank">juancarlos.fischer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="font-family:"times new roman",serif">Hello!</div><div style="font-family:"times new roman",serif">Thanks for answering.<br>This is the result using version 2.7.4:<br></div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">Network UPS Tools - UPS driver controller 2.7.4<br>Network UPS Tools - Generic HID driver 0.41 (2.7.4)<br>USB communication driver 0.33<br>Using subdriver: Belkin/Liebert HID 0.17<br></div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">battery.charge: 100<br>battery.charge.low: 38<br>battery.charge.warning: 38<br>battery.type: PbAc<br>battery.voltage: 13.9<br>battery.voltage.nominal: 12.0<br>device.mfr: Emerson Network Power<br>device.model: LiebertPSA<br>device.serial: <br>device.type: ups<br><a href="http://driver.name" target="_blank">driver.name</a>: usbhid-ups<br>driver.parameter.bus: 001<br>driver.parameter.pollfreq: 30<br>driver.parameter.pollinterval: 2<br>driver.parameter.port: auto<br>driver.parameter.productid: 0001<br>driver.parameter.synchronous: no<br>driver.parameter.vendorid: 10AF<br>driver.version: 2.7.4<br>driver.version.data: Belkin/Liebert HID 0.17<br>driver.version.internal: 0.41<br>input.frequency: 50.0<br>input.voltage: 221.8<br>output.voltage: 222.6<br>ups.load: 8<br>ups.mfr: Emerson Network Power<br>ups.model: LiebertPSA<br>ups.productid: 0001<br>ups.serial: <br>ups.status: OL CHRG<br>ups.vendorid: 10af<br></div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">Regards,</div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">Juan Carlos</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 20, 2024 at 4:22 PM Jim Klimov <<a href="mailto:jimklimov%2Bnut@gmail.com" target="_blank">jimklimov+nut@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello,</div><div><br></div><div> For clarity: what changed with the move from NUT v2.7.4 to 2.8.0 - the warnings "became reported", or the highlighted values became zeroes (and were valid non-zero numbers with older NUT - so a regression)?</div><div><br></div><div> It seems the message is specific to the subdriver and comes from commit 207fed2282 and a change to the method involved was just recently experimentally proposed in <a href="https://github.com/networkupstools/nut/issues/2271" target="_blank">https://github.com/networkupstools/nut/issues/2271</a> discussion comments (refinement to consider merging as a pull request pending).<br></div><div><br></div><div>Thanks,</div><div>Jim<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 20, 2024 at 3:33 PM Juan Carlos Fischer via Nut-upsuser <<a href="mailto:nut-upsuser@alioth-lists.debian.net" target="_blank">nut-upsuser@alioth-lists.debian.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello everyone<br><br>I'm using: Raspberry Pi 4 Model B Rev 1.5 8 GB "Debian GNU/Linux 12 (bookworm)"<br><br>It all started when I updated from version 2.7.4 to version 2.8.0 and the consequences were the following:<br><br>pi@raspberrypi:~ $ sudo upsdrvctl start<div><br>Network UPS Tools - UPS driver controller 2.8.0<br>Network UPS Tools - Generic HID driver 0.47 (2.8.0)<br>USB communication driver (libusb 1.0) 0.43<br>Using subdriver: Belkin/Liebert HID 0.18<br>LineVoltage exponent looks wrong, but not correcting.<br>LineVoltage exponent looks wrong, but not correcting.<br>LineVoltage exponent looks wrong, but not correcting.<br>ConfigVoltage exponent looks wrong, but not correcting.<br><br>pi@raspberrypi:~ $ upsc Liebert</div><div><br>Init SSL without certificate database<br>battery.charge: 100<br>battery.charge.low: 38<br>battery.charge.warning: 38<br>battery.type: PbAc<br><b>battery.voltage: 0.0 <------------<br>battery.voltage.nominal: 0.0 <----------</b><br>device.mfr: Emerson Network Power<br>device.model: LiebertPSA<br>device.serial: <br>device.type: ups<br><a href="http://driver.name" target="_blank">driver.name</a>: usbhid-ups<br>driver.parameter.bus: 001<br>driver.parameter.pollfreq: 30<br>driver.parameter.pollinterval: 15<br>driver.parameter.port: auto<br>driver.parameter.productid: 0001<br>driver.parameter.synchronous: auto<br>driver.parameter.vendorid: 10AF<br>driver.version: 2.8.0<br>driver.version.data: Belkin/Liebert HID 0.18<br>driver.version.internal: 0.47<br>driver.version.usb: libusb-1.0.26 (API: 0x1000109)<br>input.frequency: 49.9<br><b>input.voltage: 0.0 <---------------<br>output.voltage: 0.0 <--------------</b><br>ups.load: 9<br>ups.mfr: Emerson Network Power<br>ups.model: LiebertPSA<br>ups.productid: 0001<br>ups.serial: <br>ups.status: OL CHRG<br>ups.vendorid: 10af<br><br>Except for those marked, all values are correct.<br><br>Any help would be appreciated.</div><div><br></div><div><div style="font-family:"times new roman",serif">Regards,</div><div style="font-family:"times new roman",serif"><br></div><div style="font-family:"times new roman",serif">Juan Carlos</div><br></div></div>
_______________________________________________<br>
Nut-upsuser mailing list<br>
<a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank">Nut-upsuser@alioth-lists.debian.net</a><br>
<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div></div>