Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/libusb{0,1}.c: {,nut_}libusb_open(): try to re-fetch curDevice->Vendor, Product, Serial if NULL, after claiming it by other criteria #2571

Merged
merged 9 commits into from
Aug 11, 2024

Conversation

jimklimov
Copy link
Member

Follow-up to #2562 so based on its code to facilitate testing right from github sources:

:; git clone https://github.com/jimklimov/nut -b issue-2562-retry-NULL-IDs nut
:; cd nut
...

...otherwise same as discussed in that ticket.

It is still not clear why some devices (or libusb) fail to return this information initially, while tools like lsusb and udevadm info see it well; maybe permissions or something else. Either way, the guessing leap of faith for this change set is that "claiming" the USB device changes something, and we would be able to read those data points subsequently. Got only one way to find out :)

CC @desertwitch @masterwishx @loso2255 @lemeshovich

networkupstools#1925]

Also handle "unknown 2000" assuming it is a mis-read "Eaton 9E 2000(i?)"
which refused to tell libusb its vendor/product/serial strings.

This may be the answer to such issues as networkupstools#1925, networkupstools#2380 (re-opened), networkupstools#2492

Signed-off-by: Jim Klimov <[email protected]>
…ools#2562]

I did not find any actual mentions of plain "9E2000" without an "i",
only these: https://www.eaton.com/tr/en-gb/skuPage.9E2000I.html

Also prepared for "9E3000i" models while here.

Signed-off-by: Jim Klimov <[email protected]>
…or, Product, Serial if NULL, after claiming it by other criteria [networkupstools#2562]

Signed-off-by: Jim Klimov <[email protected]>
…Product, Serial if NULL, after claiming it by other criteria [networkupstools#2562]

Signed-off-by: Jim Klimov <[email protected]>
@jimklimov jimklimov added enhancement USB portability We want NUT to build and run everywhere possible Incorrect or missing readings On some devices driver-reported values are systemically off (e.g. x10, x0.1, const+Value, etc.) impacts-release-2.8.2 Issues reported against NUT release 2.8.2 (maybe vanilla or with minor packaging tweaks) labels Jul 31, 2024
@jimklimov jimklimov added this to the 2.8.3 milestone Jul 31, 2024
@masterwishx
Copy link
Contributor

Do I need to wait for checks befor compile?
@desertwitch can I ask you again to compile or provide me config file?

@jimklimov
Copy link
Member Author

jimklimov commented Jul 31, 2024

Do I need to wait for checks before compile?

Not really, I hope. At least, if there are syntax nuances here that other OSes would complain about but your build succeeds - that would be good enough to check if the concept has merit.

If there are some worse typos, a build would fail :) So far it survived a few scenarios, including on Slackware, so the likeliness of fatal typos is low :)

@masterwishx
Copy link
Contributor

If I not mistake 9E2000i, i - > mean:
eu 230v plugs in Tower ups, in my case Israel.
ir - > same but rack ups. Also 9E1000i model exist.

@masterwishx
Copy link
Contributor

just some more info from document of 9E :

image

image

jimklimov added a commit to jimklimov/nut that referenced this pull request Jul 31, 2024
@jimklimov
Copy link
Member Author

Converting to draft while this is being tested, so NUT CI won't rebuild it in vain against newer target branch as it evolves.

@jimklimov jimklimov marked this pull request as draft August 1, 2024 06:49
@masterwishx
Copy link
Contributor

@jimklimov Thanks for @desertwitch for compiling again , but still have 9E2000i (presumed)

