Skip to content
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

feature request : Add support for Huawei Modbus UPSs #1017

Closed
sumsethan opened this issue Apr 16, 2021 · 14 comments
Closed

feature request : Add support for Huawei Modbus UPSs #1017

sumsethan opened this issue Apr 16, 2021 · 14 comments
Labels

Comments

@sumsethan
Copy link

here comes the Huawei UPS2000 series UPS Modbus Protocol Manual
https://support.huawei.com/view/PdfRead/EDOC1000110696/SUPE_DOC/k001/document.pdf

It has a USB port and a RS232 port
USB port seems like behind a translation chip " ID 04e2:1410 Exar Corp. XR21V1410 USB-UART IC"(on lsusb command) though RS232

Any ideas guys?

@sumsethan
Copy link
Author

sumsethan commented Apr 16, 2021

connecting usb port recognized as a /dev/ttyXRUSB0 device

@jimklimov
Copy link
Member

I believe currently there is one modbus-aware driver, phoenixcontact_modbus, with some efforts discussed to introduce a second. While the media connection is serial (or emulated to that), though I think RS-485 is more frequent than RS-232 for that (not that they would be easy to tell apart by looking), NUT may be lacking a driver that talks an actual protocol for that.

Actually, one of the discussed efforts is indeed a Huawei UPS2000 driver in #954 which was not merged yet due to a burst of activity and then silence from the contributor. But I suppose it would help if you can build that branch from biergaizi:ups2000 and confirm whether it works for your device.

@whc2001
Copy link

whc2001 commented Jul 21, 2021

Any progress on that?

@biergaizi
Copy link
Contributor

@sumsethan: connecting usb port recognized as a /dev/ttyXRUSB0 device

This is new information for me. What system are you using?

The RX21V1410 chip in UPS2000 doesn't work on the official upstream Linux kernel, it can be recognized as a CDC device, but not functional (presumably because the chip is in a special configuration). On your system, if you see that the device shows as a nonstandard name like ttyXRUSB0, it means you're using an unofficial, out-of-tree driver unsupported by the upstream Linux kernel, so it must be a local patch from your Linux distro.

I didn't even realize there is actually a distro that included out-of-tree driver for the chip. In all my documentation I always claim that USB is entirely unsupported, but apparently with the unofficial driver installed, USB should actually work.

Again, what is your distro?

@biergaizi
Copy link
Contributor

Following the same line of investigation, apparently the driver for MaxLinear RX21V1410 has just been mainlined to the upstream in January and April, and an official driver (with the standard serial port names, not the nonstandard ttyXRUSB0) is already included in Linux 5.13, 5.14, and 5.15-RC. This is an important development.

Perhaps it was a good decision not to merge my patch back in January. Time to retest the driver and update the documentation.

@biergaizi
Copy link
Contributor

Never mind the question.

Linux 5.12 and newer kernels already have a mainline driver xr_serial and it's confirmed to work.

@biergaizi
Copy link
Contributor

@whc2001: now it's 100% completed. Waiting for a code review and a merge.

@whc2001
Copy link

whc2001 commented Sep 24, 2021

Glad to hear, thanks for the effort!

@jimklimov
Copy link
Member

Now that the driver became part of NUT master branch, may I ask people watching this issue to try a build and report if it works for them? :)

@ultinous-dancsa
Copy link

ultinous-dancsa commented Jan 24, 2022

We've just bought a UPS2000-A-1KTTS. I'm not very familiar with building C code, i had some issues. (fresh master 88e8a83)
Linux mgmt01 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 16.04 (yeah, old, currently under replacement)
config: ./configure --with-user=ups --with-group=nut --with-usb --with-drivers=huawei-ups2000
i'm not sure if it's a bug, but configure won't complain about missing modbus lib, but the make will fail. apt-get install libmodbus-dev is needed.

root@mgmt01:/usr/local/ups/etc# cat ups.conf
[huvi]
driver = huawei-ups2000
port = /dev/ttyXRUSB0
desc = "Workstation"
root@mgmt01:/usr/local/ups/sbin# /usr/local/ups/bin/upsc huvi@localhost
battery.capacity: 9
battery.charge: 100.0
battery.charger.status: charging
battery.packs: 2
battery.runtime: 8692
battery.voltage: 27.4
device.mfr: Huawei
device.model: UPS2000A
...
ups.firmware: V2R1C1SPC50
ups.firmware.aux: P1.0-D1.0

seems working
(I'm still working myself through the documentation as i'm new to nut)

@jimklimov
Copy link
Member

jimklimov commented Jan 26, 2022 via email

@jimklimov
Copy link
Member

PR #1277 should handle the drive-by --with-drivers=... deficiency found above (thanks!)

I suppose the original issue for Huawei Modbus can be marked as achieved.

@davidmarquesneves
Copy link

Here is the page of NUT for this product:

https://networkupstools.org/docs/man/huawei-ups2000.html

@biergaizi
Copy link
Contributor

root@mgmt01:/usr/local/ups/etc# cat ups.conf
[huvi]
driver = huawei-ups2000
port = /dev/ttyXRUSB0
desc = "Workstation"
root@mgmt01:/usr/local/ups/sbin# /usr/local/ups/bin/upsc huvi@localhost
battery.capacity: 9
battery.charge: 100.0
battery.charger.status: charging
battery.packs: 2
battery.runtime: 8692
battery.voltage: 27.4
device.mfr: Huawei
device.model: UPS2000A
...
ups.firmware: V2R1C1SPC50
ups.firmware.aux: P1.0-D1.0

seems working
(I'm still working myself through the documentation as i'm new to nut)

Thanks for reporting. I'll add your model to the list of tested units in the documentation.

biergaizi added a commit to biergaizi/nut that referenced this issue Oct 21, 2022
This commit adds UPS2000-A-1KTTS with another firmware
version (V2R1C1SPC50) to the list of tested UPS models.
Thanks @ultinous-dancsa for reporting it [1].

[1] networkupstools#1017 (comment)

Signed-off-by: Yifeng Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants