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 << "Serial: " << it->getSerial() << endl;
cout << "PowerOnHours: " << it->getPowerOnHours() << endl;
cout << "SpinUpCount: " << it->getSpinUpCount() << endl;
cout << "PowerCycle: " << it->getPowerCycles() << endl;
cout << "ErrorCount: " << it->getErrorCount() << endl;
cout << endl;
}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
refurbishingHddTool: main.o app.o drive.o smart.o
g++ -Wall -o refurbishingHddTool main.o app.o drive.o smart.o
reHDD: main.o app.o drive.o smart.o
g++ -Wall -o reHDD main.o app.o drive.o smart.o
main.o: main.cpp
g++ -c main.cpp
@ -14,4 +14,4 @@ smart.o: smart.cpp
g++ -c smart.cpp
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": {
"time_t": 1588373001,
"asctime": "Sat May 2 00:43:21 2020 CEST"
"time_t": 1588412611,
"asctime": "Sat May 2 11:43:31 2020 CEST"
},
"smart_status": {
"passed": true
@ -136,7 +136,7 @@
{
"id": 3,
"name": "Spin_Up_Time",
"value": 182,
"value": 183,
"worst": 178,
"thresh": 21,
"when_failed": "",
@ -151,8 +151,8 @@
"auto_keep": true
},
"raw": {
"value": 5858,
"string": "5858"
"value": 5850,
"string": "5850"
}
},
{
@ -173,8 +173,8 @@
"auto_keep": true
},
"raw": {
"value": 730,
"string": "730"
"value": 731,
"string": "731"
}
},
{
@ -305,8 +305,8 @@
"auto_keep": true
},
"raw": {
"value": 711,
"string": "711"
"value": 712,
"string": "712"
}
},
{
@ -327,8 +327,8 @@
"auto_keep": true
},
"raw": {
"value": 350,
"string": "350"
"value": 351,
"string": "351"
}
},
{
@ -349,14 +349,14 @@
"auto_keep": true
},
"raw": {
"value": 21650,
"string": "21650"
"value": 21656,
"string": "21656"
}
},
{
"id": 194,
"name": "Temperature_Celsius",
"value": 114,
"value": 120,
"worst": 86,
"thresh": 0,
"when_failed": "",
@ -371,8 +371,8 @@
"auto_keep": true
},
"raw": {
"value": 36,
"string": "36"
"value": 30,
"string": "30"
}
},
{
@ -490,9 +490,9 @@
"power_on_time": {
"hours": 1227
},
"power_cycle_count": 711,
"power_cycle_count": 712,
"temperature": {
"current": 36
"current": 30
},
"ata_smart_error_log": {
"summary": {

BIN
src/reHDD Executable file

Binary file not shown.

View File

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