stated to implement threading
This commit is contained in:
39
src/TUI/tui.cpp
Normal file
39
src/TUI/tui.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file tui.cpp
|
||||
* @brief display user interface
|
||||
* @author hendrik schutter
|
||||
* @date 03.08.2020
|
||||
*/
|
||||
/*
|
||||
#include "../include/reHDD.h"
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief wipe drive with shred
|
||||
* \param pointer of Drive instance
|
||||
* \return void
|
||||
*/
|
||||
/*
|
||||
void TUI::initTUI()
|
||||
{
|
||||
initscr();
|
||||
raw();
|
||||
keypad(stdscr,TRUE);
|
||||
if(has_colors() == TRUE) {
|
||||
start_color();
|
||||
} else {
|
||||
printf("Your terminal does not support color\n");
|
||||
exit(1);
|
||||
}
|
||||
clear();
|
||||
curs_set(0);
|
||||
init_color(COLOR_GRAY, 173, 170, 173);
|
||||
}
|
||||
|
||||
void TUI::updateTUI(TUI_DATA data){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}*/
|
29
src/TUI/tui_data.cpp
Normal file
29
src/TUI/tui_data.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @file tui.cpp
|
||||
* @brief display user interface
|
||||
* @author hendrik schutter
|
||||
* @date 03.08.2020
|
||||
*/
|
||||
|
||||
//#include "../include/reHDD.h"
|
||||
|
||||
/*
|
||||
|
||||
TUI_DATA::TUI_DATA(vector <Drive>* pvecDrives)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
cout << "refurbishingHddTool" << endl;
|
||||
// cout << "refurbishingHddTool" << endl;
|
||||
|
||||
reHDD* app = new reHDD();
|
||||
app->app_logic();
|
||||
|
@ -7,6 +7,9 @@
|
||||
|
||||
#include "../include/reHDD.h"
|
||||
|
||||
|
||||
static int fd[2];//File descriptor for creating a pipe
|
||||
|
||||
/**
|
||||
* \brief app constructor
|
||||
* \param void
|
||||
@ -26,10 +29,44 @@ void reHDD::app_logic(void)
|
||||
{
|
||||
cout << "app logic" << endl;
|
||||
|
||||
searchDrives(&vecDrives); //search for new drives and store them in list
|
||||
filterIgnoredDrives(&vecDrives); //filter out ignored drives
|
||||
addSMARTData(&vecDrives); //add S.M.A.R.T. Data to the drives
|
||||
printDrives(&vecDrives); //print currently attached drives
|
||||
thread thDevices(ThreadDevices);
|
||||
|
||||
|
||||
//searchDrives(&vecDrives); //search for new drives and store them in list
|
||||
//filterIgnoredDrives(&vecDrives); //filter out ignored drives
|
||||
//addSMARTData(&vecDrives); //add S.M.A.R.T. Data to the drives
|
||||
// printDrives(&vecDrives); //print currently attached drives
|
||||
|
||||
|
||||
|
||||
int result = pipe (fd);
|
||||
|
||||
while(1){
|
||||
char ch;
|
||||
|
||||
|
||||
result = read (fd[0],&ch,1);
|
||||
|
||||
if (result != 1) {
|
||||
perror("read");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
printf ("From Main Thread: %c\n", ch);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
thDevices.join();
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
size_t u64SelectedDriveIndex = 0U;
|
||||
size_t u64DriveVecSize = (vecDrives.size());
|
||||
@ -39,18 +76,60 @@ void reHDD::app_logic(void)
|
||||
cout << "Selected drive index: " << u64SelectedDriveIndex << endl;
|
||||
|
||||
if(u64SelectedDriveIndex < (u64DriveVecSize)) {
|
||||
Wipe::wipeDrive(&vecDrives[u64SelectedDriveIndex]);
|
||||
// Wipe::wipeDrive(&vecDrives[u64SelectedDriveIndex]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void reHDD::ThreadDevices(){
|
||||
|
||||
|
||||
|
||||
while(true){
|
||||
|
||||
cout << "Thread" << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int result = write (fd[1], "A",1);
|
||||
//cout << result << endl;
|
||||
if (result != 1){
|
||||
perror ("write error");
|
||||
// exit (2);
|
||||
}
|
||||
|
||||
sleep(5); //sleep 5 sec
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief search attached drives on /dev/sd*
|
||||
* \param pointer of vector <Drive>* pvecDrives
|
||||
* \return void
|
||||
*/
|
||||
void reHDD::searchDrives(vector <Drive>* pvecDrives)
|
||||
void reHDD::searchDrives(vector <Drive>* pvecDrives)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cout << "search drives ..." << endl;
|
||||
char * cLine = NULL;
|
||||
size_t len = 0;
|
||||
@ -71,6 +150,8 @@ void reHDD::searchDrives(vector <Drive>* pvecDrives)
|
||||
}
|
||||
}
|
||||
fclose(outputfileHwinfo);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user