battery.capacity: 7.00
battery.charge: 100
battery.charge.low: 20
battery.charge.restart: 0
battery.protection: yes
battery.runtime: 3399
battery.runtime.low: 180
battery.type: 
battery.voltage: 83.0
battery.voltage.nominal: 72
device.mfr: Eaton
device.model: 9E2000i (presumed)
device.type: ups
driver.debug: 0
driver.flag.allow_killpower: 0
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: auto
driver.state: quiet
driver.version: 2.8.2.1
driver.version.data: MGE HID 1.48
driver.version.internal: 0.55
driver.version.usb: libusb-1.0.26 (API: 0x1000108)
input.bypass.frequency: 49.9
input.bypass.voltage: 231.0
input.frequency: 49.9
input.frequency.nominal: 50
input.transfer.high: 300
input.transfer.low: 100
input.voltage: 231.0
input.voltage.nominal: 232
outlet.1.status: on
outlet.desc: Main Outlet
outlet.id: 0
outlet.switchable: no
output.current: 1.60
output.frequency: 49.9
output.frequency.nominal: 50
output.voltage: 230.0
output.voltage.nominal: 230
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.firmware: 
ups.load: 20
ups.load.high: 105
ups.mfr: Eaton
ups.model: 9E2000i (presumed)
ups.power: 387
ups.power.nominal: 2000
ups.productid: ffff
ups.realpower: 252
ups.realpower.nominal: 1600
ups.shutdown: enabled
ups.start.auto: yes
ups.start.battery: yes
ups.start.reboot: yes
ups.status: OL
ups.temperature: 24.9
ups.test.interval: 604800
ups.test.result: Done and passed
ups.timer.shutdown: -1
ups.timer.start: -1
ups.type: online
ups.vendorid: 0463

@masterwishx
Copy link
Contributor

i think The only change for this pr and old that now : 9E2000i (presumed) and was 9E2000 (presumed) without "i"

@jimklimov
Copy link
Member Author

@masterwishx : thanks, can you also get the usbhid-ups debug log from the start-up, does it retry getting the identification metadata (whether successful or not) after claiming the device?

Did you have a chance to try the idea with quirk configuration?

@masterwishx
Copy link
Contributor

can you also get the usbhid-ups debug log from the start-up, does it retry getting the identification metadata (whether successful or not) after claiming the device?

I will try

@masterwishx
Copy link
Contributor

Did you have a chance to try the idea with quirk configuration?

What does it mean?

@jimklimov
Copy link
Member Author

Did you have a chance to try the idea with quirk configuration?

What does it mean?

Per #2562 (comment) you could try

Adding the kernel parameter usbhid.quirks=0x0463:0xffff:0x08

Maybe better google first for what such parameters do, their syntax, values, etc.

@desertwitch
Copy link
Contributor

desertwitch commented Aug 1, 2024

can you also get the usbhid-ups debug log from the start-up, does it retry getting the identification metadata (whether successful or not) after claiming the device?

I will try

In the plugin under "NUT Settings" set "UPS Driver Debug Level" to the highest level and then restart NUT, check the SYSLOG and post the results here. Ideally put in a text file with all the logs included.

@masterwishx
Copy link
Contributor

usbhid-ups

usbhid-ups seems not avalible anymore ?

@desertwitch
Copy link
Contributor

usbhid-ups

usbhid-ups seems not avalible anymore ?

It's under /usr/libexec/nut/ on Unraid, but you don't need to call it directly if you set the debug level in the NUT Settings and restart from the GUI (then check SYSLOG).

@masterwishx
Copy link
Contributor

usbhid-ups

usbhid-ups seems not avalible anymore ?

It's under /usr/libexec/nut/ on Unraid, but you don't need to call it directly if you set the debug level in the NUT Settings and restart from the GUI (then check SYSLOG).

Thanks i got it.

@masterwishx
Copy link
Contributor

@jimklimov here the syslog from usbhid-ups :

nut.log

@masterwishx
Copy link
Contributor

@desertwitch after made scan for device i think i got some more in config than in backup version , do i need this in config?

image

@desertwitch
Copy link
Contributor

desertwitch commented Aug 1, 2024

@desertwitch after made scan for device i think i got some more in config than in backup version , do i need this in config?

image

It doesn't matter, these are just GUI settings, you don't need to touch that configuration file.
If you don't put them in right now, they will be written back in the next time you save the GUI settings.

@jimklimov
Copy link
Member Author

@jimklimov here the syslog from usbhid-ups :

nut.log

Thanks! So it confirms that the re-discovery of identification strings is attempted with the claimed device, but still fails:

Aug  1 16:04:47 DaRKNaS rc.nut:    0.140242#011[D2:14407] Checking device 8 of 9 (0463/FFFF)
Aug  1 16:04:47 DaRKNaS rc.nut:    0.161396#011[D1:14407] nut_libusb_open get iManufacturer failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.182560#011[D1:14407] nut_libusb_open get iManufacturer failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.203750#011[D1:14407] nut_libusb_open get iManufacturer failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.224965#011[D1:14407] nut_libusb_open get iProduct failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.246221#011[D1:14407] nut_libusb_open get iProduct failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.267375#011[D1:14407] nut_libusb_open get iProduct failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.288551#011[D1:14407] nut_libusb_open get iSerialNumber failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.309733#011[D1:14407] nut_libusb_open get iSerialNumber failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330911#011[D1:14407] nut_libusb_open get iSerialNumber failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330924#011[D2:14407] - VendorID: 0463
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330926#011[D2:14407] - ProductID: ffff
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330928#011[D2:14407] - Manufacturer: unknown
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330929#011[D2:14407] - Product: unknown
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330931#011[D2:14407] - Serial Number: unknown
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330933#011[D2:14407] - Bus: 003
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330935#011[D2:14407] - Bus Port: 003
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330937#011[D2:14407] - Device: 002
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330938#011[D2:14407] - Device release number: 0202
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330957#011[D2:14407] Trying to match device
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330960#011[D2:14407] match_function_subdriver (non-SHUT mode): matching a device...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330964#011[D3:14407] match_function_regex: matching a device...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330966#011[D2:14407] Device matches
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330968#011[D2:14407] Reading configuration descriptor 1 of 1
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330979#011[D3:14407] libusb_kernel_driver_active() returned 0: Success
Aug  1 16:04:47 DaRKNaS rc.nut:    0.330997#011[D2:14407] Claimed interface 0 successfully
Aug  1 16:04:47 DaRKNaS rc.nut:    0.331000#011[D3:14407] nut_usb_set_altinterface: skipped libusb_set_interface_alt_setting(udev, 0, 0)
Aug  1 16:04:47 DaRKNaS rc.nut:    0.352192#011[D1:14407] nut_libusb_open get iManufacturer failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.373363#011[D1:14407] nut_libusb_open get iManufacturer failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.394534#011[D1:14407] nut_libusb_open get iManufacturer failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.394543#011[D2:14407] - Manufacturer: unknown
Aug  1 16:04:47 DaRKNaS rc.nut:    0.415717#011[D1:14407] nut_libusb_open get iProduct failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.436928#011[D1:14407] nut_libusb_open get iProduct failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.458081#011[D1:14407] nut_libusb_open get iProduct failed, retrying...
Aug  1 16:04:47 DaRKNaS rc.nut:    0.458093#011[D2:14407] - Product: unknown
Aug  1 16:04:47 DaRKNaS rc.nut:    0.479521#011[D1:14407] nut_libusb_open get iSerialNumber failed, retrying...
Aug  1 16:04:48 DaRKNaS rc.nut:    0.500751#011[D1:14407] nut_libusb_open get iSerialNumber failed, retrying...
Aug  1 16:04:48 DaRKNaS rc.nut:    0.521908#011[D1:14407] nut_libusb_open get iSerialNumber failed, retrying...
Aug  1 16:04:48 DaRKNaS rc.nut:    0.521928#011[D2:14407] - Serial Number: unknown
Aug  1 16:04:48 DaRKNaS rc.nut:    0.552642#011[D2:14407] Retrieved HID descriptor (expected 9, got 9)
Aug  1 16:04:48 DaRKNaS rc.nut:    0.552654#011[D3:14407] HID descriptor, method 1: (9 bytes) => 09 21 10 01 21 01 22 05 08
Aug  1 16:04:48 DaRKNaS rc.nut:    0.552657#011[D3:14407] HID descriptor length (method 1) 2053
Aug  1 16:04:48 DaRKNaS rc.nut:    0.552659#011[D4:14407] i=0, extra[i]=09, extra[i+1]=21
Aug  1 16:04:48 DaRKNaS rc.nut:    0.552661#011[D3:14407] HID descriptor, method 2: (9 bytes) => 09 21 10 01 21 01 22 f6 03
Aug  1 16:04:48 DaRKNaS rc.nut:    0.552666#011[D3:14407] HID descriptor length (method 2) 1014
Aug  1 16:04:48 DaRKNaS rc.nut:    0.552667#011[D1:14407] Eaton device v2.02. Using full report descriptor
Aug  1 16:04:48 DaRKNaS rc.nut:    0.552669#011[D2:14407] Warning: two different HID descriptors retrieved (Reportlen = 2053 vs. 1014)
Aug  1 16:04:48 DaRKNaS rc.nut:    0.552671#011[D2:14407] HID descriptor length 2053
Aug  1 16:04:51 DaRKNaS rc.nut:    3.819549#011[D2:14407] Report Descriptor size = 2053
Aug  1 16:04:51 DaRKNaS rc.nut:    3.819578#011[D3:14407] Report Descriptor: (2053 bytes) => 05 84 09 04 a1 01 09 10 a1 00 09 12 a1 <...>
...
Aug  1 16:04:51 DaRKNaS rc.nut:    3.820639#011Using subdriver: MGE HID 1.48
Aug  1 16:04:51 DaRKNaS rc.nut:    3.820643#011[D1:14407] 218 HID objects found
Aug  1 16:04:51 DaRKNaS rc.nut:    3.820649#011[D4:14407] Entering libusb_get_report
Aug  1 16:04:51 DaRKNaS rc.nut:    3.839860#011[D3:14407] Report[get]: (2 bytes) => 28 02
...

That Using subdriver: ... message comes from usbhid-ups.c::callback() method (so specific for protocol expected of these devices, unlike the more generic libusbN.c files), so there may be a chance to fill these data points while walking the report descriptors, perhaps.

At least, there are lots of reports named like UPS.PowerSummary.iManufacturer, UPS.PowerSummary.iModel, UPS.PowerSummary.iOEMInformation, UPS.PowerSummary.iPartNumber, UPS.PowerSummary.iProduct, UPS.PowerSummary.iSerialNumber etc. which seem relevant but I do not know at the moment if they ought to be desired strings or references to some other location that would have the strings, and how to wrangle that. That said, maybe the driver does try already:

...
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270847#011[D5:14407] hid_lookup_path: 00840004 -> UPS
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270852#011[D5:14407] hid_lookup_path: 00840024 -> PowerSummary
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270857#011[D5:14407] hid_lookup_path: ffff00f0 -> iModel
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270863#011[D1:14407] Path: UPS.PowerSummary.iModel, Type: Feature, ReportID: 0x10, Offset: 16, Size: 8, Value: 3
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270870#011[D3:14407] Report[buf]: (11 bytes) => 10 05 01 03 07 09 02 0a 04 06 0b
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270876#011[D5:14407] PhyMax = 0, PhyMin = 0, LogMax = 255, LogMin = 0
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270881#011[D5:14407] Unit = 00000000, UnitExp = 0
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270885#011[D5:14407] Exponent = 0
...
Aug  1 16:04:52 DaRKNaS rc.nut:    5.479612#011[D5:14407] hid_lookup_usage: UPS -> 00840004
Aug  1 16:04:52 DaRKNaS rc.nut:    5.479621#011[D5:14407] hid_lookup_usage: PowerSummary -> 00840024
Aug  1 16:04:52 DaRKNaS rc.nut:    5.479628#011[D5:14407] hid_lookup_usage: iModel -> ffff00f0
Aug  1 16:04:52 DaRKNaS rc.nut:    5.479632#011[D4:14407] string_to_path: depth = 3
Aug  1 16:04:52 DaRKNaS rc.nut:    5.479646#011[D3:14407] Report[buf]: (11 bytes) => 10 05 01 03 07 09 02 0a 04 06 0b
Aug  1 16:04:52 DaRKNaS rc.nut:    5.479651#011[D5:14407] PhyMax = 0, PhyMin = 0, LogMax = 255, LogMin = 0
Aug  1 16:04:52 DaRKNaS rc.nut:    5.479655#011[D5:14407] Unit = 00000000, UnitExp = 0
Aug  1 16:04:52 DaRKNaS rc.nut:    5.479659#011[D5:14407] Exponent = 0
Aug  1 16:04:53 DaRKNaS rc.nut:    5.500864#011nut_libusb_get_string: Input/Output Error
Aug  1 16:04:53 DaRKNaS rc.nut:    5.500904#011[D5:14407] hid_lookup_usage: UPS -> 00840004
Aug  1 16:04:53 DaRKNaS rc.nut:    5.500913#011[D5:14407] hid_lookup_usage: Flow -> 0084001e
Aug  1 16:04:53 DaRKNaS rc.nut:    5.500923#011[D5:14407] hid_lookup_usage: [4] -> not found in lookup table
Aug  1 16:04:53 DaRKNaS rc.nut:    5.500928#011[D5:14407] string_to_path: hid_lookup_usage failed, checking if token [4] is a raw value
Aug  1 16:04:53 DaRKNaS rc.nut:    5.500942#011[D5:14407] hid_lookup_usage: ConfigApparentPower -> 00840043
Aug  1 16:04:53 DaRKNaS rc.nut:    5.500946#011[D4:14407] string_to_path: depth = 4
Aug  1 16:04:53 DaRKNaS rc.nut:    5.500952#011[D4:14407] Entering libusb_get_report
Aug  1 16:04:53 DaRKNaS rc.nut:    5.523195#011[D3:14407] Report[get]: (5 bytes) => 74 40 06 d0 07
Aug  1 16:04:53 DaRKNaS rc.nut:    5.523217#011[D5:14407] PhyMax = 0, PhyMin = 0, LogMax = 65535, LogMin = 0
Aug  1 16:04:53 DaRKNaS rc.nut:    5.523224#011[D5:14407] Unit = 0000d121, UnitExp = 7
Aug  1 16:04:53 DaRKNaS rc.nut:    5.523230#011[D5:14407] Exponent = 0
Aug  1 16:04:53 DaRKNaS rc.nut:    5.523237#011[D2:14407] get_model_name(unknown, 2000)
Aug  1 16:04:53 DaRKNaS rc.nut: 
Aug  1 16:04:53 DaRKNaS rc.nut:    5.523242#011[D2:14407] comparing with: ellipse 300
...

...which is probably the fallback in that ofter-referenced method that assigns "unknown" when nothing else helps (note the nut_libusb_get_string: Input/Output Error message in the log).

Later also I can see the likes of

Aug  1 16:04:53 DaRKNaS rc.nut:    5.633177#011[D2:14407] Path: UPS.PowerSummary.iVersion, Type: Feature, ReportID: 0x10, Offset: 64, Size: 8, Value: 6
Aug  1 16:04:53 DaRKNaS rc.nut:    5.654478#011nut_libusb_get_string: Input/Output Error
Aug  1 16:04:53 DaRKNaS rc.nut:    5.654506#011[D5:14407] send_to_all: SETINFO ups.firmware ""

And, notably for your other concern, there is a UPS.PowerSummary.iDeviceChemistry (Value: 5) too.

Aug  1 16:04:52 DaRKNaS rc.nut:    5.270750#011[D5:14407] hid_lookup_path: 00840004 -> UPS
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270756#011[D5:14407] hid_lookup_path: 00840024 -> PowerSummary
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270762#011[D5:14407] hid_lookup_path: 00850089 -> iDeviceChemistry
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270769#011[D1:14407] Path: UPS.PowerSummary.iDeviceChemistry, Type: Feature, ReportID: 0x10, Offset: 0, Size: 8, Value: 5
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270781#011[D3:14407] Report[buf]: (11 bytes) => 10 05 01 03 07 09 02 0a 04 06 0b
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270787#011[D5:14407] PhyMax = 0, PhyMin = 0, LogMax = 255, LogMin = 0
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270791#011[D5:14407] Unit = 00000000, UnitExp = 0
Aug  1 16:04:52 DaRKNaS rc.nut:    5.270796#011[D5:14407] Exponent = 0
...
Aug  1 16:04:53 DaRKNaS rc.nut:    5.570964#011[D5:14407] hid_lookup_usage: UPS -> 00840004
Aug  1 16:04:53 DaRKNaS rc.nut:    5.570966#011[D5:14407] hid_lookup_usage: PowerSummary -> 00840024
Aug  1 16:04:53 DaRKNaS rc.nut:    5.570969#011[D5:14407] hid_lookup_usage: iDeviceChemistry -> 00850089
Aug  1 16:04:53 DaRKNaS rc.nut:    5.570971#011[D4:14407] string_to_path: depth = 3
Aug  1 16:04:53 DaRKNaS rc.nut:    5.570975#011[D3:14407] Report[buf]: (11 bytes) => 10 05 01 03 07 09 02 0a 04 06 0b
Aug  1 16:04:53 DaRKNaS rc.nut:    5.570977#011[D5:14407] PhyMax = 0, PhyMin = 0, LogMax = 255, LogMin = 0
Aug  1 16:04:53 DaRKNaS rc.nut:    5.570978#011[D5:14407] Unit = 00000000, UnitExp = 0
Aug  1 16:04:53 DaRKNaS rc.nut:    5.570980#011[D5:14407] Exponent = 0
Aug  1 16:04:53 DaRKNaS rc.nut:    5.570982#011[D2:14407] Path: UPS.PowerSummary.iDeviceChemistry, Type: Feature, ReportID: 0x10, Offset: 0, Size: 8, Value: 5
Aug  1 16:04:53 DaRKNaS rc.nut:    5.592217#011nut_libusb_get_string: Input/Output Error
Aug  1 16:04:53 DaRKNaS rc.nut:    5.592248#011[D5:14407] send_to_all: SETINFO battery.type ""

