pseq: Parsing support for i2c_interface element
Add JSON parsing support for the new i2c_interface element in the
phosphor-power-sequencer configuration file.
Tested:
* Ran automated tests.
Change-Id: I2841078b0dd69635dbb6f71461d33d885b380f08
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/phosphor-power-sequencer/src/config_file_parser.cpp b/phosphor-power-sequencer/src/config_file_parser.cpp
index 07566ae..3163aff 100644
--- a/phosphor-power-sequencer/src/config_file_parser.cpp
+++ b/phosphor-power-sequencer/src/config_file_parser.cpp
@@ -118,6 +118,29 @@
return GPIO(line, activeLow);
}
+std::tuple<uint8_t, uint16_t> parseI2CInterface(
+ const nlohmann::json& element,
+ const std::map<std::string, std::string>& variables)
+{
+ verifyIsObject(element);
+ unsigned int propertyCount{0};
+
+ // Required bus property
+ const json& busElement = getRequiredProperty(element, "bus");
+ uint8_t bus = parseUint8(busElement, variables);
+ ++propertyCount;
+
+ // Required address property
+ const json& addressElement = getRequiredProperty(element, "address");
+ uint16_t address = parseHexByte(addressElement, variables);
+ ++propertyCount;
+
+ // Verify no invalid properties exist
+ verifyPropertyCount(element, propertyCount);
+
+ return {bus, address};
+}
+
std::unique_ptr<Rail> parseRail(const json& element)
{
verifyIsObject(element);