-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
APC_MODBUS _apc_modbus_read_registers Timeouts #2609
Comments
Build command for libmodbus and NUT build_libmodbus.sh #!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo -e "ERROR: Please run as root\n"
exit
fi
# Install dependencies
apt-get install -y \
autoconf libusb-1.0-0-dev libusb-dev git libtool gawk
# Build RTU USB Library
git clone -b rtu_usb https://github.com/networkupstools/libmodbus
cd libmodbus
./autogen.sh
export DEB_HOST_MULTIARCH=aarch64-linux-gnu
./configure \
--prefix=/usr \
--sysconfdir=/etc/nut \
--includedir=/usr/include \
--mandir=/usr/share/man \
--libdir=/usr/lib/${DEB_HOST_MULTIARCH} \
--libexecdir=/usr/libexec \
--with-libusb \
--enable-static \
--enable-shared \
--with-pkgconfig-dir=/usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig
make -j4 && make install build_nut.sh #!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo -e "ERROR: Please run as root\n"
exit
fi
# Install dependencies
apt-get install -y \
libssl-dev libnss3-dev libgd-dev augeas-tools \
libaugeas-dev augeas-lenses libcppunit-dev \
ccache time perl curl make autoconf automake \
libltdl-dev libtool cppcheck pkg-config gcc g++ \
clang valgrind libsystemd-dev
# Build NUT
git clone https://github.com/networkupstools/nut
cd nut
./autogen.sh
export DEB_HOST_MULTIARCH="aarch64-linux-gnu"
./configure \
--prefix=/usr \
--with-doc=no \
--with-drivers="apc_modbus,usbhid-ups" \
--with-usb \
--with-modbus \
--sysconfdir=/etc/nut \
--includedir=/usr/include \
--mandir=/usr/share/man \
--libdir=/usr/lib/${DEB_HOST_MULTIARCH} \
--libexecdir=/usr/libexec \
--with-ssl \
--with-nss \
--with-cgi \
--with-dev \
--with-statepath=/run/nut \
--with-altpidpath=/run/nut \
--with-drvpath=/lib/nut \
--with-cgipath=/usr/lib/cgi-bin/nut \
--with-htmlpath=/usr/share/nut/www \
--with-pidpath=/run/nut \
--datadir=/usr/share/nut \
--with-pkgconfig-dir=/usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig \
--with-user=nut \
--with-group=nut \
--with-udev-dir=/lib/udev \
--with-systemdsystemunitdir=/lib/systemd/system \
--with-systemdshutdowndir=/lib/systemd/system-shutdown \
--with-systemdtmpfilesdir=/usr/lib/tmpfiles.d
make -j4
echo ""
read -p "Do you wish to continue? [Y/N] " yesno
case $yesno in
[Yy]* )
echo "Installing..."
;;
* )
echo "Exiting..."
exit
;;
esac
make install |
CC @EchterAgo : does this ring any bells, please? |
In an effort to rule out the RPi being a factor, I recreated the build on an x86 system with Ubuntu 24.04.1 which results in:
|
Thanks for the diligence about multi-platform check. RPi's USB chips were also suspects a few times. But the segfault was reported in several issues recently - so seeing it misbehave differently per platform is at least "most intriguing!" :) CC @EchterAgo again I might at best look at code in a couple of weeks or more, and have no similar APC device to check against. |
@jimklimov Thanks for the reply. I will keep a look out for updates, let me know if there is anything you'd like me to try. |
To add another device: I'm seeing a similar behavior using a Smart-UPS 750 running FW 9.3 on NUT 2.8.2 with libmodbus c02f62b58aa4ce7538e087ef46266d2a048b0bd6.
|
UPDATE: Seems like a practical duplicate of #2289 |
To summarize current findings in one place, we see several similar patterns ending up in driver crash (typically with
** Notably,
Separately from this (maybe... seems similar to first sample above), in the later after-party discussion of original PR #2063 there were at least occasional (fixed by cable re-plug) faults with:
And also an
The I suppose a run with
There are other FD macros nearby, all defined in terms of access to https://stackoverflow.com/questions/22827510/how-to-avoid-bad-fd-set-buffer-overflow-crash suggests there are problems with 1000+ socket/FD numbers, and also reminds to check if there are FD leaks (loops with a FD not closed so another number gets opened and issued for some next operation). Another question is what CC @EchterAgo |
I suppose That's about all I can say for now, lacking a device to test against, time (gotta run in fact), etc. But I really hope the data-dig above can get someone started! |
@jimklimov I can provide you with system. If you want, Please send me a mail. |
@ZerglingGo : thanks I will, but first... @ all : were all those attempts done with the proper NUT setup, drivers running unprivileged by default? That "Resource temporarily unavailable" clue above bothers me since I saw it yesterday. Can you please try running the driver as The hypothesis I'm trying to check here is if permissions for In the debug dumps posted earlier I see |
I guess that should be |
Sorry, yes. Thought about |
https://gist.github.com/ZerglingGo/1cc0d27ae30e26d4000d674b0f7da6ec#file-strace_apc_modbus-log-2 |
On an APC SMT1500C device using the rtu_usb version of libmodbus and a USB cable, reads fail with a timeout.
Since support for USB based APC Modbus is not mainlined, I am building the required RTU_USB version of libmodbus and compiling the main branch of NUT with usb and modbus support per the https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol wiki page. The build appears to be successful but I am not able to at get the apc_modbus driver to communicate with the UPS.
I have attached build logs and included the apc_modbus output below. I have tested the connection using APC's PowerChute program (on a different system) and PowerChute is able to collect all of the ModBus only fields (like load and temperatures, etc). So I am fairly confident it is not a physical connection issue. Also when using the standard Debian bookworm build of NUT I am able to reliably communicate using the usbhid-ups driver but as it only provides a few fields, the Modbus driver is prefered.
Any pointers would be appreciated but I am not sure where to go from here.
NUT configuration indicating the new RTU USB features are included in the NUT build
Using apc_modbus to probe the unit this is the output:
Host Details
ups.conf
upsd.conf
nut.conf
The text was updated successfully, but these errors were encountered: