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

Add support for Hunnox HNX-850 #638

Merged
merged 24 commits into from Apr 20, 2021

Conversation

marianojan
Copy link
Contributor

This PR adds support for the Hunnox HNX-850 UPS.

It's a special case for the fabula subdriver, with a required lockstep for the commands. For this UPS, if the commands are not sent in a specific order, the output status remains unchanged.

To make it work, my ups.conf file, has the following configuration:

[u1]
       driver = "nutdrv_qx"
       port = "auto"
       vendorid = "0001"
       productid = "0000"
       protocol = hunnox
       langid_fix = 0x0409
       novendor
       noscanlangid

Also I had to add a new flag, noscanlangid because this scan hangs the USB endpoint of the UPS.

I hope it can help someone else who has this brand of UPS.

@zykh
Copy link
Contributor

zykh commented Dec 3, 2018

Thanks for the patch, @marianojan.
I'm not lucid enough and I've not enough time now for a complete review, but I'll come back to this in a few days...

So just one thing for now... basically the working sequence is:

  • initialization (only once):
    • get string at index 0 twice,
    • then string at index 1,
    • then sleep for a while,
  • update sequence (loop):
    • get string at index 0xd (F query),
    • get string at index 3 (Q1 query),
    • get string at index 0xc (I query),

right?

@marianojan
Copy link
Contributor Author

Hello @zykh!

You are right, the working sequence is as you expressed it.
The initialization steps are required only once, as far as I tested it.
The update sequence requires that before each Q1 query, one of F or I query has to be done. I copied the steps from the Windows client, by capturing the requests with Wireshark.
Both the I and F queries return null data. (The windows client somehow receives a versión number, but when I tested in linux, I always got an empty string)

I don't have a great knowledge about the project, so if something is misplaced or has to be done in another way, please tell me.

Thank you for taking a look at it!

@@ -790,7 +841,7 @@ static int krauler_command(const char *cmd, char *buf, size_t buflen)
}

/* Fabula communication subdriver */
static int fabula_command(const char *cmd, char *buf, size_t buflen)
static int _fabula_command(const char *cmd, char *buf, size_t buflen, char hunnox_patch)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not worth adding a hunnox_patch parameter which is only for Hunox 850. A function should be use for other protocols. Do you have any other options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that duplicating the entire function was a bad idea. But maybe it's the safest way to avoid problems for other UPSs? What do you recommend?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My stance on this wavered over time, but in the end I guess making an explicit "hunnox_command" that happens to repeat some of the other code can be more readable and maintainable, and would clearly "protect" support of different devices from these and later changes in not-their subdriver.

It may be or not be possible and practical that shared code can be de-duplicated into new routines called from various places, as a separate effort.

Copy link

@panoti panoti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a ARES AR265i. It may also use this subdriver. I hope this pull request be merged.

drivers/Makefile.am Outdated Show resolved Hide resolved
drivers/nutdrv_qx.c Show resolved Hide resolved
drivers/nutdrv_qx.c Show resolved Hide resolved
@knoid
Copy link

knoid commented Feb 12, 2020

Thanks to this PR I was able to get data from my newly bought UPS!

I'm not sure which model it really is but it's sold as "Ups Energit Iron Guardian 800 Plcd Dispay Usb Monofasica" (with spelling errors and all) and comes with software branded as "UPSmart v1.5" for redhat and I 1) don't own a CD-R and 2) use Ubuntu.

@microfrost1
Copy link

This worked perfectly for my "Powercool Smart UPS 1200VA".

@lgtm-com

This comment has been minimized.

@jimklimov
Copy link
Member

Was this work done by/for/on-behalf of a vendor (e.g. Hunnox)? If so, please update the docs/acknowledgements.txt file as well.

jimklimov and others added 2 commits November 7, 2020 23:23
@@ -0,0 +1,29 @@
/* nutdrv_qx_zinto.h - Subdriver for Zinto protocol based UPSes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marianojan : if this was adapted from a subdriver for another UPS model, worth mentioning taht but the title here should point to Hunnox ;)

@@ -0,0 +1,137 @@
/* nutdrv_qx_zinto.c - Subdriver for Zinto protocol based UPSes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marianojan : if this was adapted from a subdriver for another UPS model, worth mentioning taht but the title here should point to Hunnox ;)

@clepple clepple added the USB label Dec 31, 2020
@LukePrior
Copy link

Is this going to get merged?

Updated file heading
Updated file heading
drivers/nutdrv_qx.c Show resolved Hide resolved
Err on the safer side of changing behavior for non-hunnox device support, limit the applicability of langid_fix (per PR networkupstools#638 review cautionary comments). Maybe the proposed original change did apply to other devices that support the fix-up, but that should be evaluated separately and this new constraint reversed if needed.
Basically mention updates from Hunnox subdriver and protocol addition (PR networkupstools#638).
Some more keywords to the dictionary from PR networkupstools#638
@lgtm-com

This comment has been minimized.

@jimklimov
Copy link
Member

jimklimov commented Apr 20, 2021

Thanks @marianojan for the contribution and @panoti for review and highlighting possible sore points.

@networkupstools networkupstools deleted a comment from lgtm-com bot Apr 20, 2021
@networkupstools networkupstools deleted a comment from lgtm-com bot Apr 20, 2021
@networkupstools networkupstools deleted a comment from lgtm-com bot Apr 20, 2021
@networkupstools networkupstools deleted a comment from lgtm-com bot Apr 20, 2021
@networkupstools networkupstools deleted a comment from lgtm-com bot Apr 20, 2021
…mand() without using a mixed routine, to ensure no impact on currently supported devices
… choice of usb_get_string{,_simple}() based on langid_fix alone
…d to support more than Hunnox branded devices
…r (and use of) "hunnox_patch" leaving the markers in comments for refactoring
@lgtm-com

This comment has been minimized.

@lgtm-com

This comment was marked as duplicate.

@jimklimov jimklimov merged commit 169b637 into networkupstools:master Apr 20, 2021

{ "device.mfr", 0, NULL, "FW?\r", "", 39, '#', "", 1, 15, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL },
{ "device.model", 0, NULL, "FW?\r", "", 39, '#', "", 17, 26, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL },
{ "ups.firmware", 0, NULL, "FW?\r", "", 39, '#', "", 28, 37, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aquette: going over recent merges, and given your earlier comments about mfr/model/serial in #807 (comment) - should these fields here be removed also (does something else handle them by default)? And/or apply some same namespace (ups vs device) here?

@JulyIghor
Copy link

Anyone knows what does mean '*' which sometimes comes instead of '('?
image

@JulyIghor
Copy link

Sometimes it won't start

  0.118743	[D3] nut_usb_set_altinterface: skipped usb_set_altinterface(udev, 0)
   0.120429	[D3] send: Q1
   0.124323	[D3] read: Input/output error (-5)
   0.124355	[D2] qx_process_answer: short reply (input.voltage)
   0.124377	[D2] Skipping protocol Q1 0.07
   0.124385	Device not supported!
   0.124395	Device not supported!

And works again only after re-attaching usb cable

@jimklimov jimklimov added the HCL label Apr 25, 2022
jimklimov added a commit to jimklimov/nut that referenced this pull request Apr 25, 2022
jimklimov added a commit to jimklimov/nut that referenced this pull request Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants