NVMeBasicContext: Account for invalid drive status
Respect the drive status bits in the basic management command response
before parsing the drive temperature value, as it may not yet be valid.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I5311eb3b07f9b52fce7342c9c7f670f777d68c1d
diff --git a/src/NVMeBasicContext.cpp b/src/NVMeBasicContext.cpp
index 29dab7a..08333c5 100644
--- a/src/NVMeBasicContext.cpp
+++ b/src/NVMeBasicContext.cpp
@@ -397,6 +397,15 @@
}
uint8_t* messageData = static_cast<uint8_t*>(msg);
+
+ uint8_t status = messageData[0];
+ if ((status & NVME_MI_BASIC_SFLGS_DRIVE_NOT_READY) ||
+ !(status & NVME_MI_BASIC_SFLGS_DRIVE_FUNCTIONAL))
+ {
+ sensor->markFunctional(false);
+ return;
+ }
+
double value = getTemperatureReading(messageData[2]);
if (!std::isfinite(value))
{