Патч для powercom.c, исправляющий баг "battery.charge: 0.0" для IMP-425AP и подобных
Текст патча (nut-2.6.5):
--- drivers/powercom.c.orig 2012-07-31 21:38:59.000000000 +0400
+++ drivers/powercom.c 2014-08-30 01:10:25.820362835 +0400
@@ -887,24 +887,37 @@
types[type].flowControl.setup_flow_control();
/* Setup Model and LineVoltage */
- if (!strncmp(types[type].name, "BNT",3) || !strcmp(types[type].name, "KIN") || !strcmp(types[type].name, "IMP")){
+ /* if (!strncmp(types[type].name, "BNT",3) || !strcmp(types[type].name, "KIN") || !strcmp(types[type].name, "IMP")){ */
+ if (getval("type") == NULL){
if (!ups_getinfo()) return;
/* Give "BNT-other" a chance! */
if (raw_data[MODELNAME]==0x42 || raw_data[MODELNAME]==0x4B){
- model=BNTmodels[raw_data[MODELNUMBER]/16];
+ /* model=BNTmodels[raw_data[MODELNUMBER]/16]; */
if (!strcmp(types[type].name, "BNT-other"))
types[type].name="BNT-other";
else if (raw_data[MODELNAME]==0x42)
types[type].name="BNT";
else if (raw_data[MODELNAME]==0x4B){
types[type].name="KIN";
- model=KINmodels[raw_data[MODELNUMBER]/16];
+ /* model=KINmodels[raw_data[MODELNUMBER]/16]; */
}
}
else if (raw_data[UPSVERSION]==0xFF){
types[type].name="IMP";
+ /* model=IMPmodels[raw_data[MODELNUMBER]/16]; */
+ }
+ }
+ if (!strncmp(types[type].name, "BNT",3) || !strcmp(types[type].name, "KIN") || !strcmp(types[type].name, "IMP")){
+ if (!ups_getinfo()) return;
+ if (!strcmp(types[type].name, "IMP")){
model=IMPmodels[raw_data[MODELNUMBER]/16];
}
+ if (!strncmp(types[type].name, "BNT",3)){
+ model=BNTmodels[raw_data[MODELNUMBER]/16];
+ }
+ if (!strcmp(types[type].name, "KIN")){
+ model=KINmodels[raw_data[MODELNUMBER]/16];
+ }
linevoltage=voltages[raw_data[MODELNUMBER]%16];
snprintf(buf,sizeof(buf),"%s-%dAP",types[type].name,model);
if (!strcmp(modelname, "Unknown"))
Текст патча (nut-2.4.1):
--- drivers/powercom.c 2009-02-17 12:20:48.000000000 +0300
+++ drivers/powercom.c 2010-03-02 15:48:25.354735038 +0300
@@ -852,21 +852,30 @@
/* setup flow control */
types[type].flowControl.setup_flow_control();
- if (!strncmp(types[type].name, "BNT",3) || !strcmp(types[type].name, "KIN") || !strcmp(types[type].name, "IMP")){
+ if (getval("type") == NULL){
if (!ups_getinfo()) return;
if (raw_data[UPSVERSION]==0xFF){
types[type].name="IMP";
- model=IMPmodels[raw_data[MODELNUMBER]/16];
}
if (raw_data[MODELNAME]==0x42){
if (!strcmp(types[type].name, "BNT-other"))
types[type].name="BNT-other";
else
types[type].name="BNT";
- model=BNTmodels[raw_data[MODELNUMBER]/16];
}
if (raw_data[MODELNAME]==0x4B){
types[type].name="KIN";
+ }
+ }
+ if (!strncmp(types[type].name, "BNT",3) || !strcmp(types[type].name, "KIN") || !strcmp(types[type].name, "IMP")){
+ if (!ups_getinfo()) return;
+ if (!strcmp(types[type].name, "IMP")){
+ model=IMPmodels[raw_data[MODELNUMBER]/16];
+ }
+ if (!strncmp(types[type].name, "BNT",3)){
+ model=BNTmodels[raw_data[MODELNUMBER]/16];
+ }
+ if (!strcmp(types[type].name, "KIN")){
model=KINmodels[raw_data[MODELNUMBER]/16];
}
linevoltage=voltages[raw_data[MODELNUMBER]%16];
Пока в nut не исправили этот глючек, т.е. как минимум для
nut 2.4.1 - 2.6.5 это решений будет актуально.