Conversation
Add the optional 'value' argument to the upscmd man page synopsis and describe both the 'command' and 'value' parameters. Signed-off-by: TomZanna <git@tomzanna.com>
Document and implement command_delay automatic timeout handling, plus offdelay and startdelay parameters, and expose outlet.count and ups.watchdog.status variables. Signed-off-by: TomZanna <git@tomzanna.com>
|
A ZIP file with standard source tarball and another tarball with pre-built docs for commit e506a3a is temporarily available: NUT-tarballs-PR-3722.zip. |
|
✅ Build nut 2.8.5.5554-master completed (commit eaf8b63f12 by @TomZanna)
|
…ings Add read-only input.transfer.reason variable from the device's recorded bypass code, refreshed each poll and cleared by clear.fault.record. Stop publishing device settings (outlet.delay.start, ups.start.auto, ups.watchdog.status, input.eco.switchable, ups.beeper.status) with assumed defaults; expose them only once the device reports them, retaining last known values with a warning when the device stops responding.
|
✅ Build nut 2.8.5.5558-master completed (commit 18766b1f95 by @TomZanna)
|
|
✅ Build nut 2.8.5.5558-master completed (commit 18766b1f95 by @TomZanna) |
…ools#3722] Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov
left a comment
There was a problem hiding this comment.
Generally looks quite solid, thanks! One group of comments I have is about terminology (see concerns about "outlet bank" below), another is about readability of logged messages - many places where I think there should be a space between %s tokens... or maybe I missed something as I read the code. There may also be some de-duplication possible with existing common code.
| A command that is reported as failed had at least one of the operations it | ||
| performs rejected by the device (or unanswered), so a partially applied | ||
| command is possible and worth re-checking with linkman:upsc[8]. |
There was a problem hiding this comment.
How would upsc help with the re-check? Would the failure be exposed in an alarm/status? (If so, clarify in the doc).
There was a problem hiding this comment.
Fair point... upsc only shows the published state, and a rejected write does not change it,
so the old sentence was misleading. Reworded so that is clear that the driver logs which operation was
rejected, and what is published is what the device actually did, as reported on the next
poll. Nothing is surfaced as an alarm or a status variable, and the text no longer implies
otherwise.
| with a warning for every failed read. | ||
|
|
||
| *outlet.count*:: | ||
| Total number of controllable outlet banks. |
There was a problem hiding this comment.
Here and below, I assume "outlet bank" is same concept as "outlet group" named in existing code/docs? There is a whole section on them in docs/nut-names.txt.
Likewise (also for code) there is already a documented data point name outlet.group.count
That said, there is also precedent (in SNMP mappings mostly) about outlet.group.count, outlet.count and outlet.group.%i.count (IIRC reflecting the amount of groups, total sockets, and sockets in the particular group, if exposed by the device like ePDU). In many cases, a larger UPS may provide a couple or more groups of 4-8 sockets which turn on/off as one bundle, and sometimes address high-power C19 sockets (where a PDU might be connected with a dozen or more devices fed) for stand-alone management.
So please revise which one fits this device/driver best to use them somewhat consistently :)
| *upscmd* -l 'ups' | ||
|
|
||
| *upscmd* [-A 'authconf'] [-u 'username'] [-p 'password'] [-w] [-t <timeout>] 'ups' 'command' | ||
| *upscmd* [-A 'authconf'] [-u 'username'] [-p 'password'] [-w] [-t <timeout>] 'ups' 'command' ['value'] |
There was a problem hiding this comment.
Good catch, we were just two decades late on documenting this change :D
| /* Milliseconds elapsed since '*start', as a signed value ("now" is expected | ||
| * to be later than the reference time). */ | ||
| static long elapsed_milliseconds(const struct timeval *start) | ||
| { | ||
| struct timeval now; | ||
|
|
||
| gettimeofday(&now, NULL); | ||
| return (long)(now.tv_sec - start->tv_sec) * 1000L | ||
| + (long)(now.tv_usec - start->tv_usec) / 1000L; | ||
| } | ||
|
|
There was a problem hiding this comment.
This one is neat, but I wonder if common.c already has something of the sort - check elapsed_since_timeval(), IMHO it looks like a stronger alternative?
| upslogx(LOG_ERR, "device rejected or did not answer [%s%s]", | ||
| command, NUT_STRARG(parameters)); |
There was a problem hiding this comment.
Wouldn't this want a third %s in the middle, printed as: ((parameters && *parameters) ? " " : "") to separate from command?.. Or just a space, as NUT_STRARG would print a <null> if applicable anyway?
| do_command(SET, IDENTIFICATION, response, NULL); | ||
| if (!send_set_command(IDENTIFICATION, response)) | ||
| upslogx(LOG_ERR, "%s: device rejected or did not " | ||
| "answer [%s%s]", __func__, IDENTIFICATION, |
There was a problem hiding this comment.
Maybe similar comment as elsewhere, now about spacing between ID and response?
| do_command(SET, TRANSFER_VOLTAGE, response, NULL); | ||
| if (!send_set_command(TRANSFER_VOLTAGE, response)) | ||
| upslogx(LOG_ERR, "%s: device rejected or did not answer " | ||
| "[%s%s]", __func__, TRANSFER_VOLTAGE, response); |
There was a problem hiding this comment.
Maybe similar comment as elsewhere, now about spacing between TV and response?
| do_command(SET, TRANSFER_VOLTAGE, response, NULL); | ||
| if (!send_set_command(TRANSFER_VOLTAGE, response)) | ||
| upslogx(LOG_ERR, "%s: device rejected or did not answer " | ||
| "[%s%s]", __func__, TRANSFER_VOLTAGE, response); |
There was a problem hiding this comment.
Maybe similar comment as elsewhere, now about spacing between TV and response?
| do_command(SET, VOLTAGE_SENSITIVITY, parm, NULL); | ||
| if (!send_set_command(VOLTAGE_SENSITIVITY, parm)) | ||
| upslogx(LOG_ERR, "%s: device rejected or did " | ||
| "not answer [%s%s]", __func__, |
There was a problem hiding this comment.
Maybe similar comment as elsewhere, now about spacing between VS and parm?
| /* Read the watchdog setting and publish ups.watchdog.status. The device | ||
| * reports "<timeout in seconds>;<restart alarm flag>", where a timeout of 0 | ||
| * means that the watchdog is disabled. This is auxiliary information, so a | ||
| * missing or unexpected answer must not mark the whole UPS as stale: a | ||
| * warning is logged and the previously published value is left in place. */ | ||
| static int get_watchdog(void) { |
There was a problem hiding this comment.
Interesting - can this use the UPS as an external watchdog (e.g. reboot the computer if it missed a few polls)? Can this then be disabled (by a command and perhaps by graceful driver exit), for example when we know we are bringing the driver down for package upgrade, system shutdown, etc.?
There was a problem hiding this comment.
Yeah, if polling stops while it's armed the UPS just cuts power to the load.
Right now, you can disarm it manually via upsrw -s ups.watchdog.status=disabled [ups-name]. I'll test if disarming it in upsdrv_cleanup() is doable over the next few days and push a commit.
|
❌ Build nut 2.8.5.5561-master failed (commit 6c4d8f874c by @jimklimov) |
…y in man page Improve tripplitesu driver error handling to exit upon intermediate errors rather than continuing. Update the man page to consistently use "outlet" terminology instead of "outlet bank", and expand documentation of the watchdog setting and command failure behavior for clarity. Signed-off-by: TomZanna <git@tomzanna.com>
|
✅ Build nut 2.8.5.5565-master completed (commit cecbe3ba76 by @TomZanna)
|
|
✅ Build nut 2.8.5.5565-master completed (commit cecbe3ba76 by @TomZanna) |
Added the
offdelayandstartdelaysettings toups.conf(in seconds and minutes, respectively, matching the units used by the corresponding device commands). Also added support for an optional delay (in seconds) passed through thevalueargument of theshutdown.return,shutdown.reboot, andshutdown.reboot.gracefulinstant commands. This allows the delay to be selected per invocation without restarting the driver or changing its configuration.Added control of individual outlet banks through the
outlet.n.load.offandoutlet.n.load.oninstant commands, along with the correspondingoutlet.count,outlet.n.status, andoutlet.n.switchablevariables.Added the
shutdown.stayoffinstant command and aligned the shutdown-related commands with their intended return-delay behavior:shutdown.rebootandshutdown.reboot.gracefulrequest the load to return immediately after shutdown. The device will only restart the load when the restart delay is longer than the shutdown delay.shutdown.returnandshutdown.stayoffclear the return delay, so the load returns only when mains is (re)applied, or remains off, respectively.Added the following variables and instant commands:
ups.beeper.status,ups.delay.start,ups.start.auto,ups.watchdog.status,outlet.delay.start, andinput.eco.switchablebattery.datebeeper.muteandclear.fault.recordinput.transfer.lowandinput.transfer.highagainst the ranges reported by the device, exposed throughinput.transfer.low.min/.maxandinput.transfer.high.min/.max.Instant commands and variable writes now report failures when the device rejects an operation or does not respond, instead of unconditionally reporting success.
Added the
command_delaysetting toups.confto enforce a minimum interval, in milliseconds, between commands sent to the UPS. This works around devices that fail to respond when commands are sent too soon after one another. The interval is measured from the previous command, so an idle connection is not penalized. The special value-1starts the driver without an initial delay and enables one-second command pacing only after a command times out. See [PR drivers/tripplitesu.c: add 1s delay in command_send #3273].