Recently upgraded NUT and noticed some of the older Cyberpower models weren't as well supported as before. Here's a small patch to mark those models as needing OP conversion and map the model names.

Doug

--- a/drivers/powerp-bin.c      2010-02-11 16:43:23.000000000 -0500
+++ b/drivers/powerp-bin.c      2010-07-03 16:42:25.000000000 -0400
@@ -60,6 +60,28 @@
 
 static unsigned char   powpan_answer[SMALLBUF];
 
+typedef struct {
+       int             first;
+       int             second;
+       const char      *pcode;
+       const char      *model;
+} modelmap_t;
+
+static const modelmap_t        modelmap_op[] = {
+       { 51, 51, "OP850", "850AVR"     },      /* O33 */
+       { 52, 53, "OP1500", "1500AVR"   },      /* O45 */
+       { 52, 51, "OP1250", "1250AVR"   },      /* O43 */
+       { 52, 49, "OP700", "700AVR"     },      /* O41 */
+       { 51, 57, "OP650", "650AVR"     },      /* O39 */
+       { 51, 55, "OP900", "900AVR"     },      /* O37 */
+       { 51, 49, "OP800", "800AVR"     },      /* O31 */
+       { 50, 57, "OP500", "500AVR"     },      /* O29 */
+       { 50, 55, "OP320", "320AVR"     },      /* O27 */
+       { 49, 48, "OP1000", "1000AVR"   },      /* O10 */
+       {  0,  0, (char*) NULL, (char *) NULL }
+};
+
+
 /* PR series */
 static const valtab_t  tran_high_pr[] = {
        { "138", -9 }, { "139", -8 }, { "140", -7 }, { "141", -6 }, { "142", -5 
},
@@ -313,7 +335,21 @@
         * was used for autodetection of the UPS. No need to do it again.
         */
        if ((s = strtok((char *)&powpan_answer[1], ".")) != NULL) {
-               dstate_setinfo("ups.model", "%s", rtrim(s, ' '));
+               if (s[0] == 'r' && s[1] == 'O') {
+                       // Older Cyberpower models need to map the model number
+                       for (i = 0; modelmap_op[i].pcode; i++) {
+                               if (s[2] == modelmap_op[i].first && s[3] == 
modelmap_op[i].second) {
+                                       dstate_setinfo("ups.model", "%s", 
modelmap_op[i].pcode);
+                                       break;
+                               }
+                       }
+
+                       if (!modelmap_op[i].pcode) {
+                               dstate_setinfo("ups.model", "%s", rtrim(s, ' 
'));
+                       }
+               } else {
+                       dstate_setinfo("ups.model", "%s", rtrim(s, ' '));
+               }
        }
        if ((s = strtok(NULL, ".")) != NULL) {
                dstate_setinfo("input.voltage.nominal", "%d", (unsigned 
char)s[0]);
@@ -577,7 +613,7 @@
                }
 
                /* See if we need to use the 'old' protocol for the OP series */
-               if (!strncmp((char *)&powpan_answer[1], "OP", 2)) {
+               if (!strncmp((char *)&powpan_answer[1], "OP", 2) || 
!strncmp((char *)&powpan_answer[1], "rO", 2)) {
                        type = OP;
                }
 
_______________________________________________
Nut-upsdev mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev

Reply via email to