conf change: sensors: read and write path rename
Rename the readpath and writepath for camelcase styling to make all
configuration variables consistent.
Change-Id: I33f475075c8f40cd2029a5c0bfda950846cd5d44
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/README.md b/README.md
index 3395055..18c89f4 100644
--- a/README.md
+++ b/README.md
@@ -103,8 +103,8 @@
ipmi:
{IPMI_ID}
name: "fan1"
- readpath: "/xyz/openbmc_project/sensors/fan_tach/fan1"
- writepath: "/sys/class/hwmon/hwmon0/pwm0"
+ readPath: "/xyz/openbmc_project/sensors/fan_tach/fan1"
+ writePath: "/sys/class/hwmon/hwmon0/pwm0"
pidinfo:
samplerate: 0.1 // sample time in seconds
p_coeff: 0.01 // coefficient for proportional
@@ -122,8 +122,8 @@
ipmi:
{IPMI_ID}
name: "sluggish0"
- readpath: "/xyz/openbmc_project/sensors/external/sluggish0"
- writepath: ""
+ readPath: "/xyz/openbmc_project/sensors/external/sluggish0"
+ writePath: ""
pidinfo:
samplerate: 1 // sample time in seconds
p_coeff: 94.0
diff --git a/conf.hpp b/conf.hpp
index c5734cc..cfea278 100644
--- a/conf.hpp
+++ b/conf.hpp
@@ -12,11 +12,11 @@
*/
struct SensorConfig
{
- /* Used for listen if readpath is passive. */
+ /* Used for listen if readPath is passive. */
std::string type;
/* Can be a sensor path or a dbus path. */
- std::string readpath;
- std::string writepath;
+ std::string readPath;
+ std::string writePath;
/* min/max values for writing a percentage or error checking. */
int64_t min;
int64_t max;
diff --git a/dbus/dbusconfiguration.cpp b/dbus/dbusconfiguration.cpp
index 0045822..e4396c4 100644
--- a/dbus/dbusconfiguration.cpp
+++ b/dbus/dbusconfiguration.cpp
@@ -80,8 +80,8 @@
std::cout << "\t{" << pair.first << ",\n\t\t{";
std::cout << pair.second.type << ", ";
- std::cout << pair.second.readpath << ", ";
- std::cout << pair.second.writepath << ", ";
+ std::cout << pair.second.readPath << ", ";
+ std::cout << pair.second.writePath << ", ";
std::cout << pair.second.min << ", ";
std::cout << pair.second.max << ", ";
std::cout << pair.second.timeout << "},\n\t},\n";
@@ -354,7 +354,7 @@
inputs.push_back(shortName);
auto& config = sensorConfig[shortName];
config.type = std::get<std::string>(base.at("Class"));
- config.readpath = sensorPathIfacePair.first;
+ config.readPath = sensorPathIfacePair.first;
// todo: maybe un-hardcode this if we run into slower
// timeouts with sensors
if (config.type == "temp")
@@ -376,7 +376,7 @@
}
auto& config = sensorConfig[otherSensor];
- config.writepath = sensorPathIfacePair.first;
+ config.writePath = sensorPathIfacePair.first;
// todo: un-hardcode this if there are fans with
// different ranges
config.max = 255;
@@ -481,7 +481,7 @@
inputs.push_back(shortName);
auto& config = sensorConfig[shortName];
- config.readpath = sensorPathIfacePair.first;
+ config.readPath = sensorPathIfacePair.first;
config.type = "temp";
// todo: maybe un-hardcode this if we run into slower
// timeouts with sensors
diff --git a/examples/swampd.conf b/examples/swampd.conf
index c4fab5e..fd492ee 100644
--- a/examples/swampd.conf
+++ b/examples/swampd.conf
@@ -2,55 +2,55 @@
sensors = (
{ name = "fan1"
type = "fan"
- readpath = "/xyz/openbmc_project/sensors/fan_tach/fan1"
- writepath = "/sys/class/hwmon/hwmon0/pwm0"
+ readPath = "/xyz/openbmc_project/sensors/fan_tach/fan1"
+ writePath = "/sys/class/hwmon/hwmon0/pwm0"
min = 0
{ name = "fan2"
type = "fan"
- readpath = "/xyz/openbmc_project/sensors/fan_tach/fan2"
- writepath = "/sys/class/hwmon/hwmon0/pwm1"
+ readPath = "/xyz/openbmc_project/sensors/fan_tach/fan2"
+ writePath = "/sys/class/hwmon/hwmon0/pwm1"
min = 0
max = 255
timeout = 0 },
{ name = "fan3"
type = "fan"
- readpath = "/xyz/openbmc_project/sensors/fan_tach/fan3"
- writepath = "/sys/class/hwmon/hwmon0/pwm2"
+ readPath = "/xyz/openbmc_project/sensors/fan_tach/fan3"
+ writePath = "/sys/class/hwmon/hwmon0/pwm2"
min = 0
max = 255
timeout = 0 },
{ name = "fan4"
type = "fan"
- readpath = "/xyz/openbmc_project/sensors/fan_tach/fan4"
- writepath = "/sys/class/hwmon/hwmon0/pwm3"
+ readPath = "/xyz/openbmc_project/sensors/fan_tach/fan4"
+ writePath = "/sys/class/hwmon/hwmon0/pwm3"
min = 0
max = 255
timeout = 0 },
{ name = "fan5"
type = "fan"
- readpath = "/xyz/openbmc_project/sensors/fan_tach/fan5"
- writepath = ""
+ readPath = "/xyz/openbmc_project/sensors/fan_tach/fan5"
+ writePath = ""
min = 0
max = 0
timeout = 0 },
{ name = "fan6"
type = "fan"
- readpath = "/xyz/openbmc_project/sensors/fan_tach/fan6"
- writepath = ""
+ readPath = "/xyz/openbmc_project/sensors/fan_tach/fan6"
+ writePath = ""
min = 0
max = 0
timeout = 0 },
{ name = "fan7"
type = "fan"
- readpath = "/xyz/openbmc_project/sensors/fan_tach/fan7"
- writepath = ""
+ readPath = "/xyz/openbmc_project/sensors/fan_tach/fan7"
+ writePath = ""
min = 0
max = 0
timeout = 0 },
{ name = "fan8"
type = "fan"
- readpath = "/xyz/openbmc_project/sensors/fan_tach/fan8"
- writepath = ""
+ readPath = "/xyz/openbmc_project/sensors/fan_tach/fan8"
+ writePath = ""
min = 0
max = 0
timeout = 0 }
diff --git a/scripts/README b/scripts/README
index f884fc6..8695774 100644
--- a/scripts/README
+++ b/scripts/README
@@ -5,7 +5,7 @@
accessor. This provides read-only access to information. The goal of the
configuration is to specify how it can be read and if it's a fan, how the PID
output can be written. Initially there'll only be sysfs and passive dbus
-access. If a writepath for a sensor is a dbus path, then the system will need
+access. If a writePath for a sensor is a dbus path, then the system will need
to verify which Control.Fan* interfaces is registered and send values to the
Target property of that interface.
@@ -14,7 +14,7 @@
fan PID control objects may not, and they can leave the fields as 0 & 0.
The only requirement for a sensor is that it isn't writeonly. Only fans are
-expected to have a writepath set, and in this current version non-fan sensors
+expected to have a writePath set, and in this current version non-fan sensors
are assumed readonly.
The sensor names are unique across all zones.
diff --git a/scripts/sensor-example.txt b/scripts/sensor-example.txt
index 0915163..b1318b8 100644
--- a/scripts/sensor-example.txt
+++ b/scripts/sensor-example.txt
@@ -1,9 +1,9 @@
fan2: /* Name of the sensor. */
type: fan /* Type of sensor, fan, temp, margin */
/* How the sensor can be read[1] */
- readpath: /xyz/openbmc_project/sensors/fan_tach/fan2
+ readPath: /xyz/openbmc_project/sensors/fan_tach/fan2
/* How the sensor can be set[2] */
- writepath: /sys/class/hwmon/hwmon0/pwm1
+ writePath: /sys/class/hwmon/hwmon0/pwm1
/* The minimum value used for scaling writes (int64) */
min: 0
/* The maximum value used for scaling writes (int64) */
@@ -13,7 +13,7 @@
*/
timeout: 0
-[1] readpath has multiple options:
+[1] readPath has multiple options:
* If it has "/xyz/openbmc_project/extsensors/" in it, it's an EXTERNAL or
host-provided sensor.
* If it has "/xyz/openbmc_project/" in it, it's a sensor whose value is
diff --git a/scripts/sensor-example.yaml b/scripts/sensor-example.yaml
index 7378bff..1debe3e 100644
--- a/scripts/sensor-example.yaml
+++ b/scripts/sensor-example.yaml
@@ -1,31 +1,31 @@
fan2:
type: fan
- readpath: /xyz/openbmc_project/sensors/fan_tach/fan2
- writepath: /sys/class/hwmon/hwmon0/pwm1
+ readPath: /xyz/openbmc_project/sensors/fan_tach/fan2
+ writePath: /sys/class/hwmon/hwmon0/pwm1
min: 0
max: 255
timeout: 0
fan6:
type: fan
- readpath: /xyz/openbmc_project/sensors/fan_tach/fan6
- writepath:
+ readPath: /xyz/openbmc_project/sensors/fan_tach/fan6
+ writePath:
min: 0
max: 0
timeout: 0
temp1:
type: temp
- readpath: /xyz/openbmc_project/sensors/temperature/temp1
- writepath:
+ readPath: /xyz/openbmc_project/sensors/temperature/temp1
+ writePath:
min: 0
max: 0
timeout: 0
sluggish0:
type: margin
- readpath: /xyz/openbmc_project/extsensors/margin/sluggish0
- writepath:
+ readPath: /xyz/openbmc_project/extsensors/margin/sluggish0
+ writePath:
min: 0
max: 0
timeout: 0
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
index 70cd019..56e7965 100644
--- a/scripts/writesensor.mako.cpp
+++ b/scripts/writesensor.mako.cpp
@@ -12,8 +12,8 @@
<%
sensor = sensorDict[key]
type = sensor["type"]
- readpath = sensor["readpath"]
- writepath = sensor.get("writepath", "")
+ readPath = sensor["readPath"]
+ writePath = sensor.get("writePath", "")
min = sensor.get("min", 0)
max = sensor.get("max", 0)
# Presently only thermal inputs have their timeout
@@ -27,7 +27,7 @@
timeout = sensor.get("timeout", 2)
%>
{"${key}",
- {"${type}","${readpath}","${writepath}", ${min}, ${max}, ${timeout}},
+ {"${type}","${readPath}","${writePath}", ${min}, ${max}, ${timeout}},
},
% endif
% endfor
diff --git a/sensors/builder.cpp b/sensors/builder.cpp
index 966a581..4ba1837 100644
--- a/sensors/builder.cpp
+++ b/sensors/builder.cpp
@@ -53,10 +53,10 @@
const struct SensorConfig* info = &it.second;
std::cerr << "Sensor: " << name << " " << info->type << " ";
- std::cerr << info->readpath << " " << info->writepath << "\n";
+ std::cerr << info->readPath << " " << info->writePath << "\n";
- IOInterfaceType rtype = getReadInterfaceType(info->readpath);
- IOInterfaceType wtype = getWriteInterfaceType(info->writepath);
+ IOInterfaceType rtype = getReadInterfaceType(info->readPath);
+ IOInterfaceType wtype = getWriteInterfaceType(info->writePath);
// fan sensors can be ready any way and written others.
// fan sensors are the only sensors this is designed to write.
@@ -80,7 +80,7 @@
// These are a special case for read-only.
break;
case IOInterfaceType::SYSFS:
- ri = std::make_unique<SysFsRead>(info->readpath);
+ ri = std::make_unique<SysFsRead>(info->readPath);
break;
default:
ri = std::make_unique<WriteOnly>();
@@ -95,11 +95,11 @@
if (info->max > 0)
{
wi = std::make_unique<SysFsWritePercent>(
- info->writepath, info->min, info->max);
+ info->writePath, info->min, info->max);
}
else
{
- wi = std::make_unique<SysFsWrite>(info->writepath,
+ wi = std::make_unique<SysFsWrite>(info->writePath,
info->min, info->max);
}
@@ -108,19 +108,19 @@
if (info->max > 0)
{
wi = DbusWritePercent::createDbusWrite(
- info->writepath, info->min, info->max, helper);
+ info->writePath, info->min, info->max, helper);
}
else
{
wi = DbusWrite::createDbusWrite(
- info->writepath, info->min, info->max, helper);
+ info->writePath, info->min, info->max, helper);
}
if (wi == nullptr)
{
throw SensorBuildException(
"Unable to create write dbus interface for path: " +
- info->writepath);
+ info->writePath);
}
break;
@@ -137,19 +137,19 @@
{
// These sensors are read-only, but only for this application
// which only writes to fan sensors.
- std::cerr << info->type << " readpath: " << info->readpath << "\n";
+ std::cerr << info->type << " readPath: " << info->readPath << "\n";
if (IOInterfaceType::EXTERNAL == rtype)
{
std::cerr << "Creating HostSensor: " << name
- << " path: " << info->readpath << "\n";
+ << " path: " << info->readPath << "\n";
/*
* The reason we handle this as a HostSensor is because it's
* not quite pluggable; but maybe it could be.
*/
auto sensor = HostSensor::createTemp(
- name, info->timeout, hostSensorBus, info->readpath.c_str(),
+ name, info->timeout, hostSensorBus, info->readPath.c_str(),
deferSignals);
mgmr.addSensor(info->type, name, std::move(sensor));
}
diff --git a/sensors/builderconfig.cpp b/sensors/builderconfig.cpp
index 0c6ed68..5aa18bc 100644
--- a/sensors/builderconfig.cpp
+++ b/sensors/builderconfig.cpp
@@ -75,8 +75,8 @@
*/
name = sensor.lookup("name").c_str();
thisOne.type = sensor.lookup("type").c_str();
- thisOne.readpath = sensor.lookup("readpath").c_str();
- thisOne.writepath = sensor.lookup("writepath").c_str();
+ thisOne.readPath = sensor.lookup("readPath").c_str();
+ thisOne.writePath = sensor.lookup("writePath").c_str();
/* TODO: Document why this is wonky. The library probably doesn't
* like int64_t
diff --git a/sensors/buildjson.cpp b/sensors/buildjson.cpp
index 4bf5ea7..d62edfd 100644
--- a/sensors/buildjson.cpp
+++ b/sensors/buildjson.cpp
@@ -26,17 +26,17 @@
void from_json(const json& j, SensorConfig& s)
{
j.at("type").get_to(s.type);
- j.at("readpath").get_to(s.readpath);
+ j.at("readPath").get_to(s.readPath);
- /* The writepath field is optional in a configuration */
- auto writepath = j.find("writepath");
- if (writepath == j.end())
+ /* The writePath field is optional in a configuration */
+ auto writePath = j.find("writePath");
+ if (writePath == j.end())
{
- s.writepath = "";
+ s.writePath = "";
}
else
{
- j.at("writepath").get_to(s.writepath);
+ j.at("writePath").get_to(s.writePath);
}
/* The min field is optional in a configuration. */
diff --git a/test/sensors_json_unittest.cpp b/test/sensors_json_unittest.cpp
index 99ab3db..0e8ae71 100644
--- a/test/sensors_json_unittest.cpp
+++ b/test/sensors_json_unittest.cpp
@@ -27,8 +27,8 @@
"sensors": [{
"name": "fan1",
"type": "fan",
- "readpath": "/xyz/openbmc_project/sensors/fan_tach/fan1",
- "writepath": "/sys/devices/platform/ahb/ahb:apb/1e786000.pwm-tacho-controller/hwmon/**/pwm1",
+ "readPath": "/xyz/openbmc_project/sensors/fan_tach/fan1",
+ "writePath": "/sys/devices/platform/ahb/ahb:apb/1e786000.pwm-tacho-controller/hwmon/**/pwm1",
"min": 0,
"max": 255
}]
@@ -38,9 +38,9 @@
auto output = buildSensorsFromJson(j2);
EXPECT_EQ(1, output.size());
EXPECT_EQ(output["fan1"].type, "fan");
- EXPECT_EQ(output["fan1"].readpath,
+ EXPECT_EQ(output["fan1"].readPath,
"/xyz/openbmc_project/sensors/fan_tach/fan1");
- EXPECT_EQ(output["fan1"].writepath,
+ EXPECT_EQ(output["fan1"].writePath,
"/sys/devices/platform/ahb/ahb:apb/1e786000.pwm-tacho-controller/"
"hwmon/**/pwm1");
EXPECT_EQ(output["fan1"].min, 0);
@@ -51,14 +51,14 @@
TEST(SensorsFromJson, validateOptionalFields)
{
- // The writepath, min, max, timeout fields are optional.
+ // The writePath, min, max, timeout fields are optional.
auto j2 = R"(
{
"sensors": [{
"name": "fan1",
"type": "fan",
- "readpath": "/xyz/openbmc_project/sensors/fan_tach/fan1"
+ "readPath": "/xyz/openbmc_project/sensors/fan_tach/fan1"
}]
}
)"_json;
@@ -66,9 +66,9 @@
auto output = buildSensorsFromJson(j2);
EXPECT_EQ(1, output.size());
EXPECT_EQ(output["fan1"].type, "fan");
- EXPECT_EQ(output["fan1"].readpath,
+ EXPECT_EQ(output["fan1"].readPath,
"/xyz/openbmc_project/sensors/fan_tach/fan1");
- EXPECT_EQ(output["fan1"].writepath, "");
+ EXPECT_EQ(output["fan1"].writePath, "");
EXPECT_EQ(output["fan1"].min, 0);
EXPECT_EQ(output["fan1"].max, 0);
EXPECT_EQ(output["fan1"].timeout,
@@ -86,11 +86,11 @@
"sensors": [{
"name": "fan1",
"type": "fan",
- "readpath": "/xyz/openbmc_project/sensors/fan_tach/fan1"
+ "readPath": "/xyz/openbmc_project/sensors/fan_tach/fan1"
}, {
"name": "fan2",
"type": "fan",
- "readpath": "/xyz/openbmc_project/sensors/fan_tach/fan1"
+ "readPath": "/xyz/openbmc_project/sensors/fan_tach/fan1"
}]
}
)"_json;