psu-ng: Add code to set ON_OFF_CONFIG

Add code that sends the appropriate ON_OFF_CONFIG mask for the power
supply power on operation.

Tested:
    Ran gtest using x86sdk
    Used simulator to change ON_OFF_CONFIG value, restarted service,
    verified ON_OFF_CONFIG changed.
    Used i2cget on hardware to change ON_OFF_CONFIG, restarted service,
    verified ON_OFF_CONFIG changed.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: Ifd9d63fcd2e86a62b7358e08958b5e2dbd21db9f
diff --git a/pmbus.cpp b/pmbus.cpp
index d8b1804..b2fe2fd 100644
--- a/pmbus.cpp
+++ b/pmbus.cpp
@@ -303,6 +303,40 @@
     }
 }
 
+void PMBus::writeBinary(const std::string& name, std::vector<uint8_t> data,
+                        Type type)
+{
+    std::ofstream file;
+    fs::path path = getPath(type);
+
+    path /= name;
+
+    file.exceptions(std::ofstream::failbit | std::ofstream::badbit |
+                    std::ofstream::eofbit);
+
+    try
+    {
+        // I need to specify binary mode when I construct the ofstream
+        file.open(path, std::ios::out | std::ios_base::binary);
+        log<level::DEBUG>("Write data to sysfs file",
+                          entry("FILENAME=%s", path.c_str()));
+        file.write(reinterpret_cast<const char*>(&data[0]), data.size());
+    }
+    catch (const std::exception& e)
+    {
+        auto rc = errno;
+
+        log<level::ERR>("Failed to write binary data to sysfs file",
+                        entry("FILENAME=%s", path.c_str()));
+
+        using metadata = xyz::openbmc_project::Common::Device::WriteFailure;
+
+        elog<WriteFailure>(
+            metadata::CALLOUT_ERRNO(rc),
+            metadata::CALLOUT_DEVICE_PATH(fs::canonical(basePath).c_str()));
+    }
+}
+
 void PMBus::findHwmonDir()
 {
     fs::path path{basePath};