-
-
Notifications
You must be signed in to change notification settings - Fork 390
Add support for shutdown variables, mode selector, PC reset timing, a… #2986
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
base: master
Are you sure you want to change the base?
Conversation
…nd battery switch threshold - Introduced new variables to the phoenixcontact_modbus driver especially for QUINTS 4 USB: - shutdown variables - mode selector 9 = PC_MODE - PC reset delay after main power recovers - automatic switch to battery mode if main power is below or above a defined threshold. Signed-off-by: haul <[email protected]>
74ac377
to
1a24576
Compare
❌ Build nut 2.8.3.3288-master failed (commit 44e1837c49 by @) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Code changes look reasonable, there are some syntactic/markup problems to take care of, as commented additionally.
Why did all code get indented and end-of-file blank line get lost? Please fix this back too :)
Also, some additions are due into docs/man/... page for the driver, and into NEWS.adoc
about changes to this driver that would get published in a future NUT release.
drivers/phoenixcontact_modbus.c
Outdated
|
||
/* --- Shutdown & Mode Configuration --- */ | ||
|
||
// Macro for fetching a uint16_t config value with fallback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below, please use block comments /* ... */
even for single line texts
drivers/phoenixcontact_modbus.c
Outdated
addvar(VAR_VALUE, "delay.shutdown", "Delay before initiating PC shutdown (in seconds)"); | ||
addvar(VAR_VALUE, "delay.pc_shutdown", "Time allowed for PC to shutdown (in seconds)"); | ||
addvar(VAR_VALUE, "delay.pc_reset", "Duration of output off before reboot (in seconds)"); | ||
addvar(VAR_VALUE, "delay.mains_return", "Delay before switching back to mains (in seconds)"); | ||
addvar(VAR_VALUE, "mode.selector", "UPS operating mode (e.g. 9 = PC-Mode)"); | ||
addvar(VAR_VALUE, "bat.warning_soh", "Battery warning SOH threshold (%)"); | ||
addvar(VAR_VALUE, "bat.voltage_low", "Threshold [V] to switch to battery mode"); | ||
addvar(VAR_VALUE, "mains.voltage_high", "Threshold [V] to return to mains mode"); | ||
addvar(VAR_VALUE, "mains.return_delay", "Time [s] above threshold before switching back to mains"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add these explanations also to the man page?
drivers/phoenixcontact_modbus.c
Outdated
{ "ups.delay.shutdown", REG_PC_SHUTDOWN_DELAY}, | ||
{ "ups.delay.pc_shutdown", REG_PC_SHUTDOWN_TIME}, | ||
{ "ups.delay.pc_reset", REG_PC_RESET_TIME}, | ||
{ "ups.delay.mains_return", REG_MAINS_RETURN_DELAY}, | ||
{ "ups.mode.selector", REG_MODE_SELECTOR_SWITCH}, | ||
{ "ups.bat.warning_soh", REG_WARNING_SOH_THRESHOLD}, | ||
{ "ups.bat.voltage_low", REG_VOLTAGE_BELOW_BATTERY}, | ||
{ "ups.mains.voltage_high", REG_VOLTAGE_ABOVE_MAINS } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these strings are also driver configuration parameters (per addvar()
below)?
If any of these concepts are already described by standard NUT variable/command names listed in docs/nut-names.txt, it would be beneficial to add corresponding code so upsrw
/upscmd
can be used to set them at run-time, same way as for any other supported UPS with such features. But this may be improved later.
- Bumped internal version to 0.09 (two-digit format) - Replaced single-line // comments with /* ... */ block comments - Added missing variable descriptions to the man page - Preserved original authors in metadata - Standardized config variable names to align with nut-names.txt where possible - Declared all variables at top of scope as per C89 style Feedback originally provided by @jimklimov on PR networkupstools#2986 (superseded by this commit)
- Bumped internal version to 0.09 (two-digit format) - Replaced single-line // comments with /* ... */ block comments - Added missing variable descriptions to the man page - Preserved original authors in metadata - Standardized config variable names to align with nut-names.txt where possible - Declared all variables at top of scope as per C89 style Feedback originally provided by @jimklimov on PR networkupstools#2986 (superseded by this commit) Signed-off-by: haul <[email protected]>
f2cd302
to
5c5ef54
Compare
Thanks @jimklimov for your feedback. I updated the code, and please dont hesitate to add more feedback :) |
…pstools#2986] Signed-off-by: Jim Klimov <[email protected]>
…upstools#2986] Signed-off-by: Jim Klimov <[email protected]>
] Signed-off-by: Jim Klimov <[email protected]>
…etworkupstools#2986] Signed-off-by: Jim Klimov <[email protected]>
…tributors list [networkupstools#2986] Signed-off-by: Jim Klimov <[email protected]>
…#2986] Signed-off-by: Jim Klimov <[email protected]>
✅ Build nut 2.8.3.3312-master completed (commit 1339a1e957 by @jimklimov) |
✅ Build nut 2.8.3.3318-master completed (commit c4e8d885fd by @jimklimov) |
…pstools#2986] Signed-off-by: Jim Klimov <[email protected]>
…upstools#2986] Signed-off-by: Jim Klimov <[email protected]>
…tributors list [networkupstools#2986] Signed-off-by: Jim Klimov <[email protected]>
] * static methods * declarations before code * mismatches of int type vs printf formatting string (hex) Signed-off-by: Jim Klimov <[email protected]>
…etworkupstools#2986] This is not directly a troff file Signed-off-by: Jim Klimov <[email protected]>
…#2986] Signed-off-by: Jim Klimov <[email protected]>
5382b76
to
515cd8a
Compare
❌ Build nut 2.8.3.3319-master failed (commit b0c36621f4 by @jimklimov) |
@haulfi : Now that the driver code looks good for CI, I wonder if these added driver-configuration names (for concepts that overlap with existing standard NUT variable or instant command names in And as noted in earlier review comments, I'm also wondering if for at least some of these it would make sense to back them as ordinary NUT variables (rather than internal C numeric variables), which can be set at run-time by |
Note: AppVeyor CI build itself was OK, just overflowed their time allocation so could not finish some job book-keeping. |
…nd battery switch threshold
Introduced new variables to the phoenixcontact_modbus driver especially for QUINTS 4 USB:
Signed-off-by: Uli [email protected]
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.
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
blazer
and other single-device family drivers for Qx protocols,except the new
nutdrv_qx
which should cover them all).For updated existing device drivers, bumped the
DRIVER_VERSION
macroor 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.hwdb
fileProposed NUT data mapping is aligned with existing
docs/nut-names.txt
file. 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.in
if 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
int
wherelanguage or libraries dictate the use of
size_t
(orssize_t
sometimes).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.txt
file.For newly added files, the
Makefile.am
recipes were updated and themake distcheck
target passes.General documentation updates
Updated
docs/acknowledgements.txt
(for vendor-backed device support)Added or updated manual page information in
docs/man/*.txt
filesand corresponding recipe lists in
docs/man/Makefile.am
for new pagesPassed
make spellcheck
, updated spell-checking dictionary in thedocs/nut.dict
file if needed (did not remove any words -- themake
rule 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.