Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/scripts/appveyor/02-install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ REM Without the ecosystem update above, the overhead of this step remained
REM similar. It did however use a smaller population (via deps) and older
REM versions of packages.
REM Prerequisites for NUT per https://github.com/networkupstools/nut/blob/master/docs/config-prereqs.txt :
C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -S --needed base-devel mingw-w64-x86_64-toolchain autoconf-wrapper automake-wrapper libtool mingw-w64-x86_64-libltdl gcc ccache mingw-w64-x86_64-ccache git aspell aspell-en python mingw-w64-x86_64-python-pygments mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-libusb mingw-w64-x86_64-libusb-compat-git mingw-w64-x86_64-neon libneon-devel mingw-w64-x86_64-libgd mingw-w64-x86_64-cppunit mingw-w64-x86_64-nss mingw-w64-x86_64-openssl"
C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -S --needed base-devel mingw-w64-x86_64-toolchain autoconf-wrapper automake-wrapper libtool mingw-w64-x86_64-libltdl gcc ccache mingw-w64-x86_64-ccache git aspell aspell-en python mingw-w64-x86_64-python-pygments mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-libusb mingw-w64-x86_64-neon libneon-devel mingw-w64-x86_64-libgd mingw-w64-x86_64-cppunit mingw-w64-x86_64-nss mingw-w64-x86_64-openssl"
if errorlevel 1 exit /b %ERRORLEVEL%
REM SKIP mingw-w64-x86_64-libmodbus-git : we custom-build one with USB support
REM SKIP for now NUT-Monitor prereqs (runtime Python would require somilar modules; need to fix localization builds like "fr.po"): gettext mingw-w64-x86_64-python-pyqt6
Expand Down
31 changes: 22 additions & 9 deletions INSTALL.nut.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,18 @@ Archives with binaries built by recent iterations of continuous integration
jobs should be available for exploration on the respective CI platforms.
======

[[Windows_USB]]
USB-connected devices
^^^^^^^^^^^^^^^^^^^^^

If you plan to use an UPS which is locally connected to an USB port,
you have to bind it to the WinUSB driver, so that NUT (built with
libusb-1.0) can open it. Most UPS devices are bound to the Windows HID
driver by default. You can use the `wdi-simple` program shipped with NUT
(see `scripts/Windows/DriverInstaller` in the sources), or
link:https://zadig.akeo.ie/[Zadig]: select the UPS, choose `WinUSB` and
click "Replace Driver". Both currently support Windows 7 and newer.

Historical MSI installer
^^^^^^^^^^^^^^^^^^^^^^^^

Expand All @@ -973,15 +985,16 @@ Newer Windows releases should include the Windows Installer natively.

Run `NUT-Installer.msi` and follow the wizard indications.

If you plan to use an UPS which is locally connected to an USB port,
you have to install
link:https://sourceforge.net/projects/libusb-win32/files/[libUSB-win32]
on your system. Then you must install your device via libusb's "Inf Wizard".

NOTE: If you intend to build from source, relevant sources may be available at
https://github.com/mcuee/libusb-win32 and keep in mind that it is a variant of
libusb-0.1. Current NUT supports libusb-1.0 as well, and that project should
have Windows support out of the box (but it was not explored for NUT yet).
That historical package was built with libusb-0.1: to use a locally
connected USB UPS with it, you would install
https://github.com/mcuee/libusb-win32[libusb-win32] and bind the device
to its `libusb0.sys` driver with libusb's "Inf Wizard". Current NUT for
Windows is built with libusb-1.0 only, and does not support that driver
(see <<Windows_USB,USB-connected devices>> above instead).

NOTE: A new installer based on the WiX Toolset is being worked on, see
link:scripts/Windows/Installer/README.adoc[scripts/Windows/Installer/README.adoc]
and https://github.com/networkupstools/nut/issues/1485 for details.

If you have selected default directory, all configuration files are located in
`C:\Program Files\NUT\ups\etc`
Expand Down
31 changes: 31 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ https://github.com/networkupstools/nut/milestone/13
result was stored as the availability of the XML/HTTP scan. So the
`-M` scan could be disabled despite a working `libneon`, or offered
without one (impacts NUT v2.8.3 through v2.8.5). [PR #3657]
- `nut-scanner` crashed in USB scans in 32-bit Windows builds: it
called the dynamically loaded libusb-1.0 methods as default C
functions, but there they use the calling convention of Windows
API methods (`LIBUSB_CALL`), so the stack got misaligned (impacts
all NUT 2.8.x until now). [PR #3791]
* USB drivers: fixed an out-of-bounds read of the candidate HID report
descriptor lengths, which could cause a segmentation fault (regression
added in NUT v2.8.5 release). [PR #3550]
Expand Down Expand Up @@ -1123,6 +1128,32 @@ https://github.com/networkupstools/nut/milestone/13
under `lib64` (e.g. on CentOS 7) and in directories named by just the
major and minor version (e.g. `aspell-0.60` for `aspell` 0.60.6.1).
[issue #2068, PR #3773]
* USB support can now be built against libusb-1.0 releases from 1.0.9
on, such as the `libusb1` 1.0.9 package of CentOS 6. Before 1.0.16
there is no `libusb_strerror()`, so error messages show the name of
the libusb error code (from `libusb_error_name()`) instead of its
description; before 1.0.10 or so there is no `libusb_get_version()`,
so `driver.version.usb` says the version is unknown. `nut-scanner`
falls back the same way when the libusb it loads at run time lacks
these methods. [issues #509, #3781, PR #3782]
* With `--with-usb=auto` (or `yes`), the `configure` script now falls
back to an also available libusb-0.1 when the preferred libusb-1.0 is
too old for NUT, instead of building without USB drivers. An explicit
`--with-usb=libusb-1.0` still fails in that case.
[issue #3781, PR #3782]
* Windows (MinGW/MSYS2) builds of NUT now support only libusb-1.0 for
USB drivers, used with the WinUSB driver. Support for libusb-0.1
(libusb-win32 with its `libusb0.sys` driver, or libusb-compat) was
removed from Windows builds: `configure --with-usb=libusb-0.1` now
fails there, and an auto-detected libusb-0.1 is not used. Tested
with `apcmicrolink` and `nut-scanner` on Windows 10.
[issue #1507, PR #3791]
* The `wdi-simple` USB driver installer for Windows now installs the
WinUSB driver (or libusbK, if chosen) instead of `libusb0.sys`,
accepts command-line options, and no longer reads past the end of
the generated NUT USB device table. Its build instructions were
updated for current libwdi.
[issue #1507, PR #3791]


Release notes for NUT 2.8.5 - what's new since 2.8.4
Expand Down
7 changes: 7 additions & 0 deletions UPGRADING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ Changes from 2.8.5 to 2.8.6
`*.pc` files, packaging recipes and tarball names are not changed.
[PR #3754 follow-up]

- Windows builds of NUT now support only libusb-1.0; libusb-0.1
(libusb-win32 or libusb-compat) is no longer supported there, and
`--with-usb=libusb-0.1` fails. Packagers should depend on libusb-1.0
instead. USB devices previously bound to the libusb-win32
`libusb0.sys` driver must be re-bound to the WinUSB driver (e.g. with
the updated `wdi-simple` or with Zadig). [issue #1507, PR #3791]

- The Perl `UPS::Nut` module now decodes NUT quoting and backslash escapes
in query/list values and `nutauth.conf`, including include paths. Remove
manual decoding of these returned values and pass literal credentials
Expand Down
17 changes: 4 additions & 13 deletions docs/config-prereqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2066,23 +2066,14 @@ export PATH
mingw-w64-x86_64-winpthreads-git \
mingw-w64-clang-x86_64-winpthreads-git

# Note that MSYS2 includes libusb-1.0 "natively"
# The NUT codebase adjustments for Windows might at this moment expect older
# ecosystem via https://github.com/mcuee/libusb-win32 -- subject to fix then.
# Note that MSYS2 includes libusb-1.0 "natively"; it is the only libusb
# supported by NUT on Windows (libusb-win32 and libusb-compat, i.e. the
# libusb-0.1 API, are not). The UPS must be bound to the WinUSB driver
# (e.g. with Zadig) for libusb-1.0 to open it.
:; pacman -S --needed \
mingw-w64-x86_64-libusb \
mingw-w64-clang-x86_64-libusb

# Seems that the older libusb-win32 (libusb-0.1) is also available as:
:; pacman -S --needed \
mingw-w64-x86_64-libusb-win32 \
mingw-w64-clang-x86_64-libusb-win32

# Alternately there is libusb-compat (libusb-1.0 codebase exposing the older
# libusb-0.1 API) which SHOULD NOT be installed along with the real libusb-0.1:
# :; pacman -S --needed mingw-w64-x86_64-libusb-compat-git \
# mingw-w64-clang-x86_64-libusb-compat-git

# This also pulls *-devel of several other projects:
:; pacman -S --needed \
mingw-w64-x86_64-neon libneon-devel \
Expand Down
13 changes: 12 additions & 1 deletion docs/nut.dict
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 3917 utf-8
personal_ws-1.1 en 3930 utf-8
AAC
AAS
ABI
Expand Down Expand Up @@ -1587,6 +1587,7 @@ WALKMODE
WARNFATAL
WARNOPT
WCH
WDK
WELI
WH
WHAD
Expand Down Expand Up @@ -2667,6 +2668,8 @@ libtool
libupsclient
libusb
libusb's
libusbK
libusbk
libusbugen
libusbx
libvirt
Expand Down Expand Up @@ -2701,6 +2704,7 @@ lm
lmodbus
ln
lnetsnmp
lntdll
loadPercentage
localcalculation
localhost
Expand All @@ -2715,6 +2719,7 @@ login
logins
logout
logrotate
lole
lookup
loopback
lowbatt
Expand All @@ -2723,6 +2728,7 @@ lr
lregex
ls
lsd
lsetupapi
lst
lsusb
lt
Expand All @@ -2731,6 +2737,7 @@ lu
lua
lv
lvo
lwdi
lws
lxc
lxcbr
Expand Down Expand Up @@ -3219,6 +3226,7 @@ reconnection
recurses
recursing
recv
redistributable
redistributors
reentrancy
refactored
Expand Down Expand Up @@ -3396,6 +3404,7 @@ slaveaddr
slaveid
slavesync
slibtool
sln
sm
smartslot
smartups
Expand Down Expand Up @@ -3822,6 +3831,7 @@ waitbeforereconnect
wakeup
wc
wdi
wdkdir
webserver
wf
wg
Expand All @@ -3835,6 +3845,7 @@ wininit
winnutclient
winpthreads
winsymlinks
winusb
withGiven
withdoc
wix
Expand Down
10 changes: 3 additions & 7 deletions drivers/blazer_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#endif /* WIN32 */

#define DRIVER_NAME "Megatec/Q1 protocol USB driver"
#define DRIVER_VERSION "0.27"
#define DRIVER_VERSION "0.28"

/* driver description structure */
upsdrv_info_t upsdrv_info = {
Expand Down Expand Up @@ -595,14 +595,10 @@ ssize_t blazer_command(const char *cmd, char *buf, size_t buflen)
break;

case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */
/* libusb-win32 does not know EPROTO and EOVERFLOW,
* it only returns EIO for any IO errors */
#ifndef WIN32
case LIBUSB_ERROR_OVERFLOW: /* Value too large for defined data type */
# if EPROTO && WITH_LIBUSB_0_1
#if EPROTO && WITH_LIBUSB_0_1
case -EPROTO: /* Protocol error */
# endif
#endif /* !WIN32 */
#endif
default:
break;
}
Expand Down
Loading
Loading