Propagate IMMUTABLE flag on socket protocol (driver=>upsd); use it in netset; sanity-check if (defaulted) NUMBER values are not in fact STRINGs - #2549
Conversation
|
Rebased over proposed PR #2552 which covers the noisy but mostly cosmetic changes, to group logical-change commits later in the stack. |
…lag on values in DEBUG builds [networkupstools#266] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…etworkupstools#266] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…e as float or long int [networkupstools#266] If we assume a value without flags is by default a NUMBER but is not, re-default it to STRING. If it is also flagged explicitly as a NUMBER but is not, yell a warning for upstream to fix the code. Eventually this should be a reason to report protocol error, but not now. Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…, STRING and NUMBER flags [networkupstools#266] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…E" flag value [networkupstools#266] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… reinventing the wheel [networkupstools#266, networkupstools#966] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…pstools#266] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…MMUTABLE flag propagation on socket protocol (and fix float=>double) Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…tworkupstools#266] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…orkupstools#266] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…rkupstools#266] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
|
Updated with target code base shortly after v2.8.3 release (failed shellchecks) CI host disconnected, no code problems proven yet. Build restarted. |
|
✅ Build nut 2.8.3.3090-master completed (commit 6b875cfd2c by @jimklimov) |
|
While checking the shared state store on master Would you welcome a separate incremental-balancing change alongside this metadata work, and may the non-installed AI assistance: OpenAI Codex with |
Addresses various sides of issue #266 and should help hunt down cases where we do not provide a
NUMBER/STRINGflag for the readings.Currently this PR does not enforce the
STRING:Ntype but logs messages to that effect to help with further troubleshooting. One problem was about picking theauxvalue (e.g. allowed string length) at a point far away from code that should have defined the variable type in the first place. Another concern is about propagating the guessedSTRINGtype "upwards", so thatnetsetcan set it safely. Although if it lacks any type flag in the first place, most of those checks are (before and still) bypassed and any value should be settable.Possibly the better place for this sanity-checking logic of newly posted data vs. flags of a state entry is in core
state.ccode, to transplant pieces of bothnetset.c::set_var()andnetget.c::get_type()to restrict type usage that should conform to declared flags.Another aspect is bringing
IMMUTABLEflag presence into consideration when trying to set values over NUT protocol (it is not exposed inGET TYPEof the networked protocol to avoid changing the RFC).Screenshot with a driver that has
override.battery.charge=10inups.conf:Currently planning this PR to hang around for reviews and discussion until the next release after an upcoming one; some less questionable changes may be cherry-picked earlier.
This sort of change, or something inspired by it to ensure proper data type mapping with flags (maybe a table based on
docs/nut-names.txtto auto-flag device readings by pattern name? maybe from a loadable file, DMF or parseconf'ed?), would also be useful for efforts like #2525/#2524 which can culminate in reporting of JSON from NUT clients (web or not) -- and then best with a specific reportable schema.