networkupstools / nut

The Network UPS Tools repository. UPS management protocol Informational RFC 9271 published by IETF at https://www.rfc-editor.org/info/rfc9271 Please star NUT on GitHub, this helps with sponsorships!
https://networkupstools.org/
Other
1.94k stars 346 forks source link

Add support for new APC Modbus protocol #139

Closed aquette closed 11 months ago

aquette commented 10 years ago

From APCUPSD (http://apcupsd.cvs.sourceforge.net/viewvc/apcupsd/apcupsd/ReleaseNotes?pathrev=Release-3_14_11): "APC publicly released documentation[1] on a new UPS control and monitoring protocol, loosely referred to as MODBUS (after the historic industrial control protocol it is based on). The new protocol operates over RS232 serial lines as well as USB connections and is intended to supplement APC's proprietary Microlink protocol. Microlink is not going away, but APC has realized that third parties require access to UPS status and control information. Rather than publicly open Microlink, they have created another protocol to operate along side it.

Many existing Microlink UPSes can be upgraded to support MODBUS via a firmware update. See [2]. Certain older models are not upgradeable. APC support will be your best contact for determining if your UPS supports a MODBUS upgrade the information linked below does not make it clear."

[1] http://www.apc.com/whitepaper/?an=176 [2] http://www.schneider-electric.us/support/index?page=content&country=ITB&lang=EN&id=FA164737 [3] http://www.apcupsd.com/manual/manual.html


Add support for MODBUS over RS232 and USB in NUT. This effort must be synchronized with the general Modbus support in NUT ( #50 )


Implementation notes:

EchterAgo commented 1 year ago

I already had a look and apcupsd is definitely useful as a reference.

I have a basic driver working now but there still are some things to do:

Edit: List removed, see https://github.com/networkupstools/nut/pull/2063

4.141348 [D5] send_to_all: SETINFO input.voltage "248" :)

EchterAgo commented 1 year ago

I opened a draft PR with my current changes in #2063

This still needs quite a bit of work but I wanted to share it to get some early feedback. Currently it only reads the input voltage.

EchterAgo commented 1 year ago

If someone wants to test #2063, it is already very usable for tests. If you have issues, please send feedback. Also if you have questions about how to get the code compiled. At the moment I have some time and can make adjustments quickly.

EchterAgo commented 12 months ago

If anyone here wants to have their APC Modbus UPS supported by the driver in #2063, please at least post their USB VID/PID, ideally test the driver. I can help with compilation and how to test it.

WiredWonder commented 12 months ago

I have an hid-generic 0003:051D:0003.0001: hiddev0,hidraw0: USB HID v1.00 Device [American Power Conversion Smart-UPS X 750 FW:UPS 10.1 / ID=20] Which is reported by lsusb as Bus 001 Device 003: ID 051d:0003 American Power Conversion UPS

Happy to test if you can give us some instructions 👍

EchterAgo commented 12 months ago

Thanks @galapogos01, that is the same 051d:0003 as I have.

To test you need to build the software, on systems like Debian/Ubuntu you need to make sure that you have a compiler by installing the build-essential package, also you need git and the libusb-1.0-0-dev development headers.

To compile my libmodbus changes you need something like this:

git clone -b rtu_usb https://github.com/EchterAgo/libmodbus.git libmodbus
cd libmodbus
mkdir prefix
./autogen.sh
./configure --prefix=$(pwd)/prefix
make -j$(nproc) install

To build nut you can do it like this (change /path/to/libmodbus to your libmodbus directory):

git clone -b apc_modbus https://github.com/EchterAgo/nut.git nut
cd nut
./autogen.sh
./configure --with-drivers=usbhid-ups,apc_modbus --with-usb --prefix=$(pwd)/prefix --with-modbus --with-modbus-includes=-I/path/to/libmodbus/prefix/include/modbus --with-modbus-libs="-L/path/to/libmodbus/prefix/lib -lmodbus"
make -j$(nproc)
mkdir -p $(pwd)/prefix/state

After that you should be able to create a new ups.conf in the prefix:

cat > $(pwd)/prefix/ups.conf << EOF
[modbus]
    driver = apc_modbus
    port = auto
    vendorid = 051d
EOF

If everything went right you should be able to start the driver:

NUT_DEBUG_LEVEL=5 NUT_CONFPATH=/path/to/nut/prefix NUT_STATEPATH=/path/to/nut/prefix/state /path/to/nut/drivers/apc_modbus -F -a modbus

This should give output like this:

Network UPS Tools - NUT APC Modbus driver 0.01 (2.8.0-2567-gdd2c0f4f7)
Debug level is 0, dump data count is off, but backgrounding mode requested as off
Defaulting debug verbosity to NUT_DEBUG_LEVEL=5 since none was requested by command-line options
   0.000030     [D1] Network UPS Tools version 2.8.0-2567-gdd2c0f4f7 (release/snapshot of 2.8.0.1) built with gcc (Ubuntu 12.3.0-1ubuntu1~23.04) 12.3.0 and configured with flags: --with-drivers=usbhid-ups,apc_modbus --with-usb --prefix=/home/ago/src/nut/prefix --with-modbus --with-modbus-includes=-I/home/ago/src/libmodbus/prefix/include/modbus --with-modbus-libs='-L/home/ago/src/libmodbus/prefix/lib -lmodbus' CPPFLAGS=-DDEBUG CFLAGS='-g -O0'
   0.000067     [D1] debug level is '5'
   0.000085     [D5] send_to_all: SETINFO driver.debug "5"
   0.000104     [D5] send_to_all: SETFLAGS driver.debug RW NUMBER
   0.000358     [D1] Can not become_user(nobody): not root initially, remaining UID=1000 GID=1000
   0.000391     [D5] send_to_all: SETINFO device.type "ups"
   0.000403     [D5] send_to_all: SETINFO driver.state "init.device"
   0.012305     [D2] Checking device 1 of 13 (0557/2419)
   0.012335     [D1] Failed to open device (0557/2419), skipping: Access denied (insufficient permissions)
   0.012342     [D2] Checking device 2 of 13 (0557/7000)
   0.012356     [D1] Failed to open device (0557/7000), skipping: Access denied (insufficient permissions)
   0.012364     [D2] Checking device 3 of 13 (1D6B/0002)
   0.012373     [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions)
   0.012379     [D2] Checking device 4 of 13 (1D6B/0003)
   0.012389     [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions)
   0.012400     [D2] Checking device 5 of 13 (1D6B/0003)
   0.012413     [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions)
   0.012417     [D2] Checking device 6 of 13 (1D6B/0002)
   0.012430     [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions)
   0.012434     [D2] Checking device 7 of 13 (1D6B/0003)
   0.012443     [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions)
   0.012450     [D2] Checking device 8 of 13 (1D6B/0002)
   0.012461     [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions)
   0.012466     [D2] Checking device 9 of 13 (1D6B/0003)
   0.012477     [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions)
   0.012484     [D2] Checking device 10 of 13 (1D6B/0002)
   0.012494     [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions)
   0.012500     [D2] Checking device 11 of 13 (1D6B/0003)
   0.012510     [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions)
   0.012519     [D2] Checking device 12 of 13 (051D/0003)
   0.013971     [D2] - VendorID: 051d
   0.013979     [D2] - ProductID: 0003
   0.013982     [D2] - Manufacturer: American Power Conversion 
   0.013985     [D2] - Product: Smart-UPS 1500 FW:UPS 09.6 / ID=18
   0.013989     [D2] - Serial Number: 3S1545X03212  
   0.013992     [D2] - Bus: 001
   0.013995     [D2] - Bus Port: 002
   0.013998     [D2] - Device: 002
   0.014001     [D2] - Device release number: 0106
   0.014003     [D2] Trying to match device
   0.014007     [D3] match_function_regex: matching a device...
   0.014058     [D2] Device matches
   0.014064     [D2] Reading first configuration descriptor
   0.014070     [D3] libusb_kernel_driver_active() returned 0: Success
   0.014091     [D2] Claimed interface 0 successfully
   0.014095     [D3] nut_usb_set_altinterface: skipped libusb_set_interface_alt_setting(udev, 0, 0)
   0.014343     [D2] Retrieved HID descriptor (expected 9, got 9)
   0.014352     [D3] HID descriptor, method 1: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.014358     [D3] HID descriptor length (method 1) 515
   0.014361     [D4] i=0, extra[i]=09, extra[i+1]=21
   0.014368     [D3] HID descriptor, method 2: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.014376     [D3] HID descriptor length (method 2) 515
   0.014385     [D2] HID descriptor length 515
   0.015778     [D5] send_to_all: SETINFO ups.vendorid "051d"
   0.015787     [D5] send_to_all: SETINFO ups.productid "0003"
   0.015791     [D2] Report descriptor retrieved (Reportlen = 515)
   0.015794     [D2] Found HID device
   0.015807     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.015813     [D5] send_to_all: SETINFO driver.version "2.8.0-2567-gdd2c0f4f7"
   0.015817     [D5] send_to_all: SETINFO driver.version.internal "0.01"
   0.015821     [D5] send_to_all: SETINFO driver.name "apc_modbus"
   0.015825     [D5] send_to_all: SETINFO driver.state "init.info"
   0.015832     [D5] send_to_all: SETINFO ups.mfr "American Power Conversion"
   0.115750     [D5] send_to_all: SETINFO ups.firmware "UPS 09.6"
   0.115785     [D5] send_to_all: SETINFO ups.model "Smart-UPS 1500"
   0.115798     [D5] send_to_all: SETINFO ups.serial "bla"
   0.115872     [D5] send_to_all: SETINFO ups.mfr.date "2015-11-06"
   0.115886     [D5] send_to_all: SETINFO battery.date "2022-02-15"
   0.115899     [D5] send_to_all: SETINFO ups.id "APCUPS"
   0.115915     [D5] send_to_all: SETINFO driver.state "init.updateinfo"
   0.179718     [D5] send_to_all: SETINFO input.transfer.reason "AcceptableInput"
   0.259934     [D5] send_to_all: SETINFO battery.runtime "1740"
   0.259965     [D5] send_to_all: SETINFO battery.charge "100.00"
   0.259975     [D5] send_to_all: SETINFO battery.voltage "27.00"
   0.259988     [D5] send_to_all: SETINFO battery.date.maintenance "2025-12-10"
   0.259998     [D5] send_to_all: SETINFO battery.temperature "30.59"
   0.260009     [D5] send_to_all: SETINFO ups.load "24.00"
   0.260019     [D5] send_to_all: SETINFO ups.realpower "24.00"
   0.260029     [D5] send_to_all: SETINFO ups.power "20.09"
   0.260039     [D5] send_to_all: SETINFO output.current "1.31"
   0.260049     [D5] send_to_all: SETINFO output.voltage "233.19"
   0.260059     [D5] send_to_all: SETINFO output.frequency "49.98"
   0.260068     [D5] send_to_all: SETINFO experimental.output.energy "3004903"
   0.260078     [D5] send_to_all: SETINFO input.voltage "231.80"
   0.260092     [D5] send_to_all: SETINFO ups.efficiency "96.0"
   0.260104     [D5] send_to_all: SETINFO ups.timer.shutdown "-1"
   0.260116     [D5] send_to_all: SETINFO ups.timer.start "-1"
   0.260129     [D5] send_to_all: SETINFO ups.timer.reboot "-1"
   0.323784     [D5] send_to_all: SETINFO input.transfer.high "253"
   0.323823     [D5] send_to_all: SETINFO input.transfer.low "207"
   0.323838     [D5] send_to_all: SETINFO ups.delay.shutdown "0"
   0.323855     [D5] send_to_all: SETINFO ups.delay.start "0"
   0.323874     [D5] send_to_all: SETINFO ups.delay.reboot "8"
   0.323898     [D5] send_to_all: SETINFO ups.status "OL HE"
   0.323909     [D5] send_to_all: DATAOK
   0.323926     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.324301     [D2] dstate_init: sock /home/ago/src/nut/prefix/state/apc_modbus-modbus open on fd 9
   0.324323     [D5] send_to_all: SETINFO driver.parameter.pollinterval "2"
   0.324336     [D5] send_to_all: SETINFO driver.parameter.synchronous "auto"
   0.324351     [D5] send_to_all: SETINFO device.mfr "American Power Conversion"
   0.324364     [D5] send_to_all: SETINFO device.model "Smart-UPS 1500"
   0.324377     [D5] send_to_all: SETINFO device.serial "bla"
   0.324387     Running as foreground process, not saving a PID file
   0.324399     [D5] send_to_all: SETINFO driver.flag.allow_killpower "0"
   0.324410     [D5] send_to_all: SETFLAGS driver.flag.allow_killpower RW NUMBER
fastcat commented 12 months ago

I have the same VID/PID:

  idVendor           0x051d American Power Conversion
  idProduct          0x0003 UPS
  iManufacturer           1 American Power Conversion 
  iProduct                2 Smart-UPS_1500 FW:UPS 03.5 / ID=1018

I'll try to build & test soon, thanks for the nicely summarized instructions on that :)

pjcreath commented 12 months ago

I have the same, with slightly different firmware:

  idVendor = 0x051d 
  idProduct = 0x0003 
  iManufacturer = 0x0001  <American Power Conversion >
  iProduct = 0x0002  <Smart-UPS 1500 FW:UPS 09.3 / ID=18>
electrofloat commented 12 months ago
ups.vendorid: 051d
ups.productid: 0002
ups.mfr: American Power Conversion
ups.firmware: 857.L7 .I
ups.model: Back-UPS RS 550G
EchterAgo commented 12 months ago

@fastcat you probably have to update the firmware for modbus support.

@pjcreath thanks, that should work for modbus already.

@electrofloat I don't think the Back-UPS line has modbus support. You could try dumping the HID descriptor to see if the modbus usages exist.

fastcat commented 12 months ago

@fastcat you probably have to update the firmware for modbus support.

Hooray :( Is this even possible from Linux without hooking it up to APC's cloud services? APC's site that I found suggests that they only support this from Windows.

I had naively assumed that it "must" support modbus since the usbhid mode is so deficient compared to what it can monitor on its front panel and thus I assume what APC's proprietary software can somehow monitor.

EchterAgo commented 12 months ago

@fastcat you probably have to update the firmware for modbus support.

Hooray :( Is this even possible from Linux without hooking it up to APC's cloud services? APC's site that I found suggests that they only support this from Windows.

I had naively assumed that it "must" support modbus since the usbhid mode is so deficient compared to what it can monitor on its front panel and thus I assume what APC's proprietary software can somehow monitor.

I don't really know, I updated mine using Windows. I'm not even sure anymore that it can be updated for modbus, SPD_MPAO-98KJ7F_EN says this:

only SMT models running firmware greater than UPS 09.0 are supported. SMT models with UPS 08.0 or higher may be updated

EchterAgo commented 12 months ago

Although https://www.apc.com/us/en/faqs/FA402663/ says:

SMT Smart Connected UPS with firmware 4.1 or above will communicate via Modbus over Serial and USB.

EchterAgo commented 12 months ago

https://community.se.com/t5/APC-UPS-Data-Center-Enterprise/SMT1500-firmware-update/td-p/297414

So the < V8 UPS use some undocumented "Microlink" protocol and can not be updated to a Modbus firmware.

PrplHaz4 commented 12 months ago
Bus 002 Device 004: ID 051d:0003 American Power Conversion UPS  
  idVendor           0x051d American Power Conversion
  idProduct          0x0003 UPS
  iManufacturer           1 American Power Conversion
  iProduct                2 Smart-UPS 1500 FW:UPS 09.4 / ID=18
hid-generic 0003:051D:0003.0001: hiddev0,hidraw0: USB HID v1.00 Device [American Power Conversion  Smart-UPS X 1500 FW:UPS 15.0 / ID=20] on usb-0000:00:14.0-6/input0

Bus 001 Device 003: ID 051d:0003 American Power Conversion UPS
  idVendor           0x051d American Power Conversion
  idProduct          0x0003 UPS
  iManufacturer           1 American Power Conversion 
  iProduct                2 Smart-UPS X 1500 FW:UPS 15.0 / ID=20
jimklimov commented 12 months ago

FWIW, somewhere in issue reports (or ML?) I've seen a productid 0x0004 and added nominal usbhid-ups support for it a year or so ago. Apparently there a firmware bump on a device bumped the device identifier too (sort of makes sense if it is from now on communicating differently).

EchterAgo commented 12 months ago

Maybe we should not limit the acceptable VID / PID combinations when the user explicitly specifies both? Is there any driver that does similar?

EchterAgo commented 12 months ago

@PrplHaz4 thanks, both of those should work, it would be interesting to test the X version because it has a higher firmware version than mine (9.x)

5ft24dave commented 12 months ago

idVendor 0x051d American Power Conversion idProduct 0x0002 Uninterruptible Power Supply bcdDevice 0.90 iManufacturer 1 American Power Conversion iProduct 2 Back-UPS XS 1000M FW:945.d9 .D USB FW:d9

On Fri, Sep 29, 2023 at 12:35 AM Axel Gembe @.***> wrote:

If anyone here wants to have their APC Modbus UPS supported by the driver in #2063 https://github.com/networkupstools/nut/pull/2063, please at least post their USB VID/PID, ideally test the driver. I can help with compilation and how to test it.

— Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/139#issuecomment-1740440264, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI77WUBKODXT5I4SL7SQ6ZLX4Z235ANCNFSM4ASFATPQ . You are receiving this because you commented.Message ID: @.***>

5ft24dave commented 12 months ago

trying to compile the libmodbus changes I am getting the following:

@.**:~/libmodbus $ ./autogen.shconfigure.ac:76 http://configure.ac:76: error: possibly undefined macro: LT_INIT If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation.autoreconf: /usr/bin/autoconf failed with exit status: 1

On Fri, Sep 29, 2023 at 1:18 AM Axel Gembe @.***> wrote:

Thanks @galapogos01 https://github.com/galapogos01, that is the same 051d:0003 as I have.

To test you need to build the software, on systems like Debian/Ubuntu you need to make sure that you have a compiler by installing the build-essential package, also you need git and the libusb-1.0-0-dev development headers.

To compile my libmodbus changes you need something like this:

git clone -b rtu_usb https://github.com/EchterAgo/libmodbus.git libmodbus cd libmodbus mkdir prefix ./autogen.sh ./configure --prefix=$(pwd)/prefix make -j$(nproc) install

To build nut you can do it like this (change /path/to/libmodbus to your libmodbus directory):

git clone -b apc_modbus https://github.com/EchterAgo/nut.git nut ./autogen.sh ./configure --with-drivers=usbhid-ups,apc_modbus --with-usb --prefix=$(pwd)/prefix --with-modbus --with-modbus-includes=-I/path/to/libmodbus/prefix/include/modbus --with-modbus-libs="-L/path/to/libmodbus/prefix/lib -lmodbus" make -j$(nproc) mkdir -p $(pwd)/prefix/state

After that you should be able to create a new ups.conf in the prefix:

cat > $(pwd)/prefix/ups.conf << EOF [modbus] driver = apc_modbus port = auto vendorid = 051d EOF

If everything went right you should be able to start the driver:

NUT_DEBUG_LEVEL=5 NUT_CONFPATH=/path/to/nut/prefix NUT_STATEPATH=/path/to/nut/prefix/state /path/to/nut/drivers/apc_modbus -F -a modbus

This should give output like this:

Network UPS Tools - NUT APC Modbus driver 0.01 (2.8.0-2567-gdd2c0f4f7) Debug level is 0, dump data count is off, but backgrounding mode requested as off Defaulting debug verbosity to NUT_DEBUG_LEVEL=5 since none was requested by command-line options 0.000030 [D1] Network UPS Tools version 2.8.0-2567-gdd2c0f4f7 (release/snapshot of 2.8.0.1) built with gcc (Ubuntu 12.3.0-1ubuntu1~23.04) 12.3.0 and configured with flags: --with-drivers=usbhid-ups,apc_modbus --with-usb --prefix=/home/ago/src/nut/prefix --with-modbus --with-modbus-includes=-I/home/ago/src/libmodbus/prefix/include/modbus --with-modbus-libs='-L/home/ago/src/libmodbus/prefix/lib -lmodbus' CPPFLAGS=-DDEBUG CFLAGS='-g -O0' 0.000067 [D1] debug level is '5' 0.000085 [D5] send_to_all: SETINFO driver.debug "5" 0.000104 [D5] send_to_all: SETFLAGS driver.debug RW NUMBER 0.000358 [D1] Can not become_user(nobody): not root initially, remaining UID=1000 GID=1000 0.000391 [D5] send_to_all: SETINFO device.type "ups" 0.000403 [D5] send_to_all: SETINFO driver.state "init.device" 0.012305 [D2] Checking device 1 of 13 (0557/2419) 0.012335 [D1] Failed to open device (0557/2419), skipping: Access denied (insufficient permissions) 0.012342 [D2] Checking device 2 of 13 (0557/7000) 0.012356 [D1] Failed to open device (0557/7000), skipping: Access denied (insufficient permissions) 0.012364 [D2] Checking device 3 of 13 (1D6B/0002) 0.012373 [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions) 0.012379 [D2] Checking device 4 of 13 (1D6B/0003) 0.012389 [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions) 0.012400 [D2] Checking device 5 of 13 (1D6B/0003) 0.012413 [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions) 0.012417 [D2] Checking device 6 of 13 (1D6B/0002) 0.012430 [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions) 0.012434 [D2] Checking device 7 of 13 (1D6B/0003) 0.012443 [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions) 0.012450 [D2] Checking device 8 of 13 (1D6B/0002) 0.012461 [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions) 0.012466 [D2] Checking device 9 of 13 (1D6B/0003) 0.012477 [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions) 0.012484 [D2] Checking device 10 of 13 (1D6B/0002) 0.012494 [D1] Failed to open device (1D6B/0002), skipping: Access denied (insufficient permissions) 0.012500 [D2] Checking device 11 of 13 (1D6B/0003) 0.012510 [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions) 0.012519 [D2] Checking device 12 of 13 (051D/0003) 0.013971 [D2] - VendorID: 051d 0.013979 [D2] - ProductID: 0003 0.013982 [D2] - Manufacturer: American Power Conversion 0.013985 [D2] - Product: Smart-UPS 1500 FW:UPS 09.6 / ID=18 0.013989 [D2] - Serial Number: 3S1545X03212 0.013992 [D2] - Bus: 001 0.013995 [D2] - Bus Port: 002 0.013998 [D2] - Device: 002 0.014001 [D2] - Device release number: 0106 0.014003 [D2] Trying to match device 0.014007 [D3] match_function_regex: matching a device... 0.014058 [D2] Device matches 0.014064 [D2] Reading first configuration descriptor 0.014070 [D3] libusb_kernel_driver_active() returned 0: Success 0.014091 [D2] Claimed interface 0 successfully 0.014095 [D3] nut_usb_set_altinterface: skipped libusb_set_interface_alt_setting(udev, 0, 0) 0.014343 [D2] Retrieved HID descriptor (expected 9, got 9) 0.014352 [D3] HID descriptor, method 1: (9 bytes) => 09 21 00 01 21 01 22 03 02 0.014358 [D3] HID descriptor length (method 1) 515 0.014361 [D4] i=0, extra[i]=09, extra[i+1]=21 0.014368 [D3] HID descriptor, method 2: (9 bytes) => 09 21 00 01 21 01 22 03 02 0.014376 [D3] HID descriptor length (method 2) 515 0.014385 [D2] HID descriptor length 515 0.015778 [D5] send_to_all: SETINFO ups.vendorid "051d" 0.015787 [D5] send_to_all: SETINFO ups.productid "0003" 0.015791 [D2] Report descriptor retrieved (Reportlen = 515) 0.015794 [D2] Found HID device 0.015807 [D5] send_to_all: SETINFO driver.state "init.quiet" 0.015813 [D5] send_to_all: SETINFO driver.version "2.8.0-2567-gdd2c0f4f7" 0.015817 [D5] send_to_all: SETINFO driver.version.internal "0.01" 0.015821 [D5] send_to_all: SETINFO driver.name "apc_modbus" 0.015825 [D5] send_to_all: SETINFO driver.state "init.info" 0.015832 [D5] send_to_all: SETINFO ups.mfr "American Power Conversion" 0.115750 [D5] send_to_all: SETINFO ups.firmware "UPS 09.6" 0.115785 [D5] send_to_all: SETINFO ups.model "Smart-UPS 1500" 0.115798 [D5] send_to_all: SETINFO ups.serial "bla" 0.115872 [D5] send_to_all: SETINFO ups.mfr.date "2015-11-06" 0.115886 [D5] send_to_all: SETINFO battery.date "2022-02-15" 0.115899 [D5] send_to_all: SETINFO ups.id "APCUPS" 0.115915 [D5] send_to_all: SETINFO driver.state "init.updateinfo" 0.179718 [D5] send_to_all: SETINFO input.transfer.reason "AcceptableInput" 0.259934 [D5] send_to_all: SETINFO battery.runtime "1740" 0.259965 [D5] send_to_all: SETINFO battery.charge "100.00" 0.259975 [D5] send_to_all: SETINFO battery.voltage "27.00" 0.259988 [D5] send_to_all: SETINFO battery.date.maintenance "2025-12-10" 0.259998 [D5] send_to_all: SETINFO battery.temperature "30.59" 0.260009 [D5] send_to_all: SETINFO ups.load "24.00" 0.260019 [D5] send_to_all: SETINFO ups.realpower "24.00" 0.260029 [D5] send_to_all: SETINFO ups.power "20.09" 0.260039 [D5] send_to_all: SETINFO output.current "1.31" 0.260049 [D5] send_to_all: SETINFO output.voltage "233.19" 0.260059 [D5] send_to_all: SETINFO output.frequency "49.98" 0.260068 [D5] send_to_all: SETINFO experimental.output.energy "3004903" 0.260078 [D5] send_to_all: SETINFO input.voltage "231.80" 0.260092 [D5] send_to_all: SETINFO ups.efficiency "96.0" 0.260104 [D5] send_to_all: SETINFO ups.timer.shutdown "-1" 0.260116 [D5] send_to_all: SETINFO ups.timer.start "-1" 0.260129 [D5] send_to_all: SETINFO ups.timer.reboot "-1" 0.323784 [D5] send_to_all: SETINFO input.transfer.high "253" 0.323823 [D5] send_to_all: SETINFO input.transfer.low "207" 0.323838 [D5] send_to_all: SETINFO ups.delay.shutdown "0" 0.323855 [D5] send_to_all: SETINFO ups.delay.start "0" 0.323874 [D5] send_to_all: SETINFO ups.delay.reboot "8" 0.323898 [D5] send_to_all: SETINFO ups.status "OL HE" 0.323909 [D5] send_to_all: DATAOK 0.323926 [D5] send_to_all: SETINFO driver.state "init.quiet" 0.324301 [D2] dstate_init: sock /home/ago/src/nut/prefix/state/apc_modbus-modbus open on fd 9 0.324323 [D5] send_to_all: SETINFO driver.parameter.pollinterval "2" 0.324336 [D5] send_to_all: SETINFO driver.parameter.synchronous "auto" 0.324351 [D5] send_to_all: SETINFO device.mfr "American Power Conversion" 0.324364 [D5] send_to_all: SETINFO device.model "Smart-UPS 1500" 0.324377 [D5] send_to_all: SETINFO device.serial "3S1545X03212" 0.324387 Running as foreground process, not saving a PID file 0.324399 [D5] send_to_all: SETINFO driver.flag.allow_killpower "0" 0.324410 [D5] send_to_all: SETFLAGS driver.flag.allow_killpower RW NUMBER

— Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/139#issuecomment-1740495493, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI77WUCYMZHAO5MUOSFHUO3X4Z75RANCNFSM4ASFATPQ . You are receiving this because you commented.Message ID: @.***>

EchterAgo commented 12 months ago

@5ft24dave that is unrelated to my changes, some missing build dependency. I don't understand why error messages of the autoconf packages are so terrible, but it seems you are missing libtool :\ Did you install build-essential? Also try installing libtool.

5ft24dave commented 12 months ago

yes, build-essential is installed. I'll manually see if libtool is installed. it's on a raspberry pi, so it may have a few gotchas for me

On Fri, Sep 29, 2023 at 1:25 PM Axel Gembe @.***> wrote:

@5ft24dave https://github.com/5ft24dave that is unrelated to my changes, some missing build dependency. I don't understand why error messages of the autoconf packages are so terrible, but it seems you are missing libtool :\ Did you install build-essential?

— Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/139#issuecomment-1741450260, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI77WUB6UTECYGQCVNHZMSDX44VERANCNFSM4ASFATPQ . You are receiving this because you were mentioned.Message ID: @.***>

5ft24dave commented 12 months ago

@5ft24dave that is unrelated to my changes, some missing build dependency. I don't understand why error messages of the autoconf packages are so terrible, but it seems you are missing libtool :\ Did you install build-essential? Also try installing libtool.

that's what it was missing libtool.

EchterAgo commented 11 months ago

@5ft24dave I think yours does not support Modbus, but if you want to give it a try you can change the _apc_modbus_usb_device_match_func function to match PID 2. I think it will fail the _apc_modbus_usb_callback check though.

It would be helpful to include HID dumps from usb-hidups, you can dump it like this:

NUT_STATEPATH=/tmp ./drivers/usbhid-ups -s usb -x port=auto -x vendorid=051d -DDD -F -d 1

If it includes ff8600fc / ff8600fd then it does support USB Modbus.

EchterAgo commented 11 months ago

This is how the USB Modbus report descriptors should look:

$ NUT_STATEPATH=/tmp ./drivers/usbhid-ups -s usb -x port=auto -x vendorid=051d -DDD -F -d1 2>&1 | grep ff8600f[cd]
   0.025317     [D1] Path: UPS.ff8600fd, Type: Input, ReportID: 0x89, Offset: 0, Size: 8
   0.034356     [D1] Path: UPS.ff8600fc, Type: Output, ReportID: 0x90, Offset: 0, Size: 8
5ft24dave commented 11 months ago

I think my usbhid-ups driver may be a little old doesn't support -s Only thing I am missing for monitoring is output voltage...

Network UPS Tools - Generic HID driver 0.41 (2.7.4) USB communication driver 0.33 /usr/lib/nut/usbhid-ups: invalid option -- 's' Error: unknown option -?. Try -h for help.

On Sat, Sep 30, 2023 at 12:16 AM Axel Gembe @.***> wrote:

This is how the USB Modbus report descriptors should look:

$ NUT_STATEPATH=/tmp ./drivers/usbhid-ups -s usb -x port=auto -x vendorid=051d -DDD -F -d1 2>&1 | grep ff8600f[cd] 0.025317 [D1] Path: UPS.ff8600fd, Type: Input, ReportID: 0x89, Offset: 0, Size: 8 0.034356 [D1] Path: UPS.ff8600fc, Type: Output, ReportID: 0x90, Offset: 0, Size: 8

— Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/139#issuecomment-1741701716, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI77WUFWP3RCY2NTGT6MDU3X47BLHANCNFSM4ASFATPQ . You are receiving this because you were mentioned.Message ID: @.***>

jimklimov commented 11 months ago

@5ft24dave : the -s UPSNAME allows to construct a temporary configuration not saved into ups.conf - something NUT always had, then dropped, then remade in this fashion (primarily for probing, not regular runs).

NUT 2.7.4 should have the -a UPSNAME which would refer to a section name from ups.conf and does not require all the -x key=value options (but can use them).

WiredWonder commented 11 months ago

I just gave this a whirl and I am getting a segfault. Happy to provide any other info.

root@debian-vm-64:/home/xxx/software/nut# NUT_DEBUG_LEVEL=5 NUT_CONFPATH=/home/xxx/software/nut/prefix NUT_STATEPATH=/home/xxx/software/prefix/state /home/xxx/software/nut/drivers/apc_modbus -F -a modbus
Network UPS Tools - NUT APC Modbus driver 0.01 (2.8.0.1)
Debug level is 0, dump data count is off, but backgrounding mode requested as off
Defaulting debug verbosity to NUT_DEBUG_LEVEL=5 since none was requested by command-line options
   0.000019     [D1] Network UPS Tools version 2.8.0.1 (release/snapshot of 2.8.0.1) built with gcc (Debian 10.2.1-6) 10.2.1 20210110 and configured with flags: --with-drivers=usbhid-ups,apc_modbus --with-usb --prefix=/home/xxx/software/nut/prefix --with-modbus --with-modbus-includes=-I/home/xxx/software/libmodbus/prefix/include/modbus --with-modbus-libs='-L/home/xxx/software/libmodbus/prefix/lib -lmodbus'
   0.000028     [D1] debug level is '5'
   0.000123     [D5] send_to_all: SETINFO driver.debug "5"
   0.000216     [D5] send_to_all: SETFLAGS driver.debug RW NUMBER
   0.000840     [D1] Succeeded to become_user(nobody): now UID=65534 GID=65534
   0.000947     [D5] send_to_all: SETINFO device.type "ups"
   0.000973     [D5] send_to_all: SETINFO driver.state "init.device"
   0.047759     [D3] usb_busses=0x5645af8c1350
   0.047778     [D2] Checking device (051D/0003) (002/004)
   0.062395     [D2] - VendorID: 051d
   0.062410     [D2] - ProductID: 0003
   0.062414     [D2] - Manufacturer: American Power Conversion
   0.062417     [D2] - Product: Smart-UPS X 750 FW:UPS 10.1 / ID=20
   0.062421     [D2] - Serial Number: AS1512116290
   0.062424     [D2] - Bus: 002
   0.062427     [D2] - Device: 004
   0.062431     [D2] - Device release number: 0106
   0.062434     [D2] Trying to match device
   0.062542     [D3] match_function_regex: matching a device...
   0.062636     [D2] Device matches
   0.062719     [D3] nut_usb_set_altinterface: skipped usb_set_altinterface(udev, 0)
   0.063599     [D2] Retrieved HID descriptor (expected 9, got 9)
   0.063625     [D3] HID descriptor, method 1: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.063714     [D3] HID descriptor length (method 1) 515
   0.063732     [D4] i=0, extra[i]=09, extra[i+1]=21
   0.063736     [D3] HID descriptor, method 2: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.063804     [D3] HID descriptor length (method 2) 515
   0.063830     [D2] HID descriptor length 515
   0.065740     [D5] send_to_all: SETINFO ups.vendorid "051d"
   0.065935     [D5] send_to_all: SETINFO ups.productid "0003"
   0.066077     [D2] Report descriptor retrieved (Reportlen = 515)
   0.066258     [D2] Found HID device
   0.066477     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.066628     [D5] send_to_all: SETINFO driver.version "2.8.0.1"
   0.066878     [D5] send_to_all: SETINFO driver.version.internal "0.01"
   0.067062     [D5] send_to_all: SETINFO driver.name "apc_modbus"
   0.067282     [D5] send_to_all: SETINFO driver.state "init.info"
   0.067447     [D5] send_to_all: SETINFO ups.mfr "American Power Conversion"
Segmentation fault

edit:

I pulled latest changes and got this

Network UPS Tools - NUT APC Modbus driver 0.01 (2.8.0.1)
Debug level is 0, dump data count is off, but backgrounding mode requested as off
Defaulting debug verbosity to NUT_DEBUG_LEVEL=5 since none was requested by command-line options
   0.000278     [D1] Network UPS Tools version 2.8.0.1 (release/snapshot of 2.8.0.1) built with gcc (Debian 10.2.1-6) 10.2.1 20210110 and configured with flags: --with-drivers=usbhid-ups,apc_modbus --with-usb --prefix=/home/xxx/software/nut/prefix --with-modbus --with-modbus-includes=-I/home/xxx/software/libmodbus/prefix/include/modbus --with-modbus-libs='-L/home/xxx/software/libmodbus/prefix/lib -lmodbus'
   0.000502     [D1] debug level is '5'
   0.000578     [D5] send_to_all: SETINFO driver.debug "5"
   0.000650     [D5] send_to_all: SETFLAGS driver.debug RW NUMBER
   0.001204     [D1] Succeeded to become_user(nobody): now UID=65534 GID=65534
   0.001420     [D5] send_to_all: SETINFO device.type "ups"
   0.001498     [D5] send_to_all: SETINFO driver.state "init.device"
   0.046299     [D3] usb_busses=0x55ea6abd3350
   0.046588     [D2] Checking device (051D/0003) (002/004)
   0.061105     [D2] - VendorID: 051d
   0.061243     [D2] - ProductID: 0003
   0.061389     [D2] - Manufacturer: American Power Conversion
   0.061487     [D2] - Product: Smart-UPS X 750 FW:UPS 10.1 / ID=20
   0.061639     [D2] - Serial Number: AS1512116290
   0.061776     [D2] - Bus: 002
   0.061895     [D2] - Device: 004
   0.062003     [D2] - Device release number: 0106
   0.062073     [D2] Trying to match device
   0.062172     [D3] match_function_regex: matching a device...
   0.062292     [D2] Device matches
   0.062392     [D3] nut_usb_set_altinterface: skipped usb_set_altinterface(udev, 0)
   0.063359     [D2] Retrieved HID descriptor (expected 9, got 9)
   0.063455     [D3] HID descriptor, method 1: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.063540     [D3] HID descriptor length (method 1) 515
   0.063627     [D4] i=0, extra[i]=09, extra[i+1]=21
   0.063698     [D3] HID descriptor, method 2: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.063796     [D3] HID descriptor length (method 2) 515
   0.063994     [D2] HID descriptor length 515
   0.065673     [D2] _apc_modbus_usb_callback: Checking American Power Conversion  Smart-UPS X 750 FW:UPS 10.1 / ID=20 (USB VID/PID 051d:0003) report descriptors
   0.065949     [D5] send_to_all: SETINFO ups.vendorid "051d"
   0.066080     [D5] send_to_all: SETINFO ups.productid "0003"
   0.066224     [D2] Report descriptor retrieved (Reportlen = 515)
   0.066368     [D2] Found HID device
Using already open USB handle
   0.066577     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.066692     [D5] send_to_all: SETINFO driver.version "2.8.0.1"
   0.066805     [D5] send_to_all: SETINFO driver.version.internal "0.01"
   0.066921     [D5] send_to_all: SETINFO driver.name "apc_modbus"
   0.067039     [D5] send_to_all: SETINFO driver.state "init.info"
[01][03][02][04][00][58]
Segmentation fault
EchterAgo commented 11 months ago

@5ft24dave You might need to construct a temporary entry in ups.conf for this.

@galapogos01 It seems to crash when sending the command using libmodbus ([01][03][02][04][00][58]). When I compare it to my result I see this:

   0.015903     [D2] _apc_modbus_usb_callback: Checking American Power Conversion  Smart-UPS 1500 FW:UPS 09.6 / ID=18 (USB VID/PID 051d:0003) report descriptors
   0.016001     [D5] send_to_all: SETINFO ups.vendorid "051d"
   0.016007     [D5] send_to_all: SETINFO ups.productid "0003"
   0.016011     [D2] Report descriptor retrieved (Reportlen = 515)
   0.016014     [D2] Found HID device
Using already open USB handle
   0.016037     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.016043     [D5] send_to_all: SETINFO driver.version "2.8.0-2559-g25508bd8f"
   0.016048     [D5] send_to_all: SETINFO driver.version.internal "0.01"
   0.016052     [D5] send_to_all: SETINFO driver.name "apc_modbus"
   0.016056     [D5] send_to_all: SETINFO driver.state "init.info"
[01][03][02][04][00][58]
Waiting for a confirmation...
<01><03><B0><00><00><00><00>...<cut>

I'll see if I can figure something out. Did you also update libmodbus to the latest changes? I think it was missing some NULL checks somewhere that I recently added.

EchterAgo commented 11 months ago

I don't think it is the missing NULL check, Using already open USB handle indicates that the device handle is not NULL.

It would be very helpful if we could get a coredump or run the driver in gdb.

5ft24dave commented 11 months ago

@5ft24dave I think yours does not support Modbus, but if you want to give it a try you can change the _apc_modbus_usb_device_match_func function to match PID 2. I think it will fail the _apc_modbus_usb_callback check though.

It would be helpful to include HID dumps from usb-hidups, you can dump it like this:

NUT_STATEPATH=/tmp ./drivers/usbhid-ups -s usb -x port=auto -x vendorid=051d -DDD -F -d 1

If it includes ff8600fc / ff8600fd then it does support USB Modbus.

definitely doesn't support modbus. oh well

WiredWonder commented 11 months ago

@EchterAgo Yes I built the latest libmodbus changes as well in my second run. Nut is e7c519d0 and libmodbus is e676e37

Can provide either if you can give me a hand?

EchterAgo commented 11 months ago

@EchterAgo Yes I built the latest libmodbus changes as well in my second run. Nut is e7c519d and libmodbus is e676e37

Can provide either if you can give me a hand?

To produce coredumps you need to check if that is limited using ulimit. If it is limited you can use ulimit -c unlimited to remove the limit. You can also use something like apport on Ubuntu or systemd-coredump on other systems. With systemd-coredump installed you should get a listing for the crash when you execute coredumpctl list. You can then use coredumpctl debug to start gdb with the dump. If you just have the coredump file you can use gdb --core=COREFILE to do the same.

Once in gdb you could start with using bt to get a stack trace at the crash site.

EchterAgo commented 11 months ago

To start directly with gdb attached you can do it like this:

NUT_DEBUG_LEVEL=5 NUT_CONFPATH=/path/to/nut/prefix NUT_STATEPATH=/path/to/nut/prefix/state gdb --args drivers/apc_modbus -F -a modbus

Once it is loaded you can enter run to start debugging. Then once it segfaults you can enter bt to get a stack trace.

WiredWonder commented 11 months ago

Hey,

I managed to get gdb installed, haven't looked into any of the other programs you mentioned. When I run it through gdb I get the following:

   0.000035     [D1] debug level is '5'
   0.000040     [D5] send_to_all: SETINFO driver.debug "5"
   0.000044     [D5] send_to_all: SETFLAGS driver.debug RW NUMBER
   0.009179     [D1] Succeeded to become_user(nobody): now UID=65534 GID=65534
   0.009246     [D5] send_to_all: SETINFO device.type "ups"
   0.009257     [D5] send_to_all: SETINFO driver.state "init.device"
   0.009717     [D3] usb_busses=0x555555583350
   0.009729     [D2] Checking device (051D/0003) (002/005)
   0.024335     [D2] - VendorID: 051d
   0.024370     [D2] - ProductID: 0003
   0.024393     [D2] - Manufacturer: American Power Conversion
   0.024402     [D2] - Product: Smart-UPS X 750 FW:UPS 10.1 / ID=20
   0.024408     [D2] - Serial Number: AS1512116290
   0.024427     [D2] - Bus: 002
   0.024431     [D2] - Device: 005
   0.024449     [D2] - Device release number: 0106
   0.024454     [D2] Trying to match device
   0.024462     [D3] match_function_regex: matching a device...
   0.024520     [D2] Device matches
   0.024536     [D2] failed to claim USB device: could not claim interface 0: Device or resource busy
   0.025461     [D2] detached kernel driver from USB device...
   0.025497     [D3] nut_usb_set_altinterface: skipped usb_set_altinterface(udev, 0)
   0.026638     [D2] Retrieved HID descriptor (expected 9, got 9)
   0.026653     [D3] HID descriptor, method 1: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.026659     [D3] HID descriptor length (method 1) 515
   0.026665     [D4] i=0, extra[i]=09, extra[i+1]=21
   0.026674     [D3] HID descriptor, method 2: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.026700     [D3] HID descriptor length (method 2) 515
   0.026720     [D2] HID descriptor length 515
   0.028756     [D2] _apc_modbus_usb_callback: Checking American Power Conversion  Smart-UPS X 750 FW:UPS 10.1 / ID=20 (USB VID/PID 051d:0003) report descriptors
   0.028940     [D5] send_to_all: SETINFO ups.vendorid "051d"
   0.028952     [D5] send_to_all: SETINFO ups.productid "0003"
   0.028959     [D2] Report descriptor retrieved (Reportlen = 515)
   0.028965     [D2] Found HID device
Using already open USB handle
   0.029020     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.029028     [D5] send_to_all: SETINFO driver.version "2.8.0.1"
   0.029058     [D5] send_to_all: SETINFO driver.version.internal "0.01"
   0.029065     [D5] send_to_all: SETINFO driver.name "apc_modbus"
   0.029071     [D5] send_to_all: SETINFO driver.state "init.info"
[01][03][02][04][00][58]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b9ced9 in ?? () from /usr/lib/x86_64-linux-gnu/libusb-1.0.so.0
(gdb) l
1592
1593    # ifdef SIGCMD_DATA_DUMP
1594            /* handle run-time data dump (may be limited to non-backgrounding lifetimes) */
1595            sa.sa_handler = handle_dstate_dump;
1596            sigaction(SIGCMD_DATA_DUMP, &sa, NULL); /* SIGURG or SIGWINCH something else on obscure systems */
1597    # endif
1598    }
1599    #endif /* WIN32*/
1600
1601    /* This source file is used in some unit tests to mock realistic driver
(gdb) bt
#0  0x00007ffff7b9ced9 in ?? () from /usr/lib/x86_64-linux-gnu/libusb-1.0.so.0
#1  0x00007ffff7b9d26f in libusb_interrupt_transfer ()
   from /usr/lib/x86_64-linux-gnu/libusb-1.0.so.0
#2  0x00007ffff7fc3575 in _modbus_rtu_usb_send (ctx=<optimized out>,
    req=0x7fffffffdd44 "\001\003\002\004", req_length=<optimized out>) at modbus-rtu-usb.c:101
#3  0x00007ffff7fc0100 in send_msg (ctx=ctx@entry=0x55555557d920,
    msg=msg@entry=0x7fffffffdd44 "\001\003\002\004", msg_length=6) at modbus.c:181
#4  0x00007ffff7fc15ab in read_registers (ctx=ctx@entry=0x55555557d920, function=function@entry=3,
    addr=addr@entry=516, nb=nb@entry=88, dest=dest@entry=0x7fffffffdee0) at modbus.c:1296
#5  0x00007ffff7fc16c3 in modbus_read_registers (ctx=ctx@entry=0x55555557d920,
    addr=addr@entry=516, nb=nb@entry=88, dest=dest@entry=0x7fffffffdee0) at modbus.c:1342
#6  0x000055555555a0d6 in _apc_modbus_read_registers (ctx=0x55555557d920, addr=516, nb=88,
    dest=0x7fffffffdee0) at apc_modbus.c:621
#7  0x000055555555a924 in _apc_modbus_read_inventory () at apc_modbus.c:715
#8  upsdrv_initinfo () at apc_modbus.c:726
#9  0x000055555555912f in main (argc=<optimized out>, argv=<optimized out>) at main.c:2219

Hopefully this gives you enough to go off.

I tried attaching the device to another machine and running it there, I got a different error.

[01][03][02][04][00][58]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
   0.527772     _apc_modbus_read_registers: Read of 516:604 failed: Resource temporarily unavailable (auto)
   0.527803     Can't read inventory information from the UPS
   0.527848     [D5] send_to_all: SETINFO driver.state "cleanup.upsdrv"
   0.528719     [D5] send_to_all: SETINFO driver.state "cleanup.exit"
EchterAgo commented 11 months ago

Hmm, it seems to fail inside libusb somehow.

You could try adding a return 1 early in _apc_modbus_read_inventory so it doesn't read the inventory information, maybe that needs to be handled differently for your device.

Which Linux distributions are you using to test?

WiredWonder commented 11 months ago

Debian 11.7

EchterAgo commented 11 months ago

https://wiki.debian.org/HowToGetABacktrace#Automatically_loading_debugging_symbols_from_the_Internet

Setting export DEBUGINFOD_URLS="https://debuginfod.debian.net" before gdb should make gdb able to download debug symbols for the libusb package debian uses. I'm not sure if you also need some debuginfod package installed.

I'll look into testing on Debian 11.7 myself too.

WiredWonder commented 11 months ago

OK, I got this far. Seems it can not download debug symbols/source for libusb, but at least gives more detail. Hopefully this adds some colour for you, I am out of time to play around with this.

Program received signal SIGSEGV, Segmentation fault.
do_sync_bulk_transfer (dev_handle=0x555555586460, endpoint=<optimized out>,
    buffer=0x7fffffffdc50 "\220\001\003\002\004", length=length@entry=64,
    transferred=transferred@entry=0x7fffffffdc4c, timeout=timeout@entry=0, type=3 '\003')
    at ../../libusb/sync.c:177
Download failed: Invalid argument.  Continuing without source file ./build-deb/libusb/../../libusb/sync.c.
177     ../../libusb/sync.c: No such file or directory.
(gdb) bt
#0  do_sync_bulk_transfer (dev_handle=0x555555586460, endpoint=<optimized out>,
    buffer=0x7fffffffdc50 "\220\001\003\002\004", length=length@entry=64,
    transferred=transferred@entry=0x7fffffffdc4c, timeout=timeout@entry=0, type=3 '\003')
    at ../../libusb/sync.c:177
#1  0x00007ffff7b9d26f in libusb_interrupt_transfer (dev_handle=<optimized out>,
    endpoint=<optimized out>, data=<optimized out>, length=length@entry=64,
    transferred=transferred@entry=0x7fffffffdc4c, timeout=timeout@entry=0)
    at ../../libusb/sync.c:332
#2  0x00007ffff7fc3575 in _modbus_rtu_usb_send (ctx=<optimized out>,
    req=0x7fffffffdd14 "\001\003\002\004", req_length=<optimized out>) at modbus-rtu-usb.c:101
#3  0x00007ffff7fc0100 in send_msg (ctx=ctx@entry=0x55555557d920,
    msg=msg@entry=0x7fffffffdd14 "\001\003\002\004", msg_length=6) at modbus.c:181
#4  0x00007ffff7fc15ab in read_registers (ctx=ctx@entry=0x55555557d920, function=function@entry=3,
    addr=addr@entry=516, nb=nb@entry=88, dest=dest@entry=0x7fffffffdeb0) at modbus.c:1296
#5  0x00007ffff7fc16c3 in modbus_read_registers (ctx=ctx@entry=0x55555557d920,
    addr=addr@entry=516, nb=nb@entry=88, dest=dest@entry=0x7fffffffdeb0) at modbus.c:1342
#6  0x000055555555a0d6 in _apc_modbus_read_registers (ctx=0x55555557d920, addr=516, nb=88,
    dest=0x7fffffffdeb0) at apc_modbus.c:621
#7  0x000055555555a924 in _apc_modbus_read_inventory () at apc_modbus.c:715
#8  upsdrv_initinfo () at apc_modbus.c:726
#9  0x000055555555912f in main (argc=<optimized out>, argv=<optimized out>) at main.c:2219
(gdb) l
172     in ../../libusb/sync.c
EchterAgo commented 11 months ago

Ok, good to have line numbers, I'll check that.

In libmodbus I included a small test program for APC register reads in tests/apc-test-client.c which compiles to tests/apc-test-client. What happens if you run that? I get something like this:


ago@ares:~/src/libmodbus$ ./tests/apc-test-client 
Opening /dev/ttyUSB0
Number of USB devices: 13
Considering device #0 (0557:2419)
Considering device #1 (0557:7000)
Considering device #2 (1d6b:0002)
Considering device #3 (1d6b:0003)
Considering device #4 (1d6b:0003)
Considering device #5 (1d6b:0002)
Considering device #6 (1d6b:0003)
Considering device #7 (1d6b:0002)
Considering device #8 (1d6b:0003)
Considering device #9 (1d6b:0002)
Considering device #10 (1d6b:0003)
Considering device #11 (051d:0003)
Found Device 11:
  Vendor ID: 0x051d
  Product ID: 0x0003
  Class: 0x00
  Subclass: 0x00
  Protocol: 0x00

[01][03][00][97][00][01]
Waiting for a confirmation...
<01><03><02><39><99>
REG_INPUT_0_VOLTAGE = 14745 (2457.500000 scaled)
[01][03][00][8C][00][01]
Waiting for a confirmation...
<01><03><02><00><28>
REG_OUTPUT_0_CURRENT = 40 (8.000000 scaled)
[01][03][02][34][00][08]
Waiting for a confirmation...
<01><03><10>bla<00><00>
REG_SERIAL_NUMBER = "bla  "
[01][03][02][14][00][10]
Waiting for a confirmation...
<01><03><20><53><6D><61><72><74><2D><55><50><53><01><31><35><30><30><20><20><20><20><20><20><20><20><20><20><20><20><20><20><20><20><20><20>
REG_MODEL = "Smart-UPS1500                  "```
EchterAgo commented 11 months ago

From that call stack I'm wondering nut and libmodbus link to different libusb versions.

ldd /path/to/nut/drivers/apc_modbus ldd /path/to/libmodbus/prefix/lib/libmodbus.so

EchterAgo commented 11 months ago

Line 177 in sync.c is if (usbi_handling_events(HANDLE_CTX(dev_handle))), which just gets the context from a device handle. If we fail here it indicates to me that the device handle we passed has a different struct layout than the libusb used by modbus expects.

WiredWonder commented 11 months ago

From that call stack I'm wondering nut and libmodbus link to different libusb versions.

ldd /path/to/nut/drivers/apc_modbus ldd /path/to/libmodbus/prefix/lib/libmodbus.so

Looks like you're right.

root@debian-vm-64:/home/xxx/software# ldd nut/drivers/apc_modbus
        linux-vdso.so.1 (0x00007ffc9eb6a000)
        libmodbus.so.5 => /home/xxx/software/libmodbus/prefix/lib/libmodbus.so.5 (0x00007f7b6170b000)
        libusb-0.1.so.4 => /lib/x86_64-linux-gnu/libusb-0.1.so.4 (0x00007f7b614f3000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7b614d1000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7b612fd000)
        libusb-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f7b612df000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f7b6173e000)
        libudev.so.1 => /usr/lib/x86_64-linux-gnu/libudev.so.1 (0x00007f7b612b7000)
root@debian-vm-64:/home/xxx/software# ldd libmodbus/prefix/lib/libmodbus.so
        linux-vdso.so.1 (0x00007fff4b3fd000)
        libusb-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007fdbe249b000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdbe22c7000)
        libudev.so.1 => /usr/lib/x86_64-linux-gnu/libudev.so.1 (0x00007fdbe229f000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fdbe227d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fdbe24d6000)

Let me know if you have any suggestions on how to correct this!

EchterAgo commented 11 months ago

You should try to recompile nut using a newer libusb. If you don't need libusb-0.1 I would just uninstall it and recompile nut.

Also, please try the tests/apc-test-client test in libmodbus, that code is much simpler.

We should really have a way to detect incompatible libusb versions or we should just not pass libusb handles. For this I'm working on some device selection code in libmodbus that allows us to select a USB device using a unique identifier. Right now I'm thinking of a string that includes the USB bus and all the port numbers up to the device in this format:

BUS-PORT[.PORT][.PORT][.PORT]

EchterAgo commented 11 months ago

I think you can pass --with-usb=libusb-1.0 to the nut configure script and it should use libusb 1.0.

WiredWonder commented 11 months ago

Strangely, I had libusb-1.0 installed

sudo aptitude search libusb-1.0                       
i A libusb-1.0-0                              - userspace USB programming library
i   libusb-1.0-0-dev                          - userspace USB programming library development fil

but nut wouldn't find it, even when I removed 0.1

configure: can not check libusb settings via pkg-config
checking for libusb-config... no
checking for libusb preferred version... none
configure: WARNING: Defaulting libusb configuration
checking for libusb cflags...
checking for libusb ldflags... -lusb
checking for usb.h... no
checking for usb_init... no
configure: error: USB drivers requested, but libusb not found.

Installing pkg-config got it compiling.

Now I get the same error as the other machine:

[01][03][02][04][00][58]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
   1.435831     _apc_modbus_read_registers: Read of 516:604 failed: Resource temporarily unavailable (auto)
   1.435839     Can't read inventory information from the UPS
   1.435848     [D5] send_to_all: SETINFO driver.state "cleanup.upsdrv"
   1.436134     [D5] send_to_all: SETINFO driver.state "cleanup.exit"

apc-test-client gives

Opening /dev/ttyUSB0
Number of USB devices: 5
Considering device #0 (1d6b:0002)
Considering device #1 (051d:0003)
Found Device 1:
  Vendor ID: 0x051d
  Product ID: 0x0003
  Class: 0x00
  Subclass: 0x00
  Protocol: 0x00

[01][03][00][97][00][01]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
Register read of 151:152 failed: Resource temporarily unavailable
[01][03][00][8C][00][01]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
Register read of 140:141 failed: Resource temporarily unavailable
[01][03][02][34][00][08]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
Register read of 564:572 failed: Resource temporarily unavailable
[01][03][02][14][00][10]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
Register read of 532:548 failed: Resource temporarily unavailable
EchterAgo commented 11 months ago

@galapogos01 It doesn't seem to receive any response. Did you enable Modbus in your UPS? I remember I had to explicitly enable it, IIRC I was able to do it through the front panel. Does apcupsd with Modbus work?

EchterAgo commented 11 months ago

Ok, I can confirm, when disabling Modbus I get the same behaviour as @galapogos01 is seeing. However that UPS likely supports Modbus, given that it has the USB usages for it.

[01][03][00][97][00][01]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
Register read of 151:152 failed: Resource temporarily unavailable
[01][03][00][8C][00][01]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
Register read of 140:141 failed: Resource temporarily unavailable
[01][03][02][34][00][08]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
Register read of 564:572 failed: Resource temporarily unavailable
[01][03][02][14][00][10]
Waiting for a confirmation...
ERROR Resource temporarily unavailable: select
Register read of 532:548 failed: Resource temporarily unavailable

I think the timeout case here should be better handled than giving Resource temporarily unavailable

EchterAgo commented 11 months ago

Ok, I added proper error handling to libmodbus, it will now give ETIMEDOUT in errno when libusb returns LIBUSB_ERROR_TIMEOUT

WiredWonder commented 11 months ago

Did you enable Modbus in your UPS?

Something so simple! Success:

   0.000118     [D1] debug level is '5'
   0.000149     [D5] send_to_all: SETINFO driver.debug "5"
   0.000176     [D5] send_to_all: SETFLAGS driver.debug RW NUMBER
   0.000890     [D1] Can not become_user(nobody): not root initially, remaining UID=1000 GID=1000
   0.000978     [D5] send_to_all: SETINFO device.type "ups"
   0.001010     [D5] send_to_all: SETINFO driver.state "init.device"
   0.007999     [D2] Checking device 1 of 4 (1D6B/0003)
   0.008083     [D1] Failed to open device (1D6B/0003), skipping: Access denied (insufficient permissions)
   0.008104     [D2] Checking device 2 of 4 (051D/0003)
   0.011495     [D2] - VendorID: 051d
   0.011537     [D2] - ProductID: 0003
   0.011552     [D2] - Manufacturer: American Power Conversion
   0.011566     [D2] - Product: Smart-UPS X 750 FW:UPS 10.1 / ID=20
   0.011581     [D2] - Serial Number: AS15121xxxxx
   0.011595     [D2] - Bus: 001
   0.011609     [D2] - Bus Port: 002
   0.011622     [D2] - Device: 005
   0.011636     [D2] - Device release number: 0106
   0.011650     [D2] Trying to match device
   0.011665     [D3] match_function_regex: matching a device...
   0.011731     [D2] Device matches
   0.011748     [D2] Reading first configuration descriptor
   0.011777     [D3] libusb_kernel_driver_active() returned 0: Success
   0.011837     [D2] Claimed interface 0 successfully
   0.011856     [D3] nut_usb_set_altinterface: skipped libusb_set_interface_alt_setting(udev, 0, 0)
   0.012481     [D2] Retrieved HID descriptor (expected 9, got 9)
   0.012510     [D3] HID descriptor, method 1: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.012531     [D3] HID descriptor length (method 1) 515
   0.012548     [D4] i=0, extra[i]=09, extra[i+1]=21
   0.012567     [D3] HID descriptor, method 2: (9 bytes) => 09 21 00 01 21 01 22 03 02
   0.012606     [D3] HID descriptor length (method 2) 515
   0.012635     [D2] HID descriptor length 515
   0.014409     [D2] _apc_modbus_usb_callback: Checking American Power Conversion  Smart-UPS X 750 FW:UPS 10.1 / ID=20 (USB VID/PID 051d:0003) report descriptors
   0.014637     [D5] send_to_all: SETINFO ups.vendorid "051d"
   0.014666     [D5] send_to_all: SETINFO ups.productid "0003"
   0.014685     [D2] Report descriptor retrieved (Reportlen = 515)
   0.014702     [D2] Found HID device
Using already open USB handle
   0.014769     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.014797     [D5] send_to_all: SETINFO driver.version "2.8.0.1"
   0.014825     [D5] send_to_all: SETINFO driver.version.internal "0.01"
   0.014847     [D5] send_to_all: SETINFO driver.name "apc_modbus"
   0.014881     [D5] send_to_all: SETINFO driver.state "init.info"
[01][03][02][04][00][58]
Waiting for a confirmation...
<01><03><B0><00><00><00><00><00><00><00><00><55><50><53><20><31><30><2E><31><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF><53><6D><61><72><74><2D><55><50><53><20><58><01><37><35><30><20><20><20><20><20><20><20><20><20><20><20><20><20><20><20><20><20><53><4D><58><37><35><30><49><20><20><20><20><20><20><20><20><20><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><41><53><31><35><31><32><31><31><36><32><39><30><20><20><00><00><41><50><43><52><42><43><31><31><36><20><20><20><20><20><20><20><53><4D><58><34><38><52><4D><42><50><32><55><20><20><20><20><20><02><EE><02><58><00><00><15><B6><00><40><00><00><00><00><1C><D3><41><50><43><20><55><50><53><20><20><20><20><20><20><20><20><20>
   0.084039     [D5] send_to_all: SETINFO ups.firmware "UPS 10.1"
   0.084080     [D5] send_to_all: SETINFO ups.model "Smart-UPS X 750"
   0.084130     [D5] send_to_all: SETINFO ups.serial "AS15121xxxxx"
   0.084275     [D5] send_to_all: SETINFO ups.mfr.date "2015-03-21"
   0.084325     [D5] send_to_all: SETINFO battery.date "2020-03-15"
   0.084363     [D5] send_to_all: SETINFO ups.id "APC UPS"
   0.084393     [D5] send_to_all: SETINFO ups.mfr "American Power Conversion"
   0.084424     [D5] send_to_all: SETINFO driver.state "init.updateinfo"
[01][03][00][00][00][1B]
Waiting for a confirmation...
<01><03><36><00><00><20><02><00><08><00><00><00><01><00><02><00><00><00><01><00><02><00><00><00><02><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><01><04><00><48><00><01><00><00>
   0.115961     [D5] send_to_all: SETINFO input.transfer.reason "AcceptableInput"
[01][03][00][80][00][20]
Waiting for a confirmation...
<01><03><40><00><00><15><0F><C8><00><06><C3><FF><FF><19><04><00><00><0F><74><1D><67><FF><FF><1D><47><FF><FF><00><1C><FF><FF><3C><40><FF><FF><18><FE><00><72><44><C4><00><00><FF><FF><FF><FF><00><01><3C><4C><FF><FF><FF><FF><2E><80><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF>
   0.163985     [D5] send_to_all: SETINFO battery.runtime "5391"
   0.164032     [D5] send_to_all: SETINFO battery.charge "100.00"
   0.164083     [D5] send_to_all: SETINFO battery.voltage "54.09"
   0.164121     [D5] send_to_all: SETINFO battery.date.maintenance "2017-07-14"
   0.164157     [D5] send_to_all: SETINFO battery.temperature "30.91"
   0.164199     [D5] send_to_all: SETINFO ups.load "29.40"
   0.164245     [D5] send_to_all: SETINFO ups.realpower "29.40"
   0.164280     [D5] send_to_all: SETINFO ups.power "29.28"
   0.164314     [D5] send_to_all: SETINFO output.current "0.88"
   0.164348     [D5] send_to_all: SETINFO output.voltage "241.00"
   0.164395     [D5] send_to_all: SETINFO output.frequency "49.98"
   0.164426     [D5] send_to_all: SETINFO experimental.output.energy "7488708"
   0.164461     [D5] send_to_all: SETINFO input.voltage "241.19"
   0.164506     [D5] send_to_all: SETINFO ups.efficiency "93.0"
   0.164539     [D5] send_to_all: SETINFO ups.timer.shutdown "-1"
   0.164569     [D5] send_to_all: SETINFO ups.timer.start "-1"
   0.164607     [D5] send_to_all: SETINFO ups.timer.reboot "-1"
[01][03][04][02][00][07]
Waiting for a confirmation...
<01><03><0E><01><0C><00><D4><00><02><00><B4><00><00><00><00><00><08>
   0.195986     [D5] send_to_all: SETINFO input.transfer.high "268"
   0.196027     [D5] send_to_all: SETINFO input.transfer.low "212"
   0.196059     [D5] send_to_all: SETINFO ups.delay.shutdown "180"
   0.196089     [D5] send_to_all: SETINFO ups.delay.start "0"
   0.196120     [D5] send_to_all: SETINFO ups.delay.reboot "8"
   0.196153     [D5] send_to_all: SETINFO ups.status "OL HE"
   0.196179     [D5] send_to_all: DATAOK
   0.196206     [D5] send_to_all: SETINFO driver.state "init.quiet"
   0.197232     [D2] dstate_init: sock /home/jbolger/software/apc/prefix/state/apc_modbus-modbus open on fd 9
   0.197271     [D5] send_to_all: SETINFO driver.parameter.pollinterval "2"
   0.197302     [D5] send_to_all: SETINFO driver.parameter.synchronous "auto"
   0.197336     [D5] send_to_all: SETINFO device.mfr "American Power Conversion"
   0.197369     [D5] send_to_all: SETINFO device.model "Smart-UPS X 750"
   0.197400     [D5] send_to_all: SETINFO device.serial "AS15121xxxxx"
   0.197423     Running as foreground process, not saving a PID file
   0.197452     [D5] send_to_all: SETINFO driver.flag.allow_killpower "0"
   0.197479     [D5] send_to_all: SETFLAGS driver.flag.allow_killpower RW NUMBER
   0.197505     [D5] send_to_all: ADDCMD driver.killpower
   0.197531     [D5] send_to_all: ADDCMD driver.reload
   0.197557     [D5] send_to_all: ADDCMD driver.reload-or-exit
   0.197584     [D5] send_to_all: ADDCMD driver.reload-or-error
   0.197635     [D5] send_to_all: SETINFO driver.state "quiet"
   0.197667     [D1] Driver initialization completed, beginning regular infinite loop
   0.197699     [D5] send_to_all: SETINFO driver.state "updateinfo"
[01][03][00][00][00][1B]
Waiting for a confirmation...
<01><03><36><00><00><20><02><00><08><00><00><00><01><00><02><00><00><00><01><00><02><00><00><00><02><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><01><04><00><48><00><01><00><00>
[01][03][00][80][00][20]
Waiting for a confirmation...
<01><03><40><00><00><15><0F><C8><00><06><C3><FF><FF><19><04><00><00><0F><74><1D><67><FF><FF><1D><47><FF><FF><00><1C><FF><FF><3C><40><FF><FF><18><FE><00><72><44><C4><00><00><FF><FF><FF><FF><00><01><3C><4C><FF><FF><FF><FF><2E><80><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF>
[01][03][04][02][00][07]
Waiting for a confirmation...
<01><03><0E><01><0C><00><D4><00><02><00><B4><00><00><00><00><00><08>
   0.324000     [D5] send_to_all: SETINFO driver.state "quiet"
   2.199986     [D5] send_to_all: SETINFO driver.state "updateinfo"
[01][03][00][00][00][1B]
Waiting for a confirmation...
<01><03><36><00><00><20><02><00><08><00><00><00><01><00><02><00><00><00><01><00><02><00><00><00><02><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><01><04><00><48><00><01><00><00>
[01][03][00][80][00][20]
Waiting for a confirmation...
<01><03><40><00><00><15><0F><C8><00><06><C6><FF><FF><19><04><00><00><0F><77><1D><67><FF><FF><1D><41><FF><FF><00><1C><FF><FF><3C><40><FF><FF><18><FE><00><72><44><C4><00><00><FF><FF><FF><FF><00><01><3C><40><FF><FF><FF><FF><2E><80><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF>
   2.275990     [D5] send_to_all: SETINFO battery.voltage "54.19"
   2.276037     [D5] send_to_all: SETINFO battery.temperature "30.93"
   2.276080     [D5] send_to_all: SETINFO ups.power "29.25"
   2.276127     [D5] send_to_all: SETINFO input.voltage "241.00"
[01][03][04][02][00][07]
Waiting for a confirmation...
<01><03><0E><01><0C><00><D4><00><02><00><B4><00><00><00><00><00><08>
   2.291985     [D5] send_to_all: SETINFO driver.state "quiet"
   4.202409     [D5] send_to_all: SETINFO driver.state "updateinfo"
[01][03][00][00][00][1B]
Waiting for a confirmation...
<01><03><36><00><00><20><02><00><08><00><00><00><01><00><02><00><00><00><01><00><02><00><00><00><02><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><01><04><00><48><00><01><00><00>
[01][03][00][80][00][20]
Waiting for a confirmation...
<01><03><40><00><00><15><D1><C8><00><06><C6><FF><FF><19><04><00><00><0F><74><1C><FA><FF><FF><1D><9B><FF><FF><00><1C><FF><FF><3C><4C><FF><FF><18><FE><00><72><44><C4><00><00><FF><FF><FF><FF><00><01><3C><4C><FF><FF><FF><FF><2E><80><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF>
   4.276105     [D5] send_to_all: SETINFO battery.runtime "5585"
   4.276167     [D5] send_to_all: SETINFO battery.temperature "30.91"
   4.276203     [D5] send_to_all: SETINFO ups.load "28.98"
   4.276235     [D5] send_to_all: SETINFO ups.realpower "28.98"
   4.276267     [D5] send_to_all: SETINFO ups.power "29.61"
   4.276303     [D5] send_to_all: SETINFO output.voltage "241.19"
   4.276342     [D5] send_to_all: SETINFO input.voltage "241.19"
[01][03][04][02][00][07]
Waiting for a confirmation...
<01><03><0E><01><0C><00><D4><00><02><00><B4><00><00><00><00><00><08>
   4.291703     [D5] send_to_all: SETINFO driver.state "quiet"
   6.202843     [D5] send_to_all: SETINFO driver.state "updateinfo"
[01][03][00][00][00][1B]
Waiting for a confirmation...
<01><03><36><00><00><20><02><00><08><00><00><00><01><00><02><00><00><00><01><00><02><00><00><00><02><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><01><04><00><48><00><01><00><00>
[01][03][00][80][00][20]
Waiting for a confirmation...
<01><03><40><00><00><15><D1><C8><00><06><C6><FF><FF><19><04><00><00><0F><77><1D><D4><FF><FF><1D><4E><FF><FF><00><1C><FF><FF><3C><58><FF><FF><18><FF><00><72><44><C4><00><00><FF><FF><FF><FF><00><01><3C><58><FF><FF><FF><FF><2E><80><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF>
   6.307687     [D5] send_to_all: SETINFO battery.temperature "30.93"
   6.307749     [D5] send_to_all: SETINFO ups.load "29.83"
   6.308025     [D5] send_to_all: SETINFO ups.realpower "29.83"
   6.308065     [D5] send_to_all: SETINFO ups.power "29.30"
   6.308114     [D5] send_to_all: SETINFO output.voltage "241.38"
   6.308153     [D5] send_to_all: SETINFO output.frequency "49.99"
   6.308190     [D5] send_to_all: SETINFO input.voltage "241.38"
[01][03][04][02][00][07]
Waiting for a confirmation...
<01><03><0E><01><0C><00><D4><00><02><00><B4><00><00><00><00><00><08>
   6.323575     [D5] send_to_all: SETINFO driver.state "quiet"
   8.205104     [D5] send_to_all: SETINFO driver.state "updateinfo"
[01][03][00][00][00][1B]
Waiting for a confirmation...
<01><03><36><00><00><20><02><00><08><00><00><00><01><00><02><00><00><00><01><00><02><00><00><00><02><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><00><01><04><00><48><00><01><00><00>
[01][03][00][80][00][20]
Waiting for a confirmation...
<01><03><40><00><00><15><0F><C8><00><06><C3><FF><FF><19><04><00><00><0F><77><1D><67><FF><FF><1D><A9><FF><FF><00><1C><FF><FF><3C><58><FF><FF><19><01><00><72><44><C5><00><00><FF><FF><FF><FF><00><01><3C><58><FF><FF><FF><FF><2E><60><FF><FF><FF><FF><FF><FF><FF><FF><FF><FF>
   8.307616     [D5] send_to_all: SETINFO battery.runtime "5391"
   8.307666     [D5] send_to_all: SETINFO battery.voltage "54.09"
   8.307737     [D5] send_to_all: SETINFO ups.load "29.40"
   8.307781     [D5] send_to_all: SETINFO ups.realpower "29.40"
   8.307814     [D5] send_to_all: SETINFO ups.power "29.66"
   8.307854     [D5] send_to_all: SETINFO output.frequency "50.01"
   8.307903     [D5] send_to_all: SETINFO experimental.output.energy "7488709"
   8.307942     [D5] send_to_all: SETINFO ups.efficiency "92.8"
[01][03][04][02][00][07]
Waiting for a confirmation...
<01><03><0E><01><0C><00><D4><00><02><00><B4><00><00><00><00><00><08>
   8.323563     [D5] send_to_all: SETINFO driver.state "quiet"

All looks pretty good. battery.date.maintenance is not what I see on the front panel, I see battery.date which is what I set when I replaced the batteries last.

Thanks for the dev work! Make sure the readme for this driver includes the (obvious) step to enable Modbus on the device itself.

I will follow this ticket for a stable enough commit to build and run this on my main system.