Skip to content

Commit d409b43

Browse files
authored
Merge pull request #2368 from jimklimov/apc-modbus-doc-only
APC Modbus doc updates
2 parents 9fae2f6 + 6641b2a commit d409b43

File tree

7 files changed

+110
-8
lines changed

7 files changed

+110
-8
lines changed

Jenkinsfile-dynamatrix

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import org.nut.dynamatrix.*;
2525
def dynacfgPipeline = [:]
2626

2727
// NOTE: These can be further disabled or active in different combo specs
28-
// below based on branch names
28+
// below based on branch names. Also note that the values are somewhat
29+
// "inversed" -- e.g. that "disabledSomething = false" means "enable it".
2930
dynacfgPipeline.disableSlowBuildAutotools = false
3031
dynacfgPipeline.disableSlowBuildCIBuild = false
3132
dynacfgPipeline.disableSlowBuildCIBuildExperimental = false
@@ -427,12 +428,12 @@ set | sort -n """
427428
//'bodyParStages': {}
428429
] // one slowBuild filter configuration, autotools-Wall
429430

430-
,[name: 'Default autotools driven build with default configuration, bitness and warning levels on each NUT CI farm platform (but with fatal warnings as of gnu99/gnu++11)',
431+
,[name: 'Default autotools driven build with default configuration, bitness and warning levels on each NUT CI farm platform (but with fatal warnings as of gnu99/gnu++11, must pass where enabled)',
431432
disabled: dynacfgPipeline.disableSlowBuildAutotools,
432-
branchRegexSource: ~/^(PR-.+|fightwarn.*)$/,
433-
branchRegexTarget: dynacfgPipeline.branchStableRegex,
433+
//branchRegexSource: ~/^(PR-.+|fightwarn.*)$/,
434+
//branchRegexTarget: dynacfgPipeline.branchStableRegex,
434435
//branchRegexTarget: ~/fightwarn/,
435-
appliesToChangedFilesRegex: dynacfgPipeline.appliesToChangedFilesRegex_C,
436+
//appliesToChangedFilesRegex: dynacfgPipeline.appliesToChangedFilesRegex_C,
436437
'getParStages': { def dynamatrix, Closure body ->
437438
return dynamatrix.generateBuild([
438439
//commonLabelExpr: dynacfgBase.commonLabelExpr,

docs/man/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ CLEANFILES = *-spellchecked .prep-src-docs *-prepped
950950

951951
SUFFIXES = .txt-prepped .txt .html .1 .3 .5 .8
952952

953-
# For builds with allowed installation of prebuild man pages, check that
953+
# For builds with allowed installation of prebuilt man pages, check that
954954
# they exist in sources (make would pull them automatically as a fallback
955955
# from failed lookup in build products). For builds that require rebuild
956956
# of man pages, abort with error if build product is missing.

docs/man/apc_modbus.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,66 @@ Set the Modbus slave id. The default slave id is 1.
8383
Set the Modbus response timeout. The default timeout is set by libmodbus. It can
8484
be good to set a higher timeout on TCP connections with high latency.
8585

86+
BUGS
87+
----
88+
89+
This driver relies on advanced features of `libmodbus` to talk Modbus protocol
90+
over USB specifically (Serial and TCP are part of common library codebase).
91+
At the time of this writing, the common library project is just expecting a
92+
merge of the pull request with this ability.
93+
94+
For the time being, if your OS distribution does not ship the required feature
95+
set, you may have to build your own `libmodbus` and subsequently (re-)build NUT
96+
against this library, as detailed in the NUT GitHub Wiki at
97+
https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol
98+
99+
The short sequence may be like follows:
100+
------
101+
cd ~/
102+
git clone -b rtu_usb https://github.com/networkupstools/libmodbus
103+
cd libmodbus
104+
./autogen.sh
105+
./configure --with-libusb --prefix=/path/to/prefix
106+
make install
107+
------
108+
109+
[NOTE]
110+
======
111+
* you may need to `make && sudo make install` if you want to place this library
112+
files' variant into a system path (like `--prefix=/usr/local/ups` to match
113+
NUT defaults -- this activity would need privilege elevation via `sudo`),
114+
and not into your home directory or some `/tmp` location.
115+
* conversely, you may want to
116+
`./configure --with-libusb --enable-static --disable-shared --prefix=/path/to/prefix`
117+
and only build and install a static `libmodbus.a` (can well be installed into
118+
`/tmp` or similarly short-lived location), so that the customized Modbus+USB
119+
logic gets built directly into `apc_modbus` binary program and there would be
120+
no potential run-time conflict with a dynamic library file available elsewhere
121+
in the system.
122+
======
123+
124+
------
125+
cd ~/
126+
git clone https://github.com/networkupstools/nut
127+
cd nut
128+
./autogen.sh
129+
./configure --with-drivers=apc_modbus --with-usb --with-modbus \
130+
--with-modbus-includes=-I/path/to/prefix/include/modbus \
131+
--with-modbus-libs="-L/path/to/prefix/lib -lmodbus"
132+
make
133+
------
134+
135+
[NOTE]
136+
======
137+
* Other NUT `configure` options may be needed for proper behavior, such as
138+
`--prefix`, `--with-sysconfdir`, `--with-user` and `--with-group` to match
139+
your packaged or otherwise preceding NUT installation.
140+
======
141+
142+
The `./configure --enable-inplace-runtime` may be a good start to inherit
143+
build configuration from an existing NUT deployment, as further detailed at
144+
https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests
145+
86146
AUTHORS
87147
-------
88148

docs/nut.dict

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 3478 utf-8
1+
personal_ws-1.1 en 3480 utf-8
22
AAC
33
AAS
44
ABI
@@ -2431,6 +2431,7 @@ lk
24312431
lldb
24322432
llvm
24332433
lm
2434+
lmodbus
24342435
ln
24352436
lnetsnmp
24362437
loadPercentage
@@ -2940,6 +2941,7 @@ rqt
29402941
rsa
29412942
rsync
29422943
rts
2944+
rtu
29432945
ru
29442946
rubygem
29452947
runlevel

m4/nut_check_libmodbus.m4

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ if test -z "${nut_have_libmodbus_seen}"; then
7272
AC_CHECK_FUNCS(modbus_set_byte_timeout, [], [nut_have_libmodbus=no])
7373
AC_CHECK_FUNCS(modbus_set_response_timeout, [], [nut_have_libmodbus=no])
7474
75-
AC_CHECK_FUNCS(modbus_new_rtu_usb, [nut_have_libmodbus_usb=yes], [nut_have_libmodbus_usb=no])
75+
AC_CHECK_FUNCS(modbus_new_rtu_usb, [nut_have_libmodbus_usb=yes], [
76+
AS_IF([test x"${nut_with_usb}" = xyes && test x"${nut_with_modbus}" = xyes && test x"${nut_have_libmodbus}" = xyes ], [
77+
AC_MSG_WARN([Both --with-modbus and --with-usb were requested, and a libmodbus was found, but it seems to not support USB. You may require a custom build per https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol])
78+
])
79+
nut_have_libmodbus_usb=no
80+
])
7681
7782
dnl modbus_set_byte_timeout() and modbus_set_response_timeout()
7883
dnl in 3.0.x and 3.1.x have different args (since ~2013): the

tools/nut-scanner/scan_snmp.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,24 @@ nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip
10331033

10341034
# ifdef HAVE_SEMAPHORE
10351035
if (max_threads_scantype > 0) {
1036+
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
1037+
#pragma GCC diagnostic push
1038+
#endif
1039+
#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
1040+
#pragma GCC diagnostic ignored "-Wunreachable-code"
1041+
#endif
1042+
#ifdef __clang__
1043+
#pragma clang diagnostic push
1044+
#pragma clang diagnostic ignored "-Wunreachable-code"
1045+
#endif
1046+
/* Different platforms, different sizes, none fits all... */
10361047
if (SIZE_MAX > UINT_MAX && max_threads_scantype > UINT_MAX) {
1048+
#ifdef __clang__
1049+
#pragma clang diagnostic pop
1050+
#endif
1051+
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
1052+
#pragma GCC diagnostic pop
1053+
#endif
10371054
upsdebugx(1,
10381055
"WARNING: %s: Limiting max_threads_scantype to range acceptable for sem_init()",
10391056
__func__);

tools/nut-scanner/scan_xml_http.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,24 @@ nutscan_device_t * nutscan_scan_xml_http_range(const char * start_ip, const char
454454

455455
# ifdef HAVE_SEMAPHORE
456456
if (max_threads_scantype > 0) {
457+
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
458+
#pragma GCC diagnostic push
459+
#endif
460+
#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
461+
#pragma GCC diagnostic ignored "-Wunreachable-code"
462+
#endif
463+
#ifdef __clang__
464+
#pragma clang diagnostic push
465+
#pragma clang diagnostic ignored "-Wunreachable-code"
466+
#endif
467+
/* Different platforms, different sizes, none fits all... */
457468
if (SIZE_MAX > UINT_MAX && max_threads_scantype > UINT_MAX) {
469+
#ifdef __clang__
470+
#pragma clang diagnostic pop
471+
#endif
472+
#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE
473+
#pragma GCC diagnostic pop
474+
#endif
458475
upsdebugx(1,
459476
"WARNING: %s: Limiting max_threads_scantype to range acceptable for sem_init()",
460477
__func__);

0 commit comments

Comments
 (0)