apc_modbus: Fix outlet group command handling to be dynamic#3395
apc_modbus: Fix outlet group command handling to be dynamic#3395jimklimov merged 3 commits intonetworkupstools:masterfrom
Conversation
b4d9d0b to
44fcf07
Compare
|
I have successfully tested FSD on a |
|
IIUC However there doesn't seem to be a documented |
|
Thanks @EchterAgo, this works perfectly on my SMT1500. RPMs built from 44fcf07, driver 0.19.
I also ran it through the full FSD path: The per-group timer readback is a nice touch too. During the countdown I could see the timers ticking down in real time via |
|
Great to hear! @EchterAgo : did this work mature up to un-draft the PR or do you plan any changes? I'd move the news entry up to other drivers so they are all close (with As this positively impacts a driver and has few risks for other NUT users, might even go into the next release that I keep hoping to cut =D maybe by end of Easter holidays... |
|
I definitely want to get this merged ASAP, the current code is broken. Currently I don't really know the CI results because the site loads either extremely slowly or not at all here, even when I connect a VPN or try other browsers. I'll update the NEWS entry soon. |
44fcf07 to
9071e35
Compare
|
A ZIP file with standard source tarball and another tarball |
Signed-off-by: Axel Gembe <axel@gembe.net>
Values of SOG[0..2].TurnOffCountdown_EN for easier diagnostics. Signed-off-by: Axel Gembe <axel@gembe.net>
74daafb to
28e53e9
Compare
|
✅ Build nut 2.8.4.4473-master completed (commit 1b13909710 by @EchterAgo)
|
|
CI was a bit bogged down lately, I've cleaned and hopefully sped it up a bit. |
|
✅ Build nut 2.8.4.4474-master completed (commit 90c3d11b15 by @EchterAgo)
|
|
FYI, I used AI (Claude Opus 4.5) to help me write the commit message and make sense of and query the spec documents a bit. |
|
✅ Build nut 2.8.4.4475-master completed (commit 260a7f0002 by @EchterAgo)
|
28e53e9 to
868b95e
Compare
Replace hardcoded outlet group commands with dynamic detection and handling based on the `SOGRelayConfigSetting` register. This ensures commands and variables are only exposed for outlet groups that are actually present on the UPS. Key changes: - Add `APC_VF_UNAVAILABLE` flag to mark registers for absent outlet groups - Add outlet group info table tracking presence and target bits for each group (`MOG`, `SOG0` to `SOG2`) - Dynamically enumerate `outlet.group.N.id`, `outlet.group.N.designator` and `outlet.group.N.status` variables based on detected groups - Replace static outlet command entries with `_apc_modbus_handle_outlet_cmd()` which parses `load.*`, `shutdown.*`, and `outlet.group.N.*` commands at runtime - Global `load.*` and `shutdown.*` commands now target all available outlet groups instead of only the main outlet group (`MOG`) - Add `outlet.group.N.*` commands (`load.off`, `load.on`, `load.cycle`, etc.) for each detected group - Update `upsdrv_shutdown()` to use the unified command handler - Add `OutletStatus_BF` bitfield definitions to header This fixes issues where commands were exposed for non-existent outlet groups and ensures load/shutdown operations affect all outlets on UPS units with switched outlet groups. Signed-off-by: Axel Gembe <axel@gembe.net>
868b95e to
0a13208
Compare
|
✅ Build nut 2.8.4.4476-master completed (commit de9b83aa91 by @EchterAgo)
|
It might help if you could set the CI to abort previous builds when the PR branch is pushed. https://www.jenkins.io/doc/book/pipeline/syntax/#:~:text=disableConcurrentBuilds
|
|
✅ Build nut 2.8.4.4477-master completed (commit 4041360a6f by @EchterAgo)
|
|
Aborting is enabled via milestones at different waiting pounts: if a newer build passes it first, older ones bail out. Also a limited amount of jobs are in flight while othrrs are queued. These levers can be pulled manually, e.g. to boost priority of newer iterations, but sonetimes there is value in completing older svheduled builds. Increasing in-flight job counts helps filter out at least spell-check and Makefile issues quickly, blocking on slower build/test phases - generated and placed last in queue. Also for master branch etc. we want all merges to have a verdict, even if it catches up much later (e.g. build newest commit of a merge train early, but intermediate points can wait until rebased open PRs are done). |
I am not sure why new Fedora's If the rest of workers won't complain about the current commit, this can be patched during merge. |
… 0 as initializer for enum-typed field [networkupstools#3395] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… 0 as initializer for enum-typed field [#3395] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Replace hardcoded outlet group commands with dynamic detection and handling based on the
SOGRelayConfigSettingregister. This ensures commands and variables are only exposed for outlet groups that are actually present on the UPS.Key changes:
APC_VF_UNAVAILABLEflag to mark registers for absent outlet groupsMOG,SOG0toSOG2)outlet.group.N.id,outlet.group.N.designatorandoutlet.group.N.statusvariables based on detected groups_apc_modbus_handle_outlet_cmd()which parsesload.*,shutdown.*, andoutlet.group.N.*commands at runtimeload.*andshutdown.*commands now target all available outlet groups instead of only the main outlet group (MOG)outlet.group.N.*commands (load.off,load.on,load.cycle, etc.) for each detected groupupsdrv_shutdown()to use the unified command handlerOutletStatus_BFbitfield definitions to headerThis fixes issues where commands were exposed for non-existent outlet groups and ensures load/shutdown operations affect all outlets on UPS units with switched outlet groups.
Signed-off-by: Axel Gembe axel@gembe.net
Fixes #2338
General points
Described the changes in the PR submission or a separate issue, e.g.
known published or discovered protocols, applicable hardware (expected
compatible and actually tested/developed against), limitations, etc.
There may be multiple commits in the PR, aligned and commented with
a functional change. Notably, coding style changes better belong in a
separate PR, but certainly in a dedicated commit to simplify reviews
of "real" changes in the other commits. Similarly for typo fixes in
comments or text documents.
Use of coding helper tools and AI should be disclosed in the commit
or PR comments (it is interesting to know which ones do a decent job).
As with other contributions, a human is responsible and thanked for the
quality and content of the change, and is presumed to have the right to
post that code to be published further under the project's license terms.
Please star NUT on GitHub, this helps with sponsorships! ;)
Frequent "underwater rocks" for driver addition/update PRs
Revised existing driver families and added a sub-driver if applicable
(
nutdrv_qx,usbhid-ups...) or added a brand new driver in the othercase.
Did not extend obsoleted drivers with new hardware support features
(notably
blazerand other single-device family drivers for Qx protocols,except the new
nutdrv_qxwhich should cover them all).For updated existing device drivers, bumped the
DRIVER_VERSIONmacroor its equivalent.
For USB devices (HID or not), revised that the driver uses unique
VID/PID combinations, or raised discussions when this is not the case
(several vendors do use same interface chips for unrelated protocols).
For new USB devices, built and committed the changes for the
scripts/upower/95-upower-hid.hwdbfileProposed NUT data mapping is aligned with existing
docs/nut-names.txtfile. If the device exposes useful data points not listed in the file, the
experimental.*namespace can be used as documented there, and discussionshould be raised on the NUT Developers mailing list to standardize the new
concept.
Updated
data/driver.list.inif applicable (new tested device info)Frequent "underwater rocks" for general C code PRs
structure layout and alignment in memory, endianness (layout of bytes and
bits in memory for multi-byte numeric types), or use of generic
intwherelanguage or libraries dictate the use of
size_t(orssize_tsometimes).Progress and errors are handled with
upsdebugx(),upslogx(),fatalx()and related methods, not with directprintf()orexit().Similarly, NUT helpers are used for error-checked memory allocation and
string operations (except where customized error handling is needed,
such as unlocking device ports, etc.)
Coding style (including whitespace for indentations) follows precedent
in the code of the file, and examples/guide in
docs/developers.txtfile.For newly added files, the
Makefile.amrecipes were updated and themake distchecktarget passes.General documentation updates
Added a bullet point into
NEWS.adoc, possibly alsoUPGRADING.adocif there is something packagers or custom-build users should take into
account (new driver categories, configuration options, dependencies...)
Updated
docs/acknowledgements.txt(for vendor-backed device support)Added or updated manual page information in
docs/man/*.txtfilesand corresponding recipe lists in
docs/man/Makefile.amfor new pagesPassed
make spellcheck, updated spell-checking dictionary in thedocs/nut.dictfile if needed (did not remove any words -- themakerule printout in case of changes suggests how to maintain it).
Additional work may be needed after posting this PR
Propose a PR for NUT DDL with detailed device data dumps from tests
against real hardware (the more models, the better).
Address NUT CI farm build failures for the PR: testing on numerous
platforms and toolkits can expose issues not seen on just one system.
the changed codebase.