2021-07-05 12:09:31 +02:00
|
|
|
#include "Q7STestTask.h"
|
2021-07-06 18:17:32 +02:00
|
|
|
|
2021-07-05 12:09:31 +02:00
|
|
|
#include "fsfw/timemanager/Stopwatch.h"
|
|
|
|
#include "fsfw/tasks/TaskFactory.h"
|
2021-07-06 18:17:32 +02:00
|
|
|
|
2021-07-05 12:09:31 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t Q7STestTask::performOneShotAction() {
|
|
|
|
sdCardTests();
|
|
|
|
return TestTask::performOneShotAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Q7STestTask::sdCardTests() {
|
|
|
|
using namespace std;
|
|
|
|
Stopwatch stopwatch;
|
2021-07-06 18:17:32 +02:00
|
|
|
int result = std::system("q7hw sd info all > /tmp/sd_status.txt");
|
|
|
|
if(result != 0) {
|
|
|
|
sif::debug << "system call failed with " << result << endl;
|
|
|
|
}
|
|
|
|
ifstream sdStatus("/tmp/sd_status.txt");
|
|
|
|
string line;
|
|
|
|
uint8_t idx = 0;
|
|
|
|
while (std::getline(sdStatus, line)) {
|
|
|
|
std::istringstream iss(line);
|
|
|
|
string word;
|
|
|
|
while(iss >> word) {
|
|
|
|
if(word == "on") {
|
|
|
|
sif::info << "SD card " << static_cast<int>(idx) << " is on" << endl;
|
|
|
|
}
|
|
|
|
else if(word == "off") {
|
|
|
|
sif::info << "SD card " << static_cast<int>(idx) << " is off" << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
std::remove("/tmp/sd_status.txt");
|
2021-07-06 11:28:58 +02:00
|
|
|
//TaskFactory::delayTask(3000);
|
2021-07-05 12:09:31 +02:00
|
|
|
//int result = system();
|
|
|
|
//std::fstream fs(testFile);
|
|
|
|
// Read contents from file
|
2021-07-06 11:28:58 +02:00
|
|
|
// char* line = nullptr;
|
|
|
|
// size_t len = 0;
|
|
|
|
// ssize_t read = getline(&line, &len, testFile);
|
|
|
|
// if(read != -1 and line != nullptr) {
|
|
|
|
// cout << line << endl;
|
|
|
|
// }
|
2021-07-05 12:09:31 +02:00
|
|
|
// c = fgetc(testFile);
|
|
|
|
// while (c != EOF)
|
|
|
|
// {
|
|
|
|
// printf ("%c", c);
|
|
|
|
// c = fgetc(testFile);
|
|
|
|
// }
|
|
|
|
// cout << "Info result " << result << endl;
|
|
|
|
// stopwatch.stop(true);
|
|
|
|
// system("q7hw sd set 0 on > /tmp/sd_set.txt");
|
|
|
|
// stopwatch.stop(true);
|
|
|
|
// system("q7hw sd set 0 off > /tmp/sd_set.txt");
|
|
|
|
// stopwatch.stop(true);
|
|
|
|
}
|
2021-07-06 18:17:32 +02:00
|
|
|
|
|
|
|
void Q7STestTask::fileTests() {
|
|
|
|
using namespace std;
|
|
|
|
ofstream testFile("/tmp/test.txt");
|
|
|
|
testFile << "Hallo Welt" << endl;
|
|
|
|
testFile.close();
|
|
|
|
|
|
|
|
system("echo \"Hallo Welt\" > /tmp/test2.txt");
|
|
|
|
system("echo \"Hallo Welt\"");
|
|
|
|
}
|