hardware: fix voltage sensors reporting
As per linux sysfs documentation[1], the voltages reported by sysfs files
are in millivolts, not microvolts.
Thanks to Martin for discovering the bug.
[1]: https://github.com/torvalds/linux/blob/32b9a19a1966fb3124d7ddd60ebd08688be2f3fa/Documentation/ABI/testing/sysfs-class-hwmon#L70
Fixes: 97e5ea16
Change-Id: I1475388eb88d69a13b81b6f042c43f0b439d0732
diff --git a/src/ietf-hardware/IETFHardware.cpp b/src/ietf-hardware/IETFHardware.cpp
index 9a2edc0..c355934 100644
--- a/src/ietf-hardware/IETFHardware.cpp
+++ b/src/ietf-hardware/IETFHardware.cpp
@@ -186,14 +186,14 @@
template <> const DataTree sysfsStaticData<SensorType::VoltageAC> = {
{"class", "iana-hardware:sensor"},
{"sensor-data/value-type", "volts-AC"},
- {"sensor-data/value-scale", "micro"},
+ {"sensor-data/value-scale", "milli"},
{"sensor-data/value-precision", "0"},
{"sensor-data/oper-status", "ok"}
};
template <> const DataTree sysfsStaticData<SensorType::VoltageDC> = {
{"class", "iana-hardware:sensor"},
{"sensor-data/value-type", "volts-DC"},
- {"sensor-data/value-scale", "micro"},
+ {"sensor-data/value-scale", "milli"},
{"sensor-data/value-precision", "0"},
{"sensor-data/oper-status", "ok"}
};
diff --git a/tests/hardware_ietf-hardware.cpp b/tests/hardware_ietf-hardware.cpp
index bbcf647..60eeb40 100644
--- a/tests/hardware_ietf-hardware.cpp
+++ b/tests/hardware_ietf-hardware.cpp
@@ -173,14 +173,14 @@
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/sensor-data/oper-status", "ok"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/sensor-data/value", "220000"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/sensor-data/value-precision", "0"},
- {"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/sensor-data/value-scale", "micro"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/sensor-data/value-scale", "milli"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-in']/sensor-data/value-type", "volts-AC"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/parent", "ne:ctrl"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/oper-status", "ok"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/value", "12000"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/value-precision", "0"},
- {"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/value-scale", "micro"},
+ {"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/value-scale", "milli"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:voltage-out']/sensor-data/value-type", "volts-DC"},
{"/ietf-hardware:hardware/component[name='ne:ctrl:current']/class", "iana-hardware:sensor"},
@@ -360,7 +360,7 @@
{"[name='ne:ctrl:voltage-in']/sensor-data/oper-status", "ok"},
{"[name='ne:ctrl:voltage-in']/sensor-data/value", "220000"},
{"[name='ne:ctrl:voltage-in']/sensor-data/value-precision", "0"},
- {"[name='ne:ctrl:voltage-in']/sensor-data/value-scale", "micro"},
+ {"[name='ne:ctrl:voltage-in']/sensor-data/value-scale", "milli"},
{"[name='ne:ctrl:voltage-in']/sensor-data/value-type", "volts-AC"},
{"[name='ne:ctrl:voltage-out']", ""},
{"[name='ne:ctrl:voltage-out']/name", "ne:ctrl:voltage-out"},
@@ -370,7 +370,7 @@
{"[name='ne:ctrl:voltage-out']/sensor-data/oper-status", "ok"},
{"[name='ne:ctrl:voltage-out']/sensor-data/value", "12000"},
{"[name='ne:ctrl:voltage-out']/sensor-data/value-precision", "0"},
- {"[name='ne:ctrl:voltage-out']/sensor-data/value-scale", "micro"},
+ {"[name='ne:ctrl:voltage-out']/sensor-data/value-scale", "milli"},
{"[name='ne:ctrl:voltage-out']/sensor-data/value-type", "volts-DC"},
{"[name='ne:ctrl:current']", ""},
@@ -574,21 +574,21 @@
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/oper-status", "ok"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/value", "0"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/value-precision", "0"},
- {"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/value-scale", "micro"},
+ {"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/value-scale", "milli"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-12V']/sensor-data/value-type", "volts-DC"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/parent", "ne:psu"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/oper-status", "ok"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/value", "0"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/value-precision", "0"},
- {"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/value-scale", "micro"},
+ {"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/value-scale", "milli"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-5Vsb']/sensor-data/value-type", "volts-DC"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/class", "iana-hardware:sensor"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/parent", "ne:psu"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/oper-status", "ok"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/value", "0"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/value-precision", "0"},
- {"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/value-scale", "micro"},
+ {"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/value-scale", "milli"},
{"/ietf-hardware:hardware/component[name='ne:psu:voltage-in']/sensor-data/value-type", "volts-AC"},
};
break;