-
-
Notifications
You must be signed in to change notification settings - Fork 427
Changes to add support for AMETEK Powervar UPM as usb-hid UPS. #733
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
adb504d
Changes to add support for Powervar UPM as usb-hid UPS. Includes addi…
andrewmccartney b25f8b5
Merge branch 'master' into master
jimklimov 1c75f81
Merge branch 'master' into master
jimklimov e266362
Merge branch 'master' into master
andrewmccartney e4cb867
Changes per NUT review comments. Removed info fields from polling. Ad…
andrewmccartney 29f78b5
Merge branch 'master' of https://github.com/andrewmccartney/nut
andrewmccartney c311835
Update nut.dict for PR #733
jimklimov d4172dc
Update usbhid-ups.txt
jimklimov 679eee3
Final clean up and edits for Powervar UPM support
andrewmccartney 48f9c34
Merge branch 'master' of https://github.com/andrewmccartney/nut
andrewmccartney a567c93
Merge branch 'master' into master
andrewmccartney 05f91b6
Update acknowledgements.txt
jimklimov 55778c9
Merge branch 'master' into master
jimklimov 501ae3a
Merge branch 'master' into master
andrewmccartney 4fd8a45
Merge branch 'master' into master
jimklimov ecce15e
Merge branch 'master' into master
jimklimov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| /* powervar-hid.c - subdriver to monitor Powervar USB/HID devices with NUT | ||
| * | ||
| * Copyright (C) | ||
| * 2003 - 2012 Arnaud Quette <ArnaudQuette@Eaton.com> | ||
| * 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net> | ||
| * 2008 - 2009 Arjen de Korte <adkorte-guest@alioth.debian.org> | ||
| * 2013 Charles Lepple <clepple+nut@gmail.com> | ||
|
jimklimov marked this conversation as resolved.
|
||
| * 2019 AMETEK Powervar - Andrew McCartney <andrew.mccartney@ametek.com> | ||
| * | ||
| * Note: this subdriver was initially generated as a "stub" by the | ||
| * gen-usbhid-subdriver script. It must be customized. | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 2 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| */ | ||
|
|
||
| #include "usbhid-ups.h" | ||
| #include "powervar-hid.h" | ||
| #include "main.h" /* for getval() */ | ||
| #include "usb-common.h" | ||
|
|
||
| #define POWERVAR_HID_VERSION "Powervar HID 0.19" | ||
| /* FIXME: experimental flag to be put in upsdrv_info */ | ||
|
|
||
| /* Powervar */ | ||
| #define POWERVAR_VENDORID 0x4234 | ||
|
|
||
| /* USB IDs device table */ | ||
| static usb_device_id_t powervar_usb_device_table[] = { | ||
| /* Powervar */ | ||
| { USB_DEVICE(POWERVAR_VENDORID, 0x0002), NULL }, | ||
|
|
||
| /* Terminating entry */ | ||
| { -1, -1, NULL } | ||
| }; | ||
|
|
||
|
|
||
| /* --------------------------------------------------------------- */ | ||
| /* Vendor-specific usage table */ | ||
| /* --------------------------------------------------------------- */ | ||
|
|
||
| /* POWERVAR usage table */ | ||
| static usage_lkp_t powervar_usage_lkp[] = { | ||
| { "POWERVAR1", 0xff000001 }, | ||
| { NULL, 0 } | ||
| }; | ||
|
|
||
| static usage_tables_t powervar_utab[] = { | ||
| powervar_usage_lkp, | ||
| hid_usage_lkp, | ||
| NULL, | ||
| }; | ||
|
|
||
| /* --------------------------------------------------------------- */ | ||
| /* HID2NUT lookup table */ | ||
| /* --------------------------------------------------------------- */ | ||
|
|
||
| static hid_info_t powervar_hid2nut[] = { | ||
|
|
||
| /* Battery page */ | ||
| { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", 0, stringid_conversion }, | ||
| { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, | ||
| { "battery.capacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, | ||
| { "battery.runtime", 0, 0, "UPS.PowerSummary.RuntimeToEmpty", NULL, "%.0f", 0, NULL }, | ||
|
|
||
| /* Special case: ups.status & ups.alarm */ | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, 0, shutdownimm_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, 0, lowbatt_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, 0, overload_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired", NULL, NULL, 0, timelimitexpired_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, NULL, 0, yes_no_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, NULL, 0, yes_no_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.OverTemperature", NULL, NULL, 0, overheat_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyCharged", NULL, NULL, 0, fullycharged_info }, | ||
| { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyDischarged", NULL, NULL, 0, depleted_info }, | ||
|
aquette marked this conversation as resolved.
|
||
|
|
||
| /* end of structure. */ | ||
| { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } | ||
| }; | ||
|
|
||
| static const char *powervar_format_model(HIDDevice_t *hd) { | ||
| return hd->Product; | ||
| } | ||
|
|
||
| static const char *powervar_format_mfr(HIDDevice_t *hd) { | ||
| return hd->Vendor ? hd->Vendor : "Powervar"; | ||
| } | ||
|
|
||
| static const char *powervar_format_serial(HIDDevice_t *hd) { | ||
| return hd->Serial; | ||
| } | ||
|
|
||
| /* this function allows the subdriver to "claim" a device: return 1 if | ||
| * the device is supported by this subdriver, else 0. */ | ||
| static int powervar_claim(HIDDevice_t *hd) | ||
| { | ||
| int status = is_usb_device_supported(powervar_usb_device_table, hd); | ||
|
|
||
| switch (status) | ||
| { | ||
| case POSSIBLY_SUPPORTED: | ||
| /* by default, reject, unless the productid option is given */ | ||
| if (getval("productid")) { | ||
| return 1; | ||
| } | ||
| possibly_supported("Powervar", hd); | ||
| return 0; | ||
|
|
||
| case SUPPORTED: | ||
| return 1; | ||
|
|
||
| case NOT_SUPPORTED: | ||
| default: | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| subdriver_t powervar_subdriver = { | ||
| POWERVAR_HID_VERSION, | ||
| powervar_claim, | ||
| powervar_utab, | ||
| powervar_hid2nut, | ||
| powervar_format_model, | ||
| powervar_format_mfr, | ||
| powervar_format_serial, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* powervar-hid.h - subdriver to monitor Powervar USB/HID devices with NUT | ||
| * | ||
| * Copyright (C) | ||
| * 2003 - 2009 Arnaud Quette <ArnaudQuette@Eaton.com> | ||
| * 2005 - 2006 Peter Selinger <selinger@users.sourceforge.net> | ||
| * 2008 - 2009 Arjen de Korte <adkorte-guest@alioth.debian.org> | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 2 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program; if not, write to the Free Software | ||
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| */ | ||
|
|
||
| #ifndef POWERVAR_HID_H | ||
| #define POWERVAR_HID_H | ||
|
|
||
| #include "usbhid-ups.h" | ||
|
|
||
| extern subdriver_t powervar_subdriver; | ||
|
|
||
| #endif /* POWERVAR_HID_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note @andrewmccartney : I took the liberty to stub an acknowledgements entry here. Feel free to modify if I got some names or spellings wrong.