...so at least it mis-behaves consistently, whatever the root-cause :\

CC @arnaudquette-eaton : the posted log includes a HID dump with a number of "not found in lookup table" items. Would your team be able to fill in the blind spots to the mapping tables, please?

@masterwishx
Copy link
Contributor

masterwishx commented Aug 1, 2024

Did you have a chance to try the idea with quirk configuration?

What does it mean?

Per #2562 (comment) you could try

Adding the kernel parameter usbhid.quirks=0x0463:0xffff:0x08

Maybe better google first for what such parameters do, their syntax, values, etc.

For this, I can try it if @desertwitch can say how better to make it in unraid if it still needed?
But from what I was reading from issues it's help when ups disconnect from usb driver, I don't have same issue, all working fine and no disconnection founded.

@desertwitch
Copy link
Contributor

desertwitch commented Aug 6, 2024

I think the code is definitely an enrichment for such situations where detection initially fails otherwise, in particular as some at first glance unimportant parameters may in fact be utilized for applying hot-fixes (see recent APC issue) as Jim pointed out. As to the issue at hand, even if not fully resolved, there's probably not too much more that can be done here. At least we did see some improvement, but it might also well be caused by the OS/other external factors that we're not getting much further here.

@masterwishx
Copy link
Contributor

Per #2562 (comment) you could try

Adding the kernel parameter usbhid.quirks=0x0463:0xffff:0x08

@desertwitch do you think this can help? If so where in Unraid to add it for check?

@masterwishx
Copy link
Contributor

CC @arnaudquette-eaton : the posted log includes a HID dump with a number of "not found in lookup table" items. Would your team be able to fill in the blind spots to the mapping tables, please?

@arnaudquette-eaton can you please check it?

@jimklimov
Copy link
Member Author

jimklimov commented Aug 6, 2024

Regarding quirks, Slackware manuals imply that to pass kernel cmdline arguments you'd have to edit them during boot (in loader): http://www.slackware.com/faq/do_faq.php?faq=installation

For lilo or grub you can find a config file to edit (menu.lst or some such), but preferably after testing that the option does not break system boot.

Some systems that wrap initrd management with tools can have other config files that indirectly impact what the next kernel boot would use.

@masterwishx
Copy link
Contributor

Regarding quirks, Slackware manuals imply that to pass kernel cmdline arguments you'd have to edit them during boot (in loader): http://www.slackware.com/faq/do_faq.php?faq=installation

For lilo or grub you can find a config file to edit, but preferably after testing that the option does break system boot.

Some systems that wrap initrd management with tools can have other config files that indirectly impact what the next kernel boot would use.

Yes i found way to add it to Unrad but seems its not fixed the issue ...
added to syslinux.cfg :
image
Then i see in boot syslog :
image

Then all seems same i got :
image

@jimklimov
Copy link
Member Author

jimklimov commented Aug 7, 2024

Well, thanks for trying, and sorry it did not help. FWIW, do lsusb and udevadm info report anything differently with this option in place?

I think, in the time-frame I've had and with remote guess-work based development/debugging, this couple of PRs is about as much as I can do for this issue.

A moderately poor follow-up hack could be to add platform-dependent optional blocks of code to call these tools or dig in sysfs, and parse the (meta)data findings from there. Arguably this is what libusb should have done for us, though. But as a stop-gap solution it might be useful.

@desertwitch : another idea that I think we did not try lately is to bulid NUT against libusb-0.1 (preferably not compat, but the original different codebase), to check if it fares differently?

I hope vendor representatives (wink @arnaudquette-eaton) with a more intimate knowledge of the USB stack, libusb per se, and the device behavior as not a black box for them, could figure out how NUT and lsusb differ in the queries for that basic data, that we fail and they succeed.

@masterwishx
Copy link
Contributor

Well, thanks for trying, and sorry it did not help. FWIW, do lsusb and udevadm info report anything differently with this option in place?

I think, in the time-frame I've had and with remote guess-work based development/debugging, this couple of PRs is about as much as I can do for this issue.

A moderately poor follow-up hack could be to add platform-dependent optional blocks of code to call these tools or dig in sysfs, and parse the (meta)data findings from there. Arguably this is what libusb should have done for us, though. But as a stop-gap solution it might be useful.

@desertwitch : another idea that I think we did not try lately is to bulid NUT against libusb-0.1 (preferably not compat, but the original different codebase), to check if it fares differently?

I hope vendor representatives (wink @arnaudquette-eaton) with a more intimate knowledge of the USB stack, libusb per se, and the device behavior as not a black box for them, could figure out how NUT and lsusb differ in the queries for that basic data, that we fail and they succeed.

Also like I said befor there is Unraid v7 beta2 that use newver version of lsusb but not shure if it will help...

@masterwishx
Copy link
Contributor

Well, thanks for trying, and sorry it did not help. FWIW, do lsusb and udevadm info report anything differently with this option in place?

I can check it...

@masterwishx
Copy link
Contributor

Well, thanks for trying, and sorry it did not help. FWIW, do lsusb and udevadm info report anything differently with this option in place?

I think, in the time-frame I've had and with remote guess-work based development/debugging, this couple of PRs is about as much as I can do for this issue.

A moderately poor follow-up hack could be to add platform-dependent optional blocks of code to call these tools or dig in sysfs, and parse the (meta)data findings from there. Arguably this is what libusb should have done for us, though. But as a stop-gap solution it might be useful.

@desertwitch : another idea that I think we did not try lately is to bulid NUT against libusb-0.1 (preferably not compat, but the original different codebase), to check if it fares differently?

I hope vendor representatives (wink @arnaudquette-eaton) with a more intimate knowledge of the USB stack, libusb per se, and the device behavior as not a black box for them, could figure out how NUT and lsusb differ in the queries for that basic data, that we fail and they succeed.

Looks like same as was :

Bus 003 Device 002: ID 0463:ffff MGE UPS Systems UPS
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0463 MGE UPS Systems
  idProduct          0xffff UPS
  bcdDevice            2.02
  iManufacturer           1 EATON
  iProduct                2 Eaton 9E
  iSerial                 4 GExxxxxx  #hidden by me
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0022
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               20mA
    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.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength    1014
         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              20
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

@masterwishx
Copy link
Contributor

P: /devices/pci0000:00/0000:00:14.0/usb3/3-3
N: bus/usb/003/002
E: BUSNUM=003
E: DEVNAME=/dev/bus/usb/003/002
E: DEVNUM=002
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-3
E: DEVTYPE=usb_device
E: DRIVER=usb
E: ID_BUS=usb
E: ID_FOR_SEAT=usb-pci-0000_00_14_0-usb-0_3
E: ID_MODEL=Eaton_9E
E: ID_MODEL_ENC=Eaton\x209E
E: ID_MODEL_ID=ffff
E: ID_PATH=pci-0000:00:14.0-usb-0:3
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_3
E: ID_REVISION=0202
E: ID_SERIAL=EATON_Eaton_9E_GE#hiddenbyme
E: ID_SERIAL_SHORT=GE#hiddenbyme
E: ID_USB_INTERFACES=:030000:
E: ID_VENDOR=EATON
E: ID_VENDOR_ENC=EATON
E: ID_VENDOR_ID=0463
E: MAJOR=189
E: MINOR=257
E: NVME_HOST_IFACE=none
E: PRODUCT=463/ffff/202
E: SUBSYSTEM=usb
E: TAGS=:seat:
E: TYPE=0/0/0
E: USEC_INITIALIZED=27455456


@masterwishx
Copy link
Contributor

Also seems no logs in usbhid-ups in this case:
nut1.log

@masterwishx
Copy link
Contributor

masterwishx commented Aug 10, 2024

@jimklimov as I remember apcupsc for unraid native app for ups can show model etc and serial number:
Not sure but Maybe this can help as I found some hexcodes same as we have above:
https://sourceforge.net/p/apcupsd/svn/HEAD/tree/tags/Release-3_14_14/src/drivers/usb/usb.c#l110

   {CI_UPSMODEL,                0x008400fe, P_ANY,     P_ANY,   T_INDEX,    false},  /* iProduct */
   {CI_SERNO,                   0x008400ff, P_ANY,     P_ANY,   T_INDEX,    false},  /* iSerialNumber */
   {CI_MANDAT,                  0x00850085, P_ANY,     P_PWSUM, T_DATE,     false},  /* ManufactureDate */

@jimklimov
Copy link
Member Author

Thanks, those we have (in drivers/libhid.c) and apparently fail to fetch for some reason :\

It does not seem that this PR would hurt, and the #2562 it includes does help with at least some aspects, so would merge.

I do hope that Eaton experts would chime in after the vacation era... :)

@jimklimov jimklimov marked this pull request as ready for review August 11, 2024 18:12
@jimklimov jimklimov merged commit bdffc30 into networkupstools:master Aug 11, 2024
30 checks passed
@jimklimov jimklimov deleted the issue-2562-retry-NULL-IDs branch August 11, 2024 18:12
@masterwishx
Copy link
Contributor

Thanks, those we have (in drivers/libhid.c) and apparently fail to fetch for some reason :\

It does not seem that this PR would hurt, and the #2562 it includes does help with at least some aspects, so would merge.

I do hope that Eaton experts would chime in after the vacation era... :)

Yes, Sorry for my dumbing I saw libhid.c after I wrote. Also from from debug upshid in log I saw a lot of values my ups has also for eco mode etc...
Also I tryed again usb3.0 but seems same result, saved the log in case.

I also hope Eaton experts will help after vocation as @arnaudquette-eaton was already involved a little :)

Also Thanks for your help in this case and your amazing work for this project and pr for 9E.

battery.voltage and battery.voltage.nominal
Will be cool to see in next release, I hope battery.voltage is shows real live value of battery voltage as it's very important.

@masterwishx
Copy link
Contributor

@jimklimov as I opened issue in libusb, they refer to hidapi instead libusb. Not sure what used here...
libusb/libusb#1548 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement impacts-release-2.8.2 Issues reported against NUT release 2.8.2 (maybe vanilla or with minor packaging tweaks) Incorrect or missing readings On some devices driver-reported values are systemically off (e.g. x10, x0.1, const+Value, etc.) portability We want NUT to build and run everywhere possible USB
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants