Skip to content

Commit 5dc5477

Browse files
authored
Merge 7341b41 into 68fb8bd
2 parents 68fb8bd + 7341b41 commit 5dc5477

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed

NEWS.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ https://github.com/networkupstools/nut/milestone/13
4747

4848
- `apc_modbus` driver updates:
4949
* Fixed string join not doing zero termination. [PR #3413]
50+
* Decode `RunTimeCalibrationStatus_BF` into
51+
`experimental.ups.calibration.result` [PR #3416]
5052

5153
- NUT client libraries:
5254
* Complete support for actions documented in `docs/net-protocol.txt`

docs/nut.dict

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 3734 utf-8
1+
personal_ws-1.1 en 3735 utf-8
22
AAC
33
AAS
44
ABI
@@ -1160,6 +1160,7 @@ Rouben
11601160
Rozman
11611161
Rucelf
11621162
RunAs
1163+
RunTimeCalibrationStatus
11631164
RunUPSCommand
11641165
RxD
11651166
Ryabov

drivers/apc_modbus.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,69 @@ static int _apc_modbus_battery_test_status_to_nut(const apc_modbus_value_t *valu
772772

773773
static apc_modbus_converter_t _apc_modbus_battery_test_status_conversion = { _apc_modbus_battery_test_status_to_nut, NULL };
774774

775+
static int _apc_modbus_runtime_calibration_status_to_nut(const apc_modbus_value_t *value, char *output, size_t output_len)
776+
{
777+
const char *result, *source, *modifier;
778+
const char *values[3];
779+
780+
if (value == NULL || output == NULL || output_len == 0) {
781+
/* Invalid parameters */
782+
return 0;
783+
}
784+
785+
if (value->type != APC_VT_UINT) {
786+
return 0;
787+
}
788+
789+
result = NULL;
790+
if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_PENDING)) {
791+
result = "Pending";
792+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_INPROGRESS)) {
793+
result = "InProgress";
794+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_PASSED)) {
795+
result = "Passed";
796+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_FAILED)) {
797+
result = "Failed";
798+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_REFUSED)) {
799+
result = "Refused";
800+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_ABORTED)) {
801+
result = "Aborted";
802+
}
803+
804+
source = NULL;
805+
if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_SOURCE_PROTOCOL)) {
806+
source = "Source: Protocol";
807+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_SOURCE_LOCALUI)) {
808+
source = "Source: LocalUI";
809+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_SOURCE_INTERNAL)) {
810+
source = "Source: Internal";
811+
}
812+
813+
modifier = NULL;
814+
if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_INVALIDSTATE)) {
815+
modifier = "Modifier: InvalidState";
816+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_INTERNALFAULT)) {
817+
modifier = "Modifier: InternalFault";
818+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_STATEOFCHARGENOTACCEPTABLE)) {
819+
modifier = "Modifier: StateOfChargeNotAcceptable";
820+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_LOADCHANGE)) {
821+
modifier = "Modifier: LoadChange";
822+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_ACINPUTNOTACCEPTABLE)) {
823+
modifier = "Modifier: ACInputNotAcceptable";
824+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_LOADTOOLOW)) {
825+
modifier = "Modifier: LoadTooLow";
826+
} else if ((value->data.uint_value & APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_OVERCHARGEINPROGRESS)) {
827+
modifier = "Modifier: OverChargeInProgress";
828+
}
829+
830+
values[0] = result;
831+
values[1] = source;
832+
values[2] = modifier;
833+
return _apc_modbus_string_join(values, SIZEOF_ARRAY(values), ", ", output, output_len);
834+
}
835+
836+
static apc_modbus_converter_t _apc_modbus_runtime_calibration_status_conversion = { _apc_modbus_runtime_calibration_status_to_nut, NULL };
837+
775838
static const time_t apc_date_start_offset = 946684800; /* 2000-01-01 00:00 */
776839

777840
static int _apc_modbus_date_to_nut(const apc_modbus_value_t *value, char *output, size_t output_len)
@@ -890,6 +953,7 @@ static apc_modbus_register_t apc_modbus_register_map_inventory[] = {
890953
static apc_modbus_register_t apc_modbus_register_map_status[] = {
891954
{ "input.transfer.reason", 2, 1, APC_VT_UINT, APC_VF_NONE, &_apc_modbus_status_change_cause_conversion, NULL, 0, NULL },
892955
{ "ups.test.result", 23, 1, APC_VT_UINT, APC_VF_NONE, &_apc_modbus_battery_test_status_conversion, NULL, 0, NULL },
956+
{ "experimental.ups.calibration.result", 24, 1, APC_VT_UINT, APC_VF_NONE, &_apc_modbus_runtime_calibration_status_conversion, NULL, 0, NULL },
893957
{ NULL, 0, 0, APC_VT_INT, APC_VF_NONE, NULL, NULL, 0.0f, NULL }
894958
};
895959

drivers/apc_modbus.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@
4848
#define APC_MODBUS_REPLACEBATTERYTESTSTATUS_BF_MOD_INTERNALFAULT (1 << 10)
4949
#define APC_MODBUS_REPLACEBATTERYTESTSTATUS_BF_MOD_STATEOFCHARGENOTACCEPTABLE (1 << 11)
5050

51+
/* RunTimeCalibrationStatus_BF register bits (register 24 in status block)
52+
* See MPAO-98KJ7F_R1_EN Appendix B */
53+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_PENDING (1 << 0)
54+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_INPROGRESS (1 << 1)
55+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_PASSED (1 << 2)
56+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_FAILED (1 << 3)
57+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_REFUSED (1 << 4)
58+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_ABORTED (1 << 5)
59+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_SOURCE_PROTOCOL (1 << 6)
60+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_SOURCE_LOCALUI (1 << 7)
61+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_SOURCE_INTERNAL (1 << 8)
62+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_INVALIDSTATE (1 << 9)
63+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_INTERNALFAULT (1 << 10)
64+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_STATEOFCHARGENOTACCEPTABLE (1 << 11)
65+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_LOADCHANGE (1 << 12)
66+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_ACINPUTNOTACCEPTABLE (1 << 13)
67+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_LOADTOOLOW (1 << 14)
68+
#define APC_MODBUS_RUNTIMECALIBRATIONSTATUS_BF_MOD_OVERCHARGEINPROGRESS (1 << 15)
69+
5170
#define APC_MODBUS_SOGRELAYCONFIGSETTING_BF_REG 590
5271
#define APC_MODBUS_SOGRELAYCONFIGSETTING_BF_MOG_PRESENT (1 << 0)
5372
#define APC_MODBUS_SOGRELAYCONFIGSETTING_BF_SOG_0_PRESENT (1 << 1)

0 commit comments

Comments
 (0)