rework smart module to improve parsing

This commit is contained in:
2026-05-01 14:52:16 +02:00
parent fe08cfe04f
commit 203b4a0c85
2 changed files with 362 additions and 417 deletions
+17 -15
View File
@@ -10,27 +10,29 @@
#include "reHDD.h"
/**
* @brief SMART data reader for drives
*
* Parses smartctl JSON output to extract:
* - Device information (model, serial, capacity)
* - Power statistics (hours, cycles)
* - Temperature
* - Critical sector counts (reallocated, pending, uncorrectable)
*
* Uses deterministic state machine parser for reliable multi-line JSON parsing.
*/
class SMART
{
protected:
public:
/**
* @brief Read S.M.A.R.T. data from drive and populate Drive object
* @param drive Pointer to Drive instance to populate with SMART data
*/
static void readSMARTData(Drive *drive);
private:
SMART(void);
static bool parseExitStatus(std::string sLine, uint8_t &status);
static bool parseModelFamily(std::string sLine, std::string &modelFamily);
static bool parseModelName(std::string sLine, std::string &modelName);
static bool parseSerial(std::string sLine, std::string &serial);
static bool parseCapacity(std::string sLine, uint64_t &capacity);
static bool parseErrorCount(std::string sLine, uint32_t &errorCount);
static bool parsePowerOnHours(std::string sLine, uint32_t &powerOnHours);
static bool parsePowerCycles(std::string sLine, uint32_t &powerCycles);
static bool parseTemperature(std::string sLine, uint32_t &temperature);
static bool parseReallocatedSectors(std::string sLine, uint32_t &reallocatedSectors);
static bool parsePendingSectors(std::string sLine, uint32_t &pendingSectors);
static bool parseUncorrectableSectors(std::string sLine, uint32_t &uncorrectableSectors);
SMART(void); // Utility class - no instances
};
#endif // SMART_H_
#endif // SMART_H_