Prevent termination on OCC open/read/write errors

Instead of creating an elog and terminating, the code will now retry on
a Open/Read/Write failure and if it continues to fail, it will return a
CommFailure to the caller. Then the caller of can determine how to
handle (reset PM complex or ignore).
Normally all communication errors with the OCC should trigger an OCC
reset.

Change-Id: Ibf272270156edae565231ca429f15e8fca2f15bc
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/occ_status.cpp b/occ_status.cpp
index 9e65155..b79fff4 100644
--- a/occ_status.cpp
+++ b/occ_status.cpp
@@ -212,6 +212,9 @@
                 "Status::occsWentActive: OCC mode change failed with status {}",
                 status)
                 .c_str());
+
+        // Disable and reset to try recovering
+        deviceError();
     }
 
     status = pmode->sendIpsData();
@@ -222,6 +225,12 @@
                 "Status::occsWentActive: Sending Idle Power Save Config data failed with status {}",
                 status)
                 .c_str());
+
+        if (status == CmdStatus::COMM_FAILURE)
+        {
+            // Disable and reset to try recovering
+            deviceError();
+        }
     }
 }
 
@@ -269,7 +278,7 @@
             {
                 log<level::ERR>(
                     fmt::format(
-                        "sendAmbient: SEND_AMBIENT failed with status 0x{:02X}",
+                        "sendAmbient: SEND_AMBIENT failed with rspStatus 0x{:02X}",
                         rsp[2])
                         .c_str());
                 dump_hex(rsp);
@@ -278,21 +287,27 @@
         }
         else
         {
-            log<level::ERR>("sendAmbient: INVALID SEND_AMBIENT response");
+            log<level::ERR>(
+                fmt::format(
+                    "sendAmbient: INVALID SEND_AMBIENT response length:{}",
+                    rsp.size())
+                    .c_str());
             dump_hex(rsp);
             status = CmdStatus::FAILURE;
         }
     }
     else
     {
-        if (status == CmdStatus::OPEN_FAILURE)
+        log<level::ERR>(
+            fmt::format(
+                "sendAmbient: SEND_AMBIENT FAILED! with status 0x{:02X}",
+                status)
+                .c_str());
+
+        if (status == CmdStatus::COMM_FAILURE)
         {
-            // OCC not active yet
-            status = CmdStatus::SUCCESS;
-        }
-        else
-        {
-            log<level::ERR>("sendAmbient: SEND_AMBIENT FAILED!");
+            // Disable and reset to try recovering
+            deviceError();
         }
     }