Skip to content

riello_usb.c: option for driver to calculate values of battery.runtime and battery.charge "locally" - #1692

Merged
jimklimov merged 34 commits into
networkupstools:masterfrom
amikot:patch-1
Mar 31, 2024
Merged

jimklimov merged 34 commits into
networkupstools:masterfrom
amikot:patch-1

Conversation

@amikot

@amikot amikot commented Oct 30, 2022 •

Copy link
Copy Markdown
Contributor

MAINTAINER NOTE: Planning to merge this fix as part of upcoming NUT v2.8.1 but probably will refactor later the configuration options involved -- and possibly this would only land in a subsequent release, see #1842. For now the newly introduced localcalculation option is documented as "may get deprecated soon" in favor of runtimecal as in other drivers.

Closes: #1685

This PR introduces actually two features: the local calculation of the runtime/charge data, and constraints on valid runtime/charge/temperature values. Unlike the original description and implementation, invalid data points would not cause a zero reading.


According to issue #1685 :

Added driver setting flag localcalculation. When enabled, driver will calculate values of battery.runtime and battery.charge locally. This is for some Riello models (iPlug and iDialog series) that provides incorrect values. Local calculation is done according to nominal battery capacity, nominal battery voltage, actual battery charge, maximum and actual UPS load.
Also used lead battery charge graphs as guidance to estimate current battery charge. Graph is not linear, so obtained charge value may not be perfectly accurate.
However value should be good enough to determine battery actual status and estimate rough time it can power the system.

Added condition to filter off situation when battery temperature variable is incorrectly set to variable type maximum (255) - which is typical issue of some Riello models (iPlug and iDialog series). If incorrect value is detected temperature is set to 0.

UPDATE: initially claimed calculation of battery.load, but code sets battery.charge in fact.

amikot and others added 3 commits October 30, 2022 21:00
Added driver setting flag `localcalculation`.  When enabled, driver will calculate values of battery.runtime and battery.load locally. This is for some Riello models (iPlug and iDialog series) that provides incorrect values. Local calculation is done according to nominal battery capacity, nominal battery voltage, actual battery charge, maximum and actual UPS load. 
Added condition to filter off situation when battery temperature variable is incorrectly set to variable type maximum (255) - which is typical issue of some Riello models (iPlug and iDialog series). If incorrect value is detected temperature is set to 0.
Added localcalculation flag description
@jimklimov

Copy link
Copy Markdown
Member

Looks great for a PR, more so if it is nearly your first as claimed ;) I just updated the docs impacted for feature updates.

Thinking about the flag name (if other drivers have something similar enough to name it identically) and purpose, I remembered runtimecal in nutdrv_qx driver which tries to estimate the remaining runtime more diligently (non-linearly) using two data points provided by user as measured for their UPS and various percentage loads.

@jimklimov jimklimov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested some improvements (try them in practice first). One more sore point is whitespace style (got guidelines in docs, did not get to automate them yet) - notably TABs for indentation.

Before further changes, if any, please don't forget to git pull the changes I made for the docs into your workspace, so commit history remains compatible.

Comment thread drivers/riello_usb.c Resolved
Comment thread drivers/riello_usb.c Resolved
Comment thread drivers/riello_usb.c Resolved
@jimklimov jimklimov added USB Riello Riello UPS devices (serial, usb), usually with a variant of Qx protocol labels Oct 31, 2022
@amikot

amikot commented Oct 31, 2022

Copy link
Copy Markdown
Contributor Author

Looks great for a PR, more so if it is nearly your first as claimed ;) I just updated the docs impacted for feature updates.

Thinking about the flag name (if other drivers have something similar enough to name it identically) and purpose, I remembered runtimecal in nutdrv_qx driver which tries to estimate the remaining runtime more diligently (non-linearly) using two data points provided by user as measured for their UPS and various percentage loads.

Run time in this patch depends on various percentage loads as well. It also depends on battery percentage factor and that is calculated linearly.
All factors used for runtime calculation are:

  1. nominal battery capacity (Ah) (provided by UPS protocol)
  2. battery nominal voltage (V) (provided by UPS protocol)
  3. nominal power output (W) (provided by UPS protocol)
  4. actual power output percentage (provided by UPS protocol)
  5. actual charge percentage (calculated using linear scheme )

Actual Charge Percentage is simple if we use linear scheme - like here: 10.7 - fully discharged, 12.9 - fully charged assuming that 50% is in the middle. In fact 50% is not at 11.8. but rather around 12.1. So linear scheme will show 50% while in fact it's already 40%. Battery age reduce that problem because it speed up voltage loss at higher voltages. Situation looks similar to the cars where fuel tank 50% on dashboard not always represent 50% of real tank. But indeed fill is full and empty i empty :D

@amikot

amikot commented Oct 31, 2022 •

Copy link
Copy Markdown
Contributor Author

Suggested some improvements (try them in practice first). One more sore point is whitespace style (got guidelines in docs, did not get to automate them yet) - notably TABs for indentation.

This is because I've copied the code from editor in terminal to the github on website. All tabs has been translated to spaces :(
I would prefer to have all synced automatically on server, but have no experience and knowledge how to do that.

Before further changes, if any, please don't forget to git pull the changes I made for the docs into your workspace, so commit history remains compatible.

Heh ... most confusing are git related tasks.
how to do git pull? If I try to sync it says that my branch is not behind the master.

@jimklimov

Copy link
Copy Markdown
Member

Heh ... most confusing are git related tasks.
how to do git pull? If I try to sync it says that my branch is not behind the master.

From patch-1 branch name it seems that you created the PR by suggesting an edit of the source file via GitHub web UI. That is one way to do it, but more sustainable is to use git locally (on your PC with the build workspace), and resync that one.

If you don't yet have that workspace, you can instantiate it from your github fork and branch (by default will make a new nut subdir in current path and clone the repo there), and copy in your changes from development machine:

git clone -b patch-1 https://github.com/amikot/nut

If you had cloned NUT master earlier, you can add your fork as another "remote" repo and check out the branch:

# cd nut
git remote add amikot https://github.com/amikot/nut

### if you have local edits, stash them:
git stash

git fetch --all
git checkout patch-1

### if you had local edits, unstash them to apply over the checkout:
### (if merge-conflicts arose, they would be marked with common diff
### angle-brackets in the source files reported by git)
git stash pop

Then as you edit stuff, and are satisfied with results, commit them and update the source branch on github that the PR is spawned from, so new iteration would be tested by CI:

git add -p
git commit -m 'Descriptive message'
### perhaps rinse and repeat for different logical changes

git push amikot

@jimklimov

Copy link
Copy Markdown
Member

Later on you can just git pull --all ("pull" is "fetch+merge for the current tracked branch") in the workspace, to get whatever is known new in remote repositories configured for the workspace (your fork, possibly main NUT repo).

For the purposes of this PR, this would update your workspace with any edits I might have made like for the docs yesterday.

Generally, over time it might help sync (merge) the upstream master branch into your locally customized branch at your discretion e.g. as you experiment with stuff you are not yet ready to PR publicly.

@jimklimov

Copy link
Copy Markdown
Member

FWIW, there are many Git tutorials out there. I liked https://www.atlassian.com/git/tutorials ages ago. Also google up some "git games" trainings, there should be a lot on github or other sites that walk you from level to level by completing certain git commands.

Comment thread drivers/riello_usb.c Resolved
@jimklimov

Copy link
Copy Markdown
Member

Cheers, I've updated the PR regarding my comments. Can you please fetch a fresh copy of your "patch-1" branch to build and test that the driver still works "sanely" (and e.g. does not spam logs about need for the flag when it is not set)?

jimklimov and others added 3 commits November 3, 2022 18:35
Use "guesstimate" as common NUT term for future searches
Log that guesstimation will be used instead of device readings (if any)
@amikot

amikot commented Nov 4, 2022

Copy link
Copy Markdown
Contributor Author

I must confess I'm not sure if I know what's happening here.

@amikot

amikot commented Nov 4, 2022 •

Copy link
Copy Markdown
Contributor Author

Wait a minute - I've cloned git on my PC with added my fork repository as you guided me in one of last comments.
Okay - but that PC has no my credentials to my git account nor any token, so how I can commit anything from that PC?

I've done as you said and there is some conflicts detected in riello_ups.c and they are commented with angle brackets.
but when I go to the web I see your changes without brackets and I would be okay to just sync that down to my PC to check if that works.
I understand your changes on the web, but these brackets are confusing me - there is decision to be made and don't know why and what it should be.
Did you apply this changes to my fork or into the main or what? I'm not sure what's going on :(

@jimklimov

jimklimov commented Nov 4, 2022 •

Copy link
Copy Markdown
Member

As a maintainer I can and did apply some fixes to your branch in your fork on github.

The angle brackets appear during git merge activity (e.g. part of git pull) and show places where we both edited same lines, so they present two versions of the change and you have to pick one or mix them as you deem appropriate by situation.

To test the currently published version with my changes, you can git clone from github into a separate directory, without compromising your local edits.

To git push your patch-1 branch changes back to github (and so update the PR) you have to first go to your github user profile to either add your SSH public key, or to generate a token for some permission set (e.g. r/w access to your repositories) and use it as a password for HTTPS pushes, along with your username. The URL type in git remote -v (https://... or git@...) would hint you which to use; you can also change that via git remote ... set-url ... or add another URL to same repo.

@amikot

amikot commented Nov 12, 2022 •

Copy link
Copy Markdown
Contributor Author

The changes as you have done are good - all works perfect.
Problem is that github is too complex. I have no time to study whole manual and I don't know how to push the results of my and your work into master branch ... I mean networkupstools/nut

…on" related support [networkupstools#1692]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…tery.voltage.low/.high for localcalculation guesstimates [networkupstools#1692]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov

Copy link
Copy Markdown
Member

Thanks @grifferz for the comments - I was on the verge of merging this PR "as is" to let it benefit at least some population of NUT users, but having seen your review - I've updated this PR with a shot at letting the battery voltage low/high range for these calculations be configurable.

Maybe the defaults for a range (10.7-12.9V or twice as much) could be also guesstimated from reported battery voltage seen when the driver starts (or configured in one battery.voltage.nominal setting with a value to be in the middle of one or other range)...

If you have a chance to test whether this branch now serves your HW well with currently the two added settings in your ups.conf (e.g. default.battery.voltage.high=27 and default.battery.voltage.low=20.8) - that would be great.

…range via known or configured battery.voltage.nominal [networkupstools#1692]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…to match nutdrv_qx data for PbAc batteries [networkupstools#1692]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov

jimklimov commented Mar 24, 2024 •

Copy link
Copy Markdown
Member

@grifferz : updated with a few ways to honour the battery.voltage.nominal as it seems to be actually reported by your device at least (and as it can be usefully a single setting via ups.conf).

There is decent chance it would now work out of the box (with just the localcalculation setting, but not the voltages - for devices which report their nominal values) :)

@jimklimov

jimklimov commented Mar 24, 2024 •

Copy link
Copy Markdown
Member

CI hiccups unrelated to this change set:

  • slowbuild-run/MATRIX_TAG=gnu99-gnu++98-freebsd12 (something still uneasy about docs src prep)

@jimklimov jimklimov added the ready / gonna merge The PR is in final cycles leading to merge unless someone logs an objection before we hit the button label Mar 25, 2024
@jimklimov

Copy link
Copy Markdown
Member

Cheers all, any chance for practical testing with recent changes, to merge the PR this weekend? <3 :)

@grifferz

Copy link
Copy Markdown

Cheers all, any chance for practical testing with recent changes, to merge the PR this weekend? <3 :)

Working on it…

@grifferz

Copy link
Copy Markdown

Cheers all, any chance for practical testing with recent changes, to merge the PR this weekend? <3 :)

@jimklimov Okay, so if I just run this with

localcalulation = yes

and nothing else special, I get this from upsc:

battery.capacity: 9
battery.charge: 100
battery.runtime: 864
battery.voltage: 27.4
battery.voltage.high: 26.0
battery.voltage.low: 20.8
battery.voltage.nominal: 24

However, if I try to add my own lower bound for voltage as discovered by running my unit to exhaustion, 22.9:

[riello]
    driver                      = riello_usb
    port                        = auto
    localcalculation            = yes
    default.battery.voltage.low = 22.9
    desc                        = "Riello Netpower 1500"

I get this:

battery.capacity: 9
battery.charge: 100
battery.runtime: 864
battery.voltage: 27.4
battery.voltage.high: 13.0
battery.voltage.low: 10.4
battery.voltage.nominal: 24

Am I doing something wrong with my configuration?

As it stands then, I cannot use this (without a more generous margin) because the battery.voltage.low is actually below where my device would be exhausted no matter what I set.

@jimklimov

Copy link
Copy Markdown
Member

I guess it might be a bit of an unsupported blind spot to only set one of the values in configuration. Still, it was not too expected that the values would revert to a multiplier of 1 (factors of 12V nominal base) given the other numbers like nominal "24" from HW are over 20 :\

For a quick test, would it fare better if you set "default.battery.voltage.high" in ups.conf also?

@grifferz

Copy link
Copy Markdown

Adding the "high" setyting doesn't seem to make any difference unfortunately:

[riello]                               
    driver                       = riello_usb
    port                         = auto
    localcalculation             = yes 
    default.battery.voltage.low  = 22.9
    default.battery.voltage.high = 24.0
    desc                         = "Riello Netpower 1500"
battery.capacity: 9
battery.charge: 100
battery.runtime: 864
battery.voltage: 27.4
battery.voltage.high: 13.0
battery.voltage.low: 10.4
battery.voltage.nominal: 24
…

@jimklimov

jimklimov commented Mar 30, 2024 •

Copy link
Copy Markdown
Member

Thanks, trying to mock it up now.

Some debug can help make sense of codepath walked, e.g.:

   0.001007     [D5] send_to_all: SETINFO battery.voltage.nominal "24"
   0.001033     [D5] send_to_all: SETINFO battery.capacity "0"
   0.001063     [D1] WARNING: Only one of battery.voltage.low=10.4 or battery.voltage.high=13.0 is set via driver configuration; keeping the other at built-in default value (and not aligning with battery.voltage.nominal=24.0)                                                          0.001080     [D5] send_to_all: SETINFO battery.voltage.low "10.4"                                               0.001148     [D5] send_to_all: SETINFO battery.voltage.high "13.0"

@grifferz

Copy link
Copy Markdown

Okay here we go.

(An APC is also attached and configured so ignore its mention of that)

$ sudo /lib/nut/riello_usb -a riello -DDDDD -d 1                    
   0.000000     [D5] send_to_all: SETINFO driver.state "init.starting"           
Network UPS Tools - Riello USB driver 0.12 (2.8.0-3822-g9bb7a0c6c)       
Warning: This is an experimental driver.                                    
Some features may not function correctly.                                                 
                                                                                                                                        
   0.000153     [D5] send_to_all: SETINFO driver.version.usb "libusb-1.0.22 (API: 0x1000106)"                                            
   0.000166     [D1] Using USB implementation: libusb-1.0.22 (API: 0x1000106)                                                            
   0.000364     [D5] do_upsconf_args: confupsname=(null), var=maxretry, val=3                                                            
   0.000375     [D5] do_upsconf_args: call do_global_args()                                                                              
   0.000383     [D3] do_global_args: var='maxretry' val='3'                                                                              
   0.000396     [D5] do_upsconf_args: confupsname=riello, var=driver, val=riello_usb
   0.000410     [D5] do_upsconf_args: call main_arg()   
   0.000419     [D3] main_arg: var='driver' val='riello_usb'
   0.000428     [D5] do_upsconf_args: not a main_arg()                
   0.000436     [D5] do_upsconf_args: this is a 'driver' setting, may we proceed?
   0.000444     [D5] do_upsconf_args: 'driver' setting already applied with this value             
   0.000455     [D5] do_upsconf_args: confupsname=riello, var=port, val=auto
   0.000463     [D5] do_upsconf_args: call main_arg()                                 
   0.000470     [D3] main_arg: var='port' val='auto'                                                      
   0.000488     [D5] send_to_all: SETINFO driver.parameter.port "auto"
   0.000501     [D5] do_upsconf_args: confupsname=riello, var=localcalculation, val=yes                   
   0.000510     [D5] do_upsconf_args: call main_arg()                                                                                   
   0.000517     [D3] main_arg: var='localcalculation' val='yes'                                           
   0.000525     [D5] do_upsconf_args: not a main_arg()              
   0.000532     [D5] do_upsconf_args: process as value               
   0.000548     [D5] send_to_all: SETINFO driver.parameter.localcalculation "yes"                                                        
   0.000562     [D5] do_upsconf_args: confupsname=riello, var=default.battery.voltage.low, val=22.9
   0.000570     [D5] do_upsconf_args: call main_arg()        
   0.000578     [D3] main_arg: var='default.battery.voltage.low' val='22.9'
   0.000586     [D5] do_upsconf_args: not a main_arg()                                                                         [363/5453]
   0.000593     [D5] do_upsconf_args: process as value
   0.000604     [D5] send_to_all: SETINFO battery.voltage.low "22.9"
   0.000616     [D5] send_to_all: SETINFO driver.parameter.default.battery.voltage.low "22.9"
   0.000628     [D5] do_upsconf_args: confupsname=riello, var=default.battery.voltage.high, val=24.0
   0.000636     [D5] do_upsconf_args: call main_arg()
   0.000644     [D3] main_arg: var='default.battery.voltage.high' val='24.0'
   0.000652     [D5] do_upsconf_args: not a main_arg()
   0.000659     [D5] do_upsconf_args: process as value
   0.000670     [D5] send_to_all: SETINFO battery.voltage.high "24.0"
   0.000682     [D5] send_to_all: SETINFO driver.parameter.default.battery.voltage.high "24.0"
   0.000694     [D5] do_upsconf_args: confupsname=riello, var=desc, val=Riello Netpower 1500
   0.000702     [D5] do_upsconf_args: call main_arg()
   0.000710     [D3] main_arg: var='desc' val='Riello Netpower 1500'
   0.000721     [D5] do_upsconf_args: confupsname=apc, var=driver, val=usbhid-ups
   0.000731     [D5] do_upsconf_args: confupsname=apc, var=port, val=auto
   0.000741     [D5] do_upsconf_args: confupsname=apc, var=pollonly, val=yes
   0.000753     [D5] do_upsconf_args: confupsname=apc, var=desc, val=APC Back-UPS BX1600MI
   0.000777     [D1] Network UPS Tools version 2.8.0-3822-g9bb7a0c6c (release/snapshot of 2.8.1.1) built with gcc (Debian 8.3.0-6) 8.3.0
and configured with flags: --prefix=/usr --includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc/nu
t --localstatedir=/var --libexecdir=/usr/lib/nut --srcdir=. --enable-maintainer-mode --disable-silent-rules --libdir=/usr/lib/x86_64-linu
x-gnu --with-ssl --with-nss --with-cgi --with-dev --enable-static --with-statepath=/run/nut --with-altpidpath=/run/nut --with-drvpath=/li
b/nut --with-cgipath=/usr/lib/cgi-bin/nut --with-htmlpath=/usr/share/nut/www --with-pidpath=/run/nut --datadir=/usr/share/nut --with-pkgc
onfig-dir=/usr/lib/x86_64-linux-gnu/pkgconfig --with-user=nut --with-group=nut --with-udev-dir=/lib/udev --with-systemdsystemunitdir=/lib
/systemd/system
   0.000804     [D1] debug level is '5'
   0.000816     [D5] send_to_all: SETINFO driver.debug "5"
   0.000827     [D5] send_to_all: SETFLAGS driver.debug RW NUMBER
   0.004312     [D1] Succeeded to become_user(nut): now UID=128 GID=108
   0.004362     [D5] send_to_all: SETINFO device.type "ups"
   0.004375     [D5] send_to_all: SETINFO driver.state "init.device"
   0.012186     [D2] Checking device 1 of 9 (1D6B/0002)
   0.012257     [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions)
   0.012278     [D2] Checking device 2 of 9 (1D6B/0001)
   0.012296     [D1] Failed to open device (1D6B/0001), skipping: Access denied (insufficient permissions)
   0.012305     [D2] Checking device 3 of 9 (1D6B/0002)
   0.012321     [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions)
   0.012329     [D2] Checking device 4 of 9 (051D/0002)
   0.027309     [D2] - VendorID: 051d
   0.027418     [D2] - ProductID: 0002
   0.027464     [D2] - Manufacturer: American Power Conversion
   0.027507     [D2] - Product: Back-UPS BX1600MI
   0.027549     [D2] - Serial Number: 9B2339A15993
   0.027589     [D2] - Bus: 005
   0.027628     [D2] - Bus Port: 001
   0.027716     [D2] - Device: 002                                  
   0.027759     [D2] - Device release number: 0001                                           
   0.027802     [D2] Trying to match device                                                         
   0.027843     [D3] match_function_regex: matching a device...
   0.027886     [D2] Device does not match - skipping                       
   0.027968     [D2] Checking device 5 of 9 (1D6B/0001)
   0.028061     [D1] Failed to open device (1D6B/0001), skipping: Access denied (insufficient permissions)
   0.028108     [D2] Checking device 6 of 9 (0BDA/2838)              
   0.028186     [D1] Failed to open device (0BDA/2838), skipping: Access denied (insufficient permissions)
   0.028232     [D2] Checking device 7 of 9 (1D6B/0002)                                     
   0.028313     [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions)
   0.028361     [D2] Checking device 8 of 9 (04B4/5500)             
   0.037982     [D2] - VendorID: 04b4                                            
   0.038044     [D2] - ProductID: 5500                                   
   0.038055     [D2] - Manufacturer: Cypress Semiconductor                  
   0.038066     [D2] - Product: USB to Serial                                             
   0.038075     [D2] - Serial Number: unknown                                                                                           
   0.038085     [D2] - Bus: 004                                                                                                          
   0.038095     [D2] - Bus Port: 005                                                                                                     
   0.038104     [D2] - Device: 007                                                                                                       
   0.038116     [D2] - Device release number: 0001                                                                                       
   0.038126     [D2] Trying to match device                                                                                              
   0.038137     [D3] match_function_regex: matching a device...
   0.038151     [D2] Device matches    
   0.038161     [D2] Reading configuration descriptor 1 of 1
   0.038205     [D3] libusb_kernel_driver_active() returned 0: Success
   0.038262     [D2] Claimed interface 0 successfully                  
   0.038280     [D3] nut_usb_set_altinterface: skipped libusb_set_interface_alt_setting(udev, 0, 0)
   0.039984     [D2] Retrieved HID descriptor (expected 9, got 9)   
   0.040047     [D3] HID descriptor, method 1: (9 bytes) => 09 21 11 01 00 01 22 25 00
   0.040060     [D3] HID descriptor length (method 1) 37                                                  
   0.040072     [D4] i=0, extra[i]=09, extra[i+1]=21   
   0.040089     [D3] HID descriptor, method 2: (9 bytes) => 09 21 11 01 00 01 22 25 00                    
   0.040114     [D3] HID descriptor length (method 2) 37
   0.040125     [D2] HID descriptor length 37                                                             
   0.042983     [D2] Report descriptor retrieved (Reportlen = 37)
   0.043034     [D2] Found HID device
   0.043051     [D3] Using default, detected or customized USB HID numbers: usb_config_index=0 usb_hid_rep_index=0 usb_hid_desc_index=0 u
sb_hid_ep_in=1 usb_hid_ep_out=1                               
   0.043108     [D5] send_to_all: SETINFO ups.vendorid "04b4"
   0.043128     [D5] send_to_all: SETINFO ups.productid "5500"
   0.043143     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.043163     [D5] send_to_all: SETINFO driver.version "2.8.0-3822-g9bb7a0c6c"
   0.043178     [D5] send_to_all: SETINFO driver.version.internal "0.12"
   0.043197     [D5] send_to_all: SETINFO driver.name "riello_usb"                           
   0.043211     [D5] send_to_all: SETINFO driver.state "init.info"                                  
   0.043221     [D2] entering start_ups_comm()                 
                                                                            
   0.044945     [D3] send: features report ok          
   0.457201     [D3] send ok                                                                              
   0.473015     [D3] read: FFFFFFF7 02 22 20 47 49 33 38             
   0.473082     [D5] Header detected: LAST_DATA:0,0,0,0,2,22  buf_ptr:0                                   
                                                                                            
   0.489002     [D3] read: FFFFFFF7 20 20 20 20 20 20 20                                                  
   0.504981     [D3] read: FFFFFFF7 20 20 20 20 20 20 20            
   0.520998     [D3] read: FFFFFFF4 20 20 55 53 00 00 00                         
   0.536994     [D3] read: FFFFFFF2 43 36 00 00 00 00 00                 
   0.553002     [D3] read: FFFFFFF2 20 20 00 00 00 00 00                    
   0.569003     [D3] read: FFFFFFF2 20 20 00 00 00 00 00                                  
   0.584995     [D3] read: FFFFFFF2 20 20 00 00 00 00 00                                                                                
   0.601000     [D3] read: FFFFFFF2 20 20 00 00 00 00 00                                                                                 
   0.617066     [D3] read: FFFFFFF2 20 20 00 00 00 00 00                                                                                 
   0.632992     [D3] read: FFFFFFF2 20 20 00 00 00 00 00                                                                                 
   0.648994     [D3] read: FFFFFFF2 53 57 00 00 00 00 00                                                                                 
   0.664997     [D3] read: FFFFFFF2 4D 30 00 00 00 00 00                                                                                 
   0.681016     [D3] read: FFFFFFF2 34 38 00 00 00 00 00       
   0.696991     [D3] read: FFFFFFF1 2D 00 00 00 00 00 00
   0.712853     [D3] read: FFFFFFF2 30 31 00 00 00 00 00    
   0.728959     [D3] read: FFFFFFF2 2D 30 00 00 00 00 00              
   0.744990     [D3] read: FFFFFFF2 35 31 00 00 00 00 00               
   0.760994     [D3] read: FFFFFFF2 31 31 00 00 00 00 00                                           
   0.776993     [D3] read: FFFFFFF2 31 30 00 00 00 00 00            
   0.792985     [D3] read: FFFFFFF2 30 31 00 00 00 00 00                              
   0.808992     [D3] read: FFFFFFF2 32 30 00 00 00 00 00                                                  
   0.824988     [D3] read: FFFFFFF2 30 30 00 00 00 00 00
   0.840988     [D3] read: FFFFFFF2 30 30 00 00 00 00 00                                                  
   0.856993     [D3] read: FFFFFFF2 3A 3D 00 00 00 00 00
   0.872976     [D3] read: FFFFFFF2 38 03 00 00 00 00 00                                                  
   0.873039     [D5]                                             
End detected: LAST_DATA:30,30,3A,3D,38,3  buf_ptr:68
                                                                                                                                         
   0.883288     [D3] in read: 68                              
   0.883343     [D3] riello_command ok: 68                   
   0.883355     [D3] Get identif Ok: read byte: 68            
   0.883365     [D2] Communication with UPS established            
   0.883397     [D1] Will guesstimate battery charge and runtime instead of trusting device readings (if any); consider also setting default.battery.voltage.low and default.battery.voltage.high for this device
   0.883511     [D5] send_to_all: SETINFO driver.parameter.localcalculation "1"              
   0.883570     [D5] send_to_all: SETINFO device.mfr "RPS S.p.a."                                   
   0.883620     [D5] send_to_all: SETINFO device.model "USC6           "
   0.883696     [D5] send_to_all: SETINFO device.serial "                "  
   0.883770     [D5] send_to_all: SETINFO ups.mfr "RPS S.p.a."
   0.883818     [D5] send_to_all: SETINFO ups.model "USC6           "                                     
   0.883865     [D5] send_to_all: SETINFO ups.serial "                "
   0.883914     [D5] send_to_all: SETINFO ups.firmware "SWM048-01-05"                                     
   1.297089     [D3] send ok                                                                
   1.304968     [D3] read: FFFFFFF0 00 00 00 00 00 00 00                                                  
   1.320966     [D3] read: FFFFFFF7 02 22 20 47 4E 31 36            
   1.321030     [D5] Header detected: LAST_DATA:0,0,0,0,2,22  buf_ptr:0          
                                                                         
   1.336961     [D3] read: FFFFFFF7 30 30 35 3D 3C 30 30                    
   1.352955     [D3] read: FFFFFFF7 33 38 34 30 31 38 30                                  
   1.368967     [D3] read: FFFFFFF5 30 39 30 3E 36 00 00                                                                                
   1.384954     [D3] read: FFFFFFF2 31 3F 00 00 00 00 00                                                                                 
   1.400914     [D3] read: FFFFFFF2 34 30 00 00 00 00 00                                                                                 
   1.416952     [D3] read: FFFFFFF2 35 3C 00 00 00 00 00                                                                                 
   1.432951     [D3] read: FFFFFFF2 35 03 00 00 00 00 00                                                                                 
   1.433014     [D5]                                                                                                                     
End detected: LAST_DATA:34,30,35,3C,35,3  buf_ptr:34           
                                                        
   1.443183     [D3] in read: 34                            
   1.443248     [D3] riello_command ok: 34                            
   1.443259     [D3] Get nominal Ok: read byte: 34                     
   1.443287     [D5] send_to_all: SETINFO ups.realpower.nominal "900"                              
   1.443303     [D5] send_to_all: SETINFO ups.power.nominal "1500"  
   1.443319     [D5] send_to_all: SETINFO output.voltage.nominal "230"                
   1.443339     [D5] send_to_all: SETINFO output.frequency.nominal "50.0"                                 
   1.443357     [D5] send_to_all: SETINFO battery.voltage.nominal "24"
   1.443373     [D5] send_to_all: SETINFO battery.capacity "9"                                            
   1.443394     [D1] WARNING: Only one of battery.voltage.low=10.4 or battery.voltage.high=13.0 is set via driver configuration; keeping
the other at built-in default value (and not aligning with battery.voltage.nominal=24.0)                  
   1.443414     [D5] send_to_all: SETINFO battery.voltage.low "10.4"
   1.443429     [D5] send_to_all: SETINFO battery.voltage.high "13.0"
   1.443442     [D5] send_to_all: ADDCMD load.off                                                                                        
   1.443455     [D5] send_to_all: ADDCMD load.on              
   1.443467     [D5] send_to_all: ADDCMD load.off.delay      
   1.443479     [D5] send_to_all: ADDCMD load.on.delay        
   1.443492     [D5] send_to_all: ADDCMD shutdown.return           
   1.443517     [D5] send_to_all: ADDCMD test.battery.start             
   1.443529     [D5] send_to_all: ADDCMD test.panel.start                                    
   1.443545     [D5] send_to_all: SETINFO ups.delay.shutdown "5"                                    
   1.443559     [D5] send_to_all: SETFLAGS ups.delay.shutdown RW STRING 
   1.443573     [D5] send_to_all: SETAUX ups.delay.shutdown 3               
   1.443588     [D5] send_to_all: SETINFO ups.delay.reboot "5"
   1.443601     [D5] send_to_all: SETFLAGS ups.delay.reboot RW STRING                                     
   1.443614     [D5] send_to_all: SETAUX ups.delay.reboot 3            
   1.443630     [D5] send_to_all: SETINFO driver.state "init.updateinfo"                                  
   1.443641     [D1] countlost 0                                                            
   1.857135     [D3] send ok                                                                              
   1.864937     [D3] read: FFFFFFF0 00 00 00 00 00 00 00            
   1.880940     [D3] read: FFFFFFF7 02 22 20 52 53 32 34                         
   1.881006     [D5] Header detected: LAST_DATA:0,0,0,0,2,22  buf_ptr:0  
                                                                            
   1.896937     [D3] read: FFFFFFF7 38 30 32 31 30 31 3F                                  
   1.912928     [D3] read: FFFFFFF7 35 30 3E 3F 31 3F 35                                                                                
   1.928930     [D3] read: FFFFFFF5 30 3E 3F 30 30 00 00                                                                                 
   1.944947     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                                                 
   1.960944     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                                                 
   1.976942     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                                                 
   1.992933     [D3] read: FFFFFFF2 30 31 00 00 00 00 00                                                                                 
   2.008961     [D3] read: FFFFFFF2 31 32 00 00 00 00 00       
   2.024879     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00
   2.040935     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00    
   2.056927     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00              
   2.072933     [D3] read: FFFFFFF2 3F 30 00 00 00 00 00               
   2.088924     [D3] read: FFFFFFF1 39 00 00 00 00 00 00                                           
   2.104927     [D3] read: FFFFFFF2 34 33 00 00 00 00 00            
   2.120961     [D3] read: FFFFFFF1 03 00 00 00 00 00 00                              
   2.121018     [D5]                                                                                      
End detected: LAST_DATA:3F,30,39,34,33,3  buf_ptr:48                  
                                                                                                          
   2.131263     [D3] in read: 48                                                                                                        
   2.131327     [D3] riello_command ok: 48                                                                
   2.131339     [D3] Get status Ok: read byte: 48                   
   2.131352     [D1] get_ups_status() 0                              
   2.545104     [D3] send ok                                                                                                             
   2.552903     [D3] read: FFFFFFF0 00 00 00 00 00 00 00      
   2.568914     [D3] read: FFFFFFF7 02 22 20 15 32 30 30     
   2.568974     [D5] Header detected: LAST_DATA:0,0,0,0,2,22  buf_ptr:0
                                                                   
   2.584930     [D3] read: FFFFFFF5 30 30 3E 39 03 00 00                                                                                 
   2.584986     [D5]                                                    
End detected: LAST_DATA:30,30,30,3E,39,3  buf_ptr:12                                         
                                                                                                    
   2.595225     [D3] in read: 12                                        
   2.595286     [D3] riello_command ok: 12                                  
   2.595298     [D3] Get extended Ko: command not supported   
   2.595331     [D5] send_to_all: SETINFO input.frequency "50.10"                                         
   2.595390     [D5] send_to_all: SETINFO input.bypass.frequency "409.50"
   2.595410     [D5] send_to_all: SETINFO output.frequency "50.10"                                        
   2.595429     [D5] send_to_all: SETINFO battery.voltage "27.4"                            
   2.595443                                                                                               
Using battery.voltage.low=10.4 and battery.voltage.high=13.0 for "localcalculation" guesstimates of battery.charge and battery.runtime
   2.595463     [D5] send_to_all: SETINFO battery.charge "100"                   
   2.595481     [D5] send_to_all: SETINFO battery.runtime "864"          
   2.595492     [D4] Reported temperature value is 0xFF, probably meaning "-1" for error or missing sensor - ignored
   2.595508     [D5] send_to_all: SETINFO input.voltage "239"                             
   2.595524     [D5] send_to_all: SETINFO input.bypass.voltage "4095"                                                                   
   2.595538     [D5] send_to_all: SETINFO output.voltage "239"                                                                           
   2.595554     [D5] send_to_all: SETINFO output.power.percent "0"                                                                       
   2.595569     [D5] send_to_all: SETINFO ups.load "0"                                                                                   
   2.595589     [D5] send_to_all: SETINFO ups.status "OL"                                                                                
   2.595601     [D5] send_to_all: DATAOK                                                                                                 
   2.595615     [D5] send_to_all: SETINFO output.L1.power "0"  
   2.595629     [D5] send_to_all: SETINFO output.L2.power "0"
   2.595644     [D5] send_to_all: SETINFO output.L3.power "0"
   2.595659     [D5] send_to_all: SETINFO output.L1.realpower "0"     
   2.595708     [D5] send_to_all: SETINFO output.L2.realpower "0"      
   2.595733     [D5] send_to_all: SETINFO output.L3.realpower "0"                                  
   2.595754     [D5] send_to_all: SETINFO output.L1.current "0"     
   2.595772     [D5] send_to_all: SETINFO output.L2.current "0"                       
   2.595795     [D5] send_to_all: SETINFO output.L3.current "0"                                           
   2.595810     [D5] send_to_all: SETINFO driver.state "init.quiet"   
   2.595827     [D5] send_to_all: SETINFO driver.parameter.pollinterval "2"                               
   2.595842     [D5] send_to_all: SETINFO driver.parameter.synchronous "auto"                                                           
   2.595863     Running as foreground process, not saving a PID file                                      
   2.595878     [D5] send_to_all: SETINFO driver.flag.allow_killpower "0"
   2.595893     [D5] send_to_all: SETFLAGS driver.flag.allow_killpower RW NUMBER
   2.595906     [D5] send_to_all: ADDCMD driver.killpower                                                                                
   2.595919     [D5] send_to_all: ADDCMD driver.reload        
   2.595931     [D5] send_to_all: ADDCMD driver.reload-or-exit
   2.595944     [D5] send_to_all: ADDCMD driver.reload-or-error        
   2.595957     [D5] send_to_all: SETINFO driver.state "quiet"     
   2.595968     [D1] Driver initialization completed, beginning data dump (1 loops)                                                      
   2.595982     [D5] send_to_all: SETINFO driver.state "updateinfo"     
   2.595993     [D1] countlost 0                                                             
   3.008973     [D3] send ok                                                                        
   3.016891     [D3] read: FFFFFFF0 00 00 00 00 00 00 00                
   3.032884     [D3] read: FFFFFFF7 02 22 20 52 53 32 34                    
   3.032942     [D5] Header detected: LAST_DATA:0,0,0,0,2,22  buf_ptr:0
                                                                                                          
   3.048876     [D3] read: FFFFFFF7 38 30 32 31 30 31 3F                 
   3.064856     [D3] read: FFFFFFF7 35 30 3E 3F 31 3F 35                                                  
   3.080885     [D3] read: FFFFFFF5 30 3E 3F 30 30 00 00                                    
   3.096881     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                  
   3.112884     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                                              
   3.128888     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                         
   3.144882     [D3] read: FFFFFFF2 30 31 00 00 00 00 00                 
   3.160883     [D3] read: FFFFFFF2 31 32 00 00 00 00 00                                                            
   3.176880     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                  
   3.192880     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                                                
   3.208875     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                                                 
   3.224882     [D3] read: FFFFFFF2 3F 30 00 00 00 00 00                                                                                 
   3.240878     [D3] read: FFFFFFF2 39 34 00 00 00 00 00                                                                                 
   3.256865     [D3] read: FFFFFFF1 33 00 00 00 00 00 00                                                                                 
   3.272823     [D3] read: FFFFFFF1 03 00 00 00 00 00 00                                                                                 
   3.272886     [D5]                                           
End detected: LAST_DATA:3F,30,39,34,33,3  buf_ptr:48         
                                                             
   3.283142     [D3] in read: 48                                      
   3.283199     [D3] riello_command ok: 48                             
   3.283211     [D3] Get status Ok: read byte: 48                                                  
   3.283224     [D1] get_ups_status() 0                             
   3.697040     [D3] send ok                                                          
   3.704861     [D3] read: FFFFFFF0 00 00 00 00 00 00 00                                                  
   3.720847     [D3] read: FFFFFFF7 02 22 20 15 32 30 30              
   3.720915     [D5] Header detected: LAST_DATA:0,0,0,0,2,22  buf_ptr:0                                   
                                                                                                                                        
   3.736854     [D3] read: FFFFFFF5 30 30 3E 39 03 00 00                                                  
   3.736917     [D5]                                                     
End detected: LAST_DATA:30,30,30,3E,39,3  buf_ptr:12                            
                                                                                                                                         
   3.747173     [D3] in read: 12                              
   3.747228     [D3] riello_command ok: 12                    
   3.747241     [D3] Get extended Ko: command not supported            
   3.747287     [D4] Reported temperature value is 0xFF, probably meaning "-1" for error or missing sensor - ignored
   3.747374     [D5] send_to_all: SETINFO driver.state "quiet"                                                                           
   3.747392     [D5] send_to_all: SETINFO driver.state "updateinfo"     
   3.747404     [D1] countlost 0                                                             
   4.161045     [D3] send ok                                                                        
   4.168842     [D3] read: FFFFFFF0 00 00 00 00 00 00 00                
   4.184833     [D3] read: FFFFFFF7 02 22 20 52 53 32 34                    
   4.184897     [D5] Header detected: LAST_DATA:0,0,0,0,2,22  buf_ptr:0
                                                                                                          
   4.200821     [D3] read: FFFFFFF7 38 30 32 31 30 31 3F                 
   4.216831     [D3] read: FFFFFFF7 35 30 3E 3F 31 3F 35                                                  
   4.232822     [D3] read: FFFFFFF5 30 3E 3F 30 30 00 00                                    
   4.248829     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                  
   4.264825     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                                              
   4.280831     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                         
   4.296828     [D3] read: FFFFFFF2 30 31 00 00 00 00 00                 
   4.312826     [D3] read: FFFFFFF2 31 32 00 00 00 00 00                                                            
   4.328830     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                  
   4.344826     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                                                
   4.360825     [D3] read: FFFFFFF2 3F 3F 00 00 00 00 00                                                                                 
   4.376695     [D3] read: FFFFFFF2 3F 30 00 00 00 00 00                                                                                 
   4.392750     [D3] read: FFFFFFF2 39 34 00 00 00 00 00                                                                                 
   4.408767     [D3] read: FFFFFFF1 33 00 00 00 00 00 00                                                                                 
   4.424768     [D3] read: FFFFFFF1 03 00 00 00 00 00 00                                                                                 
   4.424831     [D5]                                           
End detected: LAST_DATA:3F,30,39,34,33,3  buf_ptr:48         
                                                             
   4.435026     [D3] in read: 48                                      
   4.435081     [D3] riello_command ok: 48                             
   4.435093     [D3] Get status Ok: read byte: 48                                                  
   4.435117     [D1] get_ups_status() 0                             
   4.849008     [D3] send ok                                                          
   4.856819     [D3] read: FFFFFFF0 00 00 00 00 00 00 00                                                  
   4.872798     [D3] read: FFFFFFF7 02 22 20 15 32 30 30              
   4.872863     [D5] Header detected: LAST_DATA:0,0,0,0,2,22  buf_ptr:0                                   
                                                                                                                                        
   4.888801     [D3] read: FFFFFFF5 30 30 3E 39 03 00 00                                                  
   4.888865     [D5]                                                     
End detected: LAST_DATA:30,30,30,3E,39,3  buf_ptr:12                            
                                                                                                                                         
   4.898989     [D3] in read: 12                              
   4.899049     [D3] riello_command ok: 12                    
   4.899073     [D3] Get extended Ko: command not supported            
   4.899126     [D4] Reported temperature value is 0xFF, probably meaning "-1" for error or missing sensor - ignored
   4.899190     [D5] send_to_all: SETINFO driver.state "quiet"                                                                           
   4.899214     [D5] send_to_all: SETINFO driver.state "dumping"        
   4.899233     [D3] Entering dstate_dump                                                    
battery.capacity: 9                                                                                 
battery.charge: 100                                                     
battery.runtime: 864                                                        
battery.voltage: 27.4                                                  
battery.voltage.high: 13.0                                                                                
battery.voltage.low: 10.4                                                
battery.voltage.nominal: 24                                                                               
device.mfr: RPS S.p.a.                                                                      
device.model: USC6                                                                                        
device.serial:                                                                                                                        
device.type: ups                                                                 
driver.debug: 5                                                          
driver.flag.allow_killpower: 0                                                                                      
driver.name: riello_usb                                                                   
driver.parameter.default.battery.voltage.high: 24.0                                                                                     
driver.parameter.default.battery.voltage.low: 22.9                                                                                       
driver.parameter.localcalculation: 1                                                                                                     
driver.parameter.pollinterval: 2                                                                                                         
driver.parameter.port: auto                                                                                                              
driver.parameter.synchronous: auto                                                                                                       
driver.state: dumping                                          
driver.version: 2.8.0-3822-g9bb7a0c6c                        
driver.version.internal: 0.12                                
driver.version.usb: libusb-1.0.22 (API: 0x1000106)                    
input.bypass.frequency: 409.50                                         
input.bypass.voltage: 4095                                                                         
input.frequency: 50.10                                              
input.voltage: 239                                                                    
output.frequency: 50.10                                                                                   
output.frequency.nominal: 50.0                                        
output.L1.current: 0                                                                                      
output.L1.power: 0                                                                                                                      
output.L1.realpower: 0                                                                                    
output.L2.current: 0                                                     
output.L2.power: 0                                                              
output.L2.realpower: 0                                                                                                                   
output.L3.current: 0                                          
output.L3.power: 0                                            
output.L3.realpower: 0                                                 
output.power.percent: 0                                                                                             
output.voltage: 239                                                                                                                      
output.voltage.nominal: 230
ups.delay.reboot: 5
ups.delay.shutdown: 5
ups.firmware: SWM048-01-05
ups.load: 0
ups.mfr: RPS S.p.a.
ups.model: USC6
ups.power.nominal: 1500
ups.productid: 5500
ups.realpower.nominal: 900
ups.serial:
ups.status: OL
ups.vendorid: 04b4
   4.899829     [D5] send_to_all: SETINFO driver.state "cleanup.upsdrv"                                                                 
   4.900900     [D5] send_to_all: SETINFO driver.state "cleanup.exit"                                                                   

…rom settings or initial reading [networkupstools#1692]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…rom nominal voltage alignment, then apply from settings or initial reading [networkupstools#1692]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov

Copy link
Copy Markdown
Member

Checking another approach: to set high/low values based on nominal first, then overlay with configs if given (even if just one limit is customized), e.g.:

:; make -ks -j 8 && NUT_STATEPATH=`pwd`/tests/NIT/tmp  ./drivers/riello_usb -s ups -x port=auto -DDDDDD -x default.battery.voltage.low=22.9

...
0.001712     [D5] send_to_all: SETINFO battery.voltage.nominal "24"                                             0.001726     [D5] send_to_all: SETINFO battery.capacity "0"                                                     0.001739     [D3] upsdrv_initinfo: Using 2 times the voltage range of 12V PbAc battery                          0.001766     [D2] upsdrv_initinfo: Using battery.voltage.low=22.9 from device or settings                       0.001782     [D1] WARNING: Only one of battery.voltage.low=22.9 or battery.voltage.high=26.0 is set via driver configuration; keeping the other at built-in default value (aligned with battery.voltage.nominal=24.0)
   0.001801     [D5] send_to_all: SETINFO battery.voltage.high "26.0"

@grifferz

grifferz commented Mar 31, 2024 •

Copy link
Copy Markdown

With this pull and running like you suggested:

$ NUT_STATEPATH=`pwd`/tests/NIT/tmp  ./drivers/riello_usb -s riello -x port=auto -DDDDDD -x default.battery.voltage.low=22.9 -d 1

…

   1.439278     [D5] send_to_all: SETINFO battery.voltage.nominal "24"
   1.439324     [D5] send_to_all: SETINFO battery.capacity "9"
   1.439369     [D3] upsdrv_initinfo: Using 2 times the voltage range of 12V PbAc battery
   1.439434     [D2] upsdrv_initinfo: Using battery.voltage.low=22.9 from device or settings
   1.439733     [D1] WARNING: Only one of battery.voltage.low=22.9 or battery.voltage.high=26.0 is set via driver configuration; keeping
the other at built-in default value (aligned with battery.voltage.nominal=24.0)
   1.439761     [D5] send_to_all: SETINFO battery.voltage.high "26.0"

…

   4.895152     [D3] Entering dstate_dump                
battery.capacity: 9                                             
battery.voltage: 27.4                                                  
battery.voltage.high: 26.0                                   
battery.voltage.low: 22.9                                              
battery.voltage.nominal: 24                                          
device.mfr: RPS S.p.a.                                                   
device.model: USC6                                                      
device.serial:                                                  
device.type: ups                                        
driver.debug: 6                                                                                                                         
driver.flag.allow_killpower: 0                          
driver.name: riello_usb                                                
driver.parameter.default.battery.voltage.low: 22.9                                                                  
driver.parameter.localcalculation: 0
…

So that seems better?

No runtime though, I suppose because no localcalculation. Adding -x localcalculation=1:

battery.capacity: 9       
battery.charge: 100
battery.runtime: 864
battery.voltage: 27.4
battery.voltage.high: 26.0
battery.voltage.low: 22.9
battery.voltage.nominal: 24

Adding -x default.battery.voltage.high=24.0 also does set that how I'd expect.

Running it like this so it uses my config file:

$ sudo ./drivers/riello_usb -a riello -DDDDD -d 1
…
   4.909009     [D3] Entering dstate_dump
battery.capacity: 9  
battery.charge: 100       
battery.runtime: 864
battery.voltage: 27.4
battery.voltage.high: 24.0
battery.voltage.low: 22.9
battery.voltage.nominal: 24
device.mfr: RPS S.p.a.    
device.model: USC6
device.serial:
device.type: ups  
driver.debug: 5                                                                                                                         
driver.flag.allow_killpower: 0                                                                                                          
driver.name: riello_usb                                            
driver.parameter.default.battery.voltage.high: 24.0               
driver.parameter.default.battery.voltage.low: 22.9
driver.parameter.localcalculation: 1
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: auto
driver.state: dumping
driver.version: 2.8.0-3824-g0e14eebfa
driver.version.internal: 0.12
driver.version.usb: libusb-1.0.22 (API: 0x1000106)
input.bypass.frequency: 409.50
input.bypass.voltage: 4095
input.frequency: 50.00
input.voltage: 239
output.frequency: 50.00
output.frequency.nominal: 50.0
output.L1.current: 0
output.L1.power: 0
output.L1.realpower: 0
output.L2.current: 0
output.L2.power: 0
output.L2.realpower: 0
output.L3.current: 0
output.L3.power: 0
output.L3.realpower: 0
output.power.percent: 0
output.voltage: 239
output.voltage.nominal: 230
ups.delay.reboot: 5
ups.delay.shutdown: 5
ups.firmware: SWM048-01-05
ups.load: 0
ups.mfr: RPS S.p.a.
ups.model: USC6
ups.power.nominal: 1500
ups.productid: 5500
ups.realpower.nominal: 900
ups.serial:
ups.status: OL
ups.vendorid: 04b4
   4.909287     [D5] send_to_all: SETINFO driver.state "cleanup.upsdrv"                                                                 
   4.909774     [D5] send_to_all: SETINFO driver.state "cleanup.exit"

So that's got it?

@jimklimov

Copy link
Copy Markdown
Member

Seems like it, I hope :)

@jimklimov

jimklimov commented Mar 31, 2024 •

Copy link
Copy Markdown
Member

I see the 4095 and 409.5 mentions (all bits set in a 12-bit streak) are still a problem, but for some other day and tracked in some other ticket (PRs welcome though - possibly a few if's to ignore a reading in the right places).

At least, it's not something I'd comfortably address from just a phone with Termux in the middle of the ocean. Oh, the times and the things made possible!

@jimklimov
jimklimov merged commit f6bff66 into networkupstools:master Mar 31, 2024
jimklimov added a commit to jimklimov/nut that referenced this pull request Apr 11, 2024
…g lines [networkupstools#1692]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this pull request Apr 11, 2024
…calculation" feature from riello_ser [networkupstools#1692, networkupstools#2390]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov jimklimov added the Incorrect or missing readings On some devices driver-reported values are systemically off (e.g. x10, x0.1, const+Value, etc.) label Apr 11, 2024
Challado pushed a commit to Challado/nut that referenced this pull request Oct 14, 2026
riello_usb.c: option for driver to calculate values of battery.runtime and battery.charge "locally"

SVN-Git-Bridge: nut-3e341d2d9c-3fc79f1e8124 f6bff66
Bridge-Author: Jim Klimov <jimklimov+nut@gmail.com>
Bridge-Author-Date: 2024-03-31T08:15:15+02:00
Bridge-Committer: GitHub <noreply@github.com>
Bridge-Committer-Date: 2024-03-31T08:15:15+02:00
From: Jim Klimov <jimklimov+nut@gmail.com>

git-svn-id: file:///mnt/export/subversion/nut/trunk@3950 5f2f2009-99cd-4845-9af7-39d0aa6e3748
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Incorrect or missing readings On some devices driver-reported values are systemically off (e.g. x10, x0.1, const+Value, etc.) ready / gonna merge The PR is in final cycles leading to merge unless someone logs an objection before we hit the button Riello Riello UPS devices (serial, usb), usually with a variant of Qx protocol Shutdowns and overrides and battery level triggers Issues and PRs about system shutdown, especially if battery charge/runtime remaining is involved USB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

riello_usb.c - incorrect check for battery_charge cap value.

4 participants