changed capacity to uint64

This commit is contained in:
Hendrik Schutter 2020-05-02 13:25:27 +02:00
parent dc93ccf1a5
commit 5cf9a2c86f
8 changed files with 47 additions and 48 deletions

View File

@ -167,7 +167,7 @@ void App::printDrives(list <Drive> *listDrives)
cout << "Capacity: " << it->getCapacity() << endl; cout << "Capacity: " << it->getCapacity() << endl;
cout << "Serial: " << it->getSerial() << endl; cout << "Serial: " << it->getSerial() << endl;
cout << "PowerOnHours: " << it->getPowerOnHours() << endl; cout << "PowerOnHours: " << it->getPowerOnHours() << endl;
cout << "SpinUpCount: " << it->getSpinUpCount() << endl; cout << "PowerCycle: " << it->getPowerCycles() << endl;
cout << "ErrorCount: " << it->getErrorCount() << endl; cout << "ErrorCount: " << it->getErrorCount() << endl;
cout << endl; cout << endl;
} }

View File

@ -28,9 +28,9 @@ string Drive::getSerial(void)
return sSerial; return sSerial;
} }
string Drive::getCapacity(void) uint64_t Drive::getCapacity(void)
{ {
return sCapacity; return u64Capacity;
} }
uint32_t Drive::getErrorCount(void) uint32_t Drive::getErrorCount(void)
@ -42,24 +42,24 @@ uint32_t Drive::getPowerOnHours(void)
return u32PowerOnHours; return u32PowerOnHours;
} }
uint32_t Drive::getSpinUpCount(void) uint32_t Drive::getPowerCycles(void)
{ {
return u32SpinUpCount; return u32PowerCycles;
} }
void Drive::setDriveSMARTData( string modelFamily, void Drive::setDriveSMARTData( string modelFamily,
string modelName, string modelName,
string serial, string serial,
string capacity, uint64_t capacity,
uint32_t errorCount, uint32_t errorCount,
uint32_t powerOnHours, uint32_t powerOnHours,
uint32_t spinUpCount) uint32_t powerCycle)
{ {
sModelFamily = modelFamily; sModelFamily = modelFamily;
sModelName = modelName; sModelName = modelName;
sSerial = serial; sSerial = serial;
sCapacity = capacity; u64Capacity = capacity;
u32ErrorCount = errorCount; u32ErrorCount = errorCount;
u32PowerOnHours = powerOnHours; u32PowerOnHours = powerOnHours;
u32SpinUpCount = spinUpCount; u32PowerCycles = powerCycle;
} }

View File

@ -22,29 +22,28 @@ public:
string getModelFamily(void); string getModelFamily(void);
string getModelName(void); string getModelName(void);
string getSerial(void); string getSerial(void);
string getCapacity(void); uint64_t getCapacity(void); //in byte
uint32_t getErrorCount(void); uint32_t getErrorCount(void);
uint32_t getPowerOnHours(void); uint32_t getPowerOnHours(void); //in hours
uint32_t getSpinUpCount(void); uint32_t getPowerCycles(void);
void setDriveSMARTData( string modelFamily, void setDriveSMARTData( string modelFamily,
string modelName, string modelName,
string serial, string serial,
string capacity, uint64_t capacity,
uint32_t errorCount, uint32_t errorCount,
uint32_t powerOnHours, uint32_t powerOnHours,
uint32_t spinUpCount); uint32_t powerCycles);
private: private:
string sPath; string sPath;
string sModelFamily; string sModelFamily;
string sModelName; string sModelName;
string sSerial; string sSerial;
string sCapacity; uint64_t u64Capacity = 0U; //in byte
uint32_t u32ErrorCount; uint32_t u32ErrorCount = 0U;
uint32_t u32PowerOnHours; uint32_t u32PowerOnHours = 0U; //in hours
uint32_t u32SpinUpCount; uint32_t u32PowerCycles = 0U;
}; };
#endif // DRIVE_H_ #endif // DRIVE_H_

View File

@ -1,5 +1,5 @@
refurbishingHddTool: main.o app.o drive.o smart.o reHDD: main.o app.o drive.o smart.o
g++ -Wall -o refurbishingHddTool main.o app.o drive.o smart.o g++ -Wall -o reHDD main.o app.o drive.o smart.o
main.o: main.cpp main.o: main.cpp
g++ -c main.cpp g++ -c main.cpp
@ -14,4 +14,4 @@ smart.o: smart.cpp
g++ -c smart.cpp g++ -c smart.cpp
clean : clean :
rm refurbishingHddTool main.o app.o drive.o smart.o rm reHDD main.o app.o drive.o smart.o

View File

@ -59,8 +59,8 @@
} }
}, },
"local_time": { "local_time": {
"time_t": 1588373001, "time_t": 1588412611,
"asctime": "Sat May 2 00:43:21 2020 CEST" "asctime": "Sat May 2 11:43:31 2020 CEST"
}, },
"smart_status": { "smart_status": {
"passed": true "passed": true
@ -136,7 +136,7 @@
{ {
"id": 3, "id": 3,
"name": "Spin_Up_Time", "name": "Spin_Up_Time",
"value": 182, "value": 183,
"worst": 178, "worst": 178,
"thresh": 21, "thresh": 21,
"when_failed": "", "when_failed": "",
@ -151,8 +151,8 @@
"auto_keep": true "auto_keep": true
}, },
"raw": { "raw": {
"value": 5858, "value": 5850,
"string": "5858" "string": "5850"
} }
}, },
{ {
@ -173,8 +173,8 @@
"auto_keep": true "auto_keep": true
}, },
"raw": { "raw": {
"value": 730, "value": 731,
"string": "730" "string": "731"
} }
}, },
{ {
@ -305,8 +305,8 @@
"auto_keep": true "auto_keep": true
}, },
"raw": { "raw": {
"value": 711, "value": 712,
"string": "711" "string": "712"
} }
}, },
{ {
@ -327,8 +327,8 @@
"auto_keep": true "auto_keep": true
}, },
"raw": { "raw": {
"value": 350, "value": 351,
"string": "350" "string": "351"
} }
}, },
{ {
@ -349,14 +349,14 @@
"auto_keep": true "auto_keep": true
}, },
"raw": { "raw": {
"value": 21650, "value": 21656,
"string": "21650" "string": "21656"
} }
}, },
{ {
"id": 194, "id": 194,
"name": "Temperature_Celsius", "name": "Temperature_Celsius",
"value": 114, "value": 120,
"worst": 86, "worst": 86,
"thresh": 0, "thresh": 0,
"when_failed": "", "when_failed": "",
@ -371,8 +371,8 @@
"auto_keep": true "auto_keep": true
}, },
"raw": { "raw": {
"value": 36, "value": 30,
"string": "36" "string": "30"
} }
}, },
{ {
@ -490,9 +490,9 @@
"power_on_time": { "power_on_time": {
"hours": 1227 "hours": 1227
}, },
"power_cycle_count": 711, "power_cycle_count": 712,
"temperature": { "temperature": {
"current": 36 "current": 30
}, },
"ata_smart_error_log": { "ata_smart_error_log": {
"summary": { "summary": {

BIN
src/reHDD Executable file

Binary file not shown.

View File

@ -10,10 +10,10 @@
string SMART::modelFamily; string SMART::modelFamily;
string SMART::modelName; string SMART::modelName;
string SMART::serial; string SMART::serial;
string SMART::capacity; uint64_t SMART::capacity = 0U;
uint32_t SMART::errorCount = 0U; uint32_t SMART::errorCount = 0U;
uint32_t SMART::powerOnHours = 0U; uint32_t SMART::powerOnHours = 0U;
uint32_t SMART::spinUpCount = 0U; uint32_t SMART::powerCycle = 0U;
void SMART::readSMARTData(Drive drive) void SMART::readSMARTData(Drive drive)
{ {
@ -35,7 +35,7 @@ void SMART::readSMARTData(Drive drive)
SMART::parseCapacity(sLine); SMART::parseCapacity(sLine);
SMART::parseErrorCount(sLine); SMART::parseErrorCount(sLine);
SMART::parsePowerOnHours(sLine); SMART::parsePowerOnHours(sLine);
SMART::parseSpinUpCount(sLine); SMART::parsePowerCycle(sLine);
} }
fclose(outputfileSmart); fclose(outputfileSmart);
//drive.setDriveSMARTData(modelFamily, modelName, serial, capacity, errorCount, powerOnHours, spinUpCount); //drive.setDriveSMARTData(modelFamily, modelName, serial, capacity, errorCount, powerOnHours, spinUpCount);
@ -119,7 +119,7 @@ string search("\"hours\": ");
} }
} }
void SMART::parseSpinUpCount(string sLine) void SMART::parsePowerCycle(string sLine)
{ {
string search("\"power_cycle_count\": "); string search("\"power_cycle_count\": ");
size_t found = sLine.find(search); size_t found = sLine.find(search);
@ -128,7 +128,7 @@ string search("\"power_cycle_count\": ");
sLine.erase(0, sLine.find(": ") + 2); sLine.erase(0, sLine.find(": ") + 2);
sLine.erase(sLine.length()-2, 2); sLine.erase(sLine.length()-2, 2);
//spinUpCount = stoi(sLine); //spinUpCount = stoi(sLine);
cout << "SpinUpCount |" << sLine << "|" << endl; cout << "PowerCycle |" << sLine << "|" << endl;
} }
} }

View File

@ -30,15 +30,15 @@ private:
static void parseCapacity(string sLine); static void parseCapacity(string sLine);
static void parseErrorCount(string sLine); static void parseErrorCount(string sLine);
static void parsePowerOnHours(string sLine); static void parsePowerOnHours(string sLine);
static void parseSpinUpCount(string sLine); static void parsePowerCycle(string sLine);
static string modelFamily; static string modelFamily;
static string modelName; static string modelName;
static string serial; static string serial;
static string capacity; static uint64_t capacity;
static uint32_t errorCount; static uint32_t errorCount;
static uint32_t powerOnHours; static uint32_t powerOnHours;
static uint32_t spinUpCount; static uint32_t powerCycle;
}; };