Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .obs/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,3 @@ release_tag:
target_project: home:networkupstools:nut-releases
filters:
event: tag_push
tags:
only:
- "v[0-9]+.[0-9]+.[0-9]+"
ignore:
# v1.2.3-rc1, these need a different regex in _service of template project
- "*-*"

release_candidate_tag:
steps:
- branch_package:
source_project: home:networkupstools:nut-stable-rc
source_package: "%{SCM_REPOSITORY_NAME}"
target_project: home:networkupstools:nut-releases
filters:
event: tag_push
tags:
only:
# v1.2.3-rc1, these need a different regex in _service of template project
- "v[0-9]+.[0-9]+.[0-9]+-.*"
4 changes: 4 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ https://github.com/networkupstools/nut/milestone/12
reality agrees with a status reported by device/protocol (if any).
This is also a step in direction of eventually providing a common
`runtimecal` style fallback to all drivers. [issue #3146, PR #3156]
* Generalize `elapsed_since_timeval()` code, originally repeated in
several modbus drivers. [issue #1938, PR #3321]
* Introduced `NOTIFY_STATE_EXTEND_TIMEOUT` option and relevant variables
for `upsnotify()` method, so we can tell systemd to not kill the service
unit if its shutdown takes long (see also the `SHUTDOWNEXIT` option in
Expand Down Expand Up @@ -346,6 +348,8 @@ several `FSD` notifications into one executed action. [PR #3097]
* Now has JSON output mode via `?json` (or `&json`) CGI query parameter.
New `@TREELINK_JSON@` keyword added and HTML templates updated to expose
these JSON documents when browsing. [issue #2524, PRs #3171, #3249]
* The `@STATUS@` directive now optionally supports separators (not only
the hard-coded `<br/>` of the older versions. [issue #2525, PR #3318]
* Handle `device.model` in addition to `ups.model` in upsstats HTML
templates. [#3180]
* Introduced a `@NUT_UPSSTATS_TEMPLATE@` command which the HTML template
Expand Down
18 changes: 13 additions & 5 deletions clients/upsstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ static void parse_var(const char *var)
upsdebug_call_finished0();
}

static void do_status(void)
static void do_status(const char *sep)
{
int i;
int i, count = 0;
char status[SMALLBUF], *ptr, *last = NULL;

upsdebug_call_starting0();
Expand All @@ -244,7 +244,9 @@ static void do_status(void)
for (i = 0; stattab[i].name != NULL; i++) {

if (!strcasecmp(ptr, stattab[i].name)) {
printf("%s<br>", stattab[i].desc);
/* Note: sep="\0" is a valid case so we do not check for *sep */
printf("%s%s", count ? (sep ? sep : "<br/>") : "", stattab[i].desc);
count++;
}
}
}
Expand Down Expand Up @@ -926,8 +928,14 @@ static int do_command(char *cmd)
return 1;
}

if (!strncmp(cmd, "STATUS ", 7)) {
do_status(&cmd[7]);
upsdebug_call_finished0();
return 1;
}

if (!strcmp(cmd, "STATUS")) {
do_status();
do_status(NULL);
upsdebug_call_finished0();
return 1;
}
Expand Down Expand Up @@ -1305,7 +1313,7 @@ static void display_tree(int verbose)

printf("<TD>%s</TD>\n", answer[2]);
printf("<TD>:</TD>\n");
printf("<TD>%s<br></TD>\n", answer[3]);
printf("<TD>%s</TD>\n", answer[3]);

printf("</TR>\n");
}
Expand Down
25 changes: 25 additions & 0 deletions common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2734,6 +2734,31 @@ double difftimespec(struct timespec x, struct timespec y)
}
#endif /* HAVE_CLOCK_GETTIME && HAVE_CLOCK_MONOTONIC */

/* returns the time elapsed since start in milliseconds */
long elapsed_since_timeval(struct timeval *start)
{
long rval;
struct timeval end;

rval = gettimeofday(&end, NULL);
if (rval < 0) {
upslog_with_errno(LOG_ERR, "elapsed_since_timeval");
}
if (start->tv_usec < end.tv_usec) {
suseconds_t nsec = (end.tv_usec - start->tv_usec) / 1000000 + 1;
end.tv_usec -= 1000000 * nsec;
end.tv_sec += nsec;
}
if (start->tv_usec - end.tv_usec > 1000000) {
suseconds_t nsec = (start->tv_usec - end.tv_usec) / 1000000;
end.tv_usec += 1000000 * nsec;
end.tv_sec -= nsec;
}
rval = (end.tv_sec - start->tv_sec) * 1000 + (end.tv_usec - start->tv_usec) / 1000;

return rval;
}

/* Help avoid cryptic "upsnotify: notify about state 4 with libsystemd:"
* (with only numeric codes) below */
const char *str_upsnotify_state(upsnotify_state_t state) {
Expand Down
1 change: 0 additions & 1 deletion conf/upsstats.html.sample.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ th, td{padding:0.5ex;}
.t2{background:#0f0;}
</style>
<!-- link rel="stylesheet" type="text/css" href="nut.css" / -->
@REFRESH@
</head>
<body>

Expand Down
34 changes: 19 additions & 15 deletions docs/maintainer-guide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,26 @@ symbol names and API versions, similar to what `GNUC` or `SUNW` libraries do.

* bump the release identification (consider committing as one commit later on):
** see `docs/nut-versioning.adoc` for details about NUT SEMVER spec and practice
** revise `.github/workflows/08-PyNUTClient.yml` for fallback `TAG_NAME` naming
** revise `appveyor.yml` for branch naming
** revise `scripts/Windows/build-mingw-nut.sh` for fallback value of `VER_OPT`
** revise `scripts/obs/debian.changelog` (at least a dummy entry)
** revise `scripts/obs/nut.dsc` and `scripts/obs/nut.spec` for their `Version`
fields
** update the fallback `NUT_DEFAULT_VERSION` in `tools/gitlog2version.sh` to
<exact incremented version> (ex: `2.8.0`), and provide the `VERSION_FORCED`
and `VERSION_FORCED_SEMVER` files (to same effect but more explicitly and
<exact incremented version> (ex: `2.8.0`)
*** DOUBLE-CHECK that the `NUT_DEFAULT_VERSION` in `tools/gitlog2version.sh`
is an `X.Y.Z` triplet, without the fourth `.1` suffix, for the release!
*** Note that since NUT v2.8.3 this script dictates the version propagated by
the `configure` script, so direct changes of `AC_INIT` there are no longer
needed
** commit with a relevant release message, e.g.:
+
----
:; git commit -sm 'Update versions for release of NUT v2.8.0'
----
** provide the `VERSION_FORCED` and `VERSION_FORCED_SEMVER` files (to same
effect as fallback in `tools/gitlog2version.sh` but more explicitly and
visibly) in the local workspace to be added to the `dist` archive tarball
file (DO NOT add them to git to avoid confusion later, or revert any such
addition after the release -- still has a chance to confuse e.g. branches
Expand Down Expand Up @@ -214,19 +231,6 @@ VERSION_FORCED_SEMVER:NUT_VERSION_FORCED_SEMVER='2.8.3'
# if file names in your top_srcdir are removed:
:; ln .relver/* .
----
*** DOUBLE-CHECK that the `NUT_DEFAULT_VERSION` in `tools/gitlog2version.sh`
is an `X.Y.Z` triplet, without the fourth `.1` suffix, for the release!
*** Note that since NUT v2.8.3 this script dictates the version propagated by
the `configure` script, so direct changes of `AC_INIT` there are no longer
needed
** revise `.github/workflows/PyNUTClient.yml` for fallback `TAG_NAME` naming
** revise `appveyor.yml` for branch naming
** revise `scripts/Windows/build-mingw-nut.sh` for fallback value of `VER_OPT`
** commit with a relevant release message, e.g.:
+
----
:; git commit -sm 'Update versions for release of NUT v2.8.0'
----

* last-minute update against possible master-branch changes (and be sure to
apply the release-version changes described above to your local copy of
Expand Down
7 changes: 6 additions & 1 deletion docs/man/upsstats.html.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,14 @@ Insert the META header magic for refreshing the page if that variable
has been set by the browser. This needs to be in the HEAD section of
the page.

*@STATUS separator@*::
*@STATUS@*::
Expand the abbreviations in the ups.status variable -- OL becomes
"On line", OB becomes "On battery", and so on.
"On line", OB becomes "On battery", and so on. Reported values are
separated by the specified optional separator (`<br/>` if not specified),
which starts at the next character after the "STATUS<space>" (e.g.
a `@STATUS @` directive might be used to avoid any separation, or
`@STATUS @` to separate by spaces.

*@STATUSCOLOR@*::
Insert red, green, or yellow color triplets depending on the severity of
Expand Down
33 changes: 2 additions & 31 deletions drivers/adelsystem_cbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

#define DRIVER_NAME "NUT ADELSYSTEM DC-UPS CB/CBI driver (libmodbus link type: " NUT_MODBUS_LINKTYPE_STR ")"
#define DRIVER_VERSION "0.07"
#define DRIVER_VERSION "0.08"

/* variables */
static modbus_t *mbctx = NULL; /* modbus memory context */
Expand Down Expand Up @@ -83,10 +83,6 @@ int register_write(modbus_t *mb, int addr, regtype_t type, void *data);
/* instant command triggered by upsd */
int upscmd(const char *cmdname, const char *extra);

/* count the time elapsed since start */
long time_elapsed(struct timeval *start);


/* driver description structure */
upsdrv_info_t upsdrv_info = {
DRIVER_NAME,
Expand Down Expand Up @@ -790,31 +786,6 @@ int register_write(modbus_t *mb, int addr, regtype_t type, void *data)
return rval;
}

/* returns the time elapsed since start in milliseconds */
long time_elapsed(struct timeval *start)
{
long rval;
struct timeval end;

rval = gettimeofday(&end, NULL);
if (rval < 0) {
upslog_with_errno(LOG_ERR, "time_elapsed");
}
if (start->tv_usec < end.tv_usec) {
suseconds_t nsec = (end.tv_usec - start->tv_usec) / 1000000 + 1;
end.tv_usec -= 1000000 * nsec;
end.tv_sec += nsec;
}
if (start->tv_usec - end.tv_usec > 1000000) {
suseconds_t nsec = (start->tv_usec - end.tv_usec) / 1000000;
end.tv_usec += 1000000 * nsec;
end.tv_sec -= nsec;
}
rval = (end.tv_sec - start->tv_sec) * 1000 + (end.tv_usec - start->tv_usec) / 1000;

return rval;
}

/* instant command triggered by upsd */
int upscmd(const char *cmdname, const char *extra)
{
Expand Down Expand Up @@ -861,7 +832,7 @@ int upscmd(const char *cmdname, const char *extra)
}

/* wait for an increasing time interval before sending shutdown command */
while ((etime = time_elapsed(&start)) < ( FSD_REPEAT_INTRV / cnt));
while ((etime = elapsed_since_timeval(&start)) < ( FSD_REPEAT_INTRV / cnt));
upsdebugx(2, "ERROR: load.off failed, wait for %lims, retries left: %d", etime, cnt - 1);
cnt--;
}
Expand Down
34 changes: 3 additions & 31 deletions drivers/generic_modbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#endif

#define DRIVER_NAME "NUT Generic Modbus driver (libmodbus link type: " NUT_MODBUS_LINKTYPE_STR ")"
#define DRIVER_VERSION "0.09"
#define DRIVER_VERSION "0.10"

/* variables */
static modbus_t *mbctx = NULL; /* modbus memory context */
Expand Down Expand Up @@ -69,9 +69,6 @@ int upscmd(const char *cmd, const char *arg);
/* read signal status */
int get_signal_state(devstate_t state);

/* count the time elapsed since start */
long time_elapsed(struct timeval *start);

int register_write(modbus_t *mb, int addr, regtype_t type, void *data);

/* driver description structure */
Expand Down Expand Up @@ -543,31 +540,6 @@ int register_write(modbus_t *mb, int addr, regtype_t type, void *data)
return rval;
}

/* returns the time elapsed since start in milliseconds */
long time_elapsed(struct timeval *start)
{
long rval;
struct timeval end;

rval = gettimeofday(&end, NULL);
if (rval < 0) {
upslog_with_errno(LOG_ERR, "time_elapsed");
}
if (start->tv_usec < end.tv_usec) {
suseconds_t nsec = (end.tv_usec - start->tv_usec) / 1000000 + 1;
end.tv_usec -= 1000000 * nsec;
end.tv_sec += nsec;
}
if (start->tv_usec - end.tv_usec > 1000000) {
suseconds_t nsec = (start->tv_usec - end.tv_usec) / 1000000;
end.tv_usec += 1000000 * nsec;
end.tv_sec -= nsec;
}
rval = (end.tv_sec - start->tv_sec) * 1000 + (end.tv_usec - start->tv_usec) / 1000;

return rval;
}

/* instant command triggered by upsd */
int upscmd(const char *cmd, const char *arg)
{
Expand Down Expand Up @@ -611,7 +583,7 @@ int upscmd(const char *cmd, const char *arg)
}

/* wait for FSD_pulse_duration ms */
while ((etime = time_elapsed(&start)) < FSD_pulse_duration);
while ((etime = elapsed_since_timeval(&start)) < FSD_pulse_duration);

data = 0 ^ sigar[FSD_T].noro;
rval = register_write(mbctx, sigar[FSD_T].addr, sigar[FSD_T].type, &data);
Expand Down Expand Up @@ -654,7 +626,7 @@ int upscmd(const char *cmd, const char *arg)
}

/* wait for an increasing time interval before sending shutdown command */
while ((etime = time_elapsed(&start)) < ( FSD_REPEAT_INTRV / cnt));
while ((etime = elapsed_since_timeval(&start)) < ( FSD_REPEAT_INTRV / cnt));
upsdebugx(2,"ERROR: load.off failed, wait for %lims, retries left: %d\n", etime, cnt - 1);
cnt--;
}
Expand Down
3 changes: 3 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,9 @@ double difftimeval(struct timeval x, struct timeval y);
double difftimespec(struct timespec x, struct timespec y);
#endif

/* count the time elapsed since start in milliseconds */
long elapsed_since_timeval(struct timeval *start);

#ifndef HAVE_USLEEP
/* int __cdecl usleep(unsigned int useconds); */
/* Note: if we'd need to define an useconds_t for obscure systems,
Expand Down
14 changes: 14 additions & 0 deletions scripts/Windows/build-mingw-nut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
#
# script to cross compile NUT for Windows from Linux using MinGW-w64
# http://mingw-w64.sourceforge.net/
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#set -x

Expand Down
Loading