diff --git a/README.md b/README.md index 63d00b19..9391d883 100644 --- a/README.md +++ b/README.md @@ -576,7 +576,7 @@ When using Eclipse, there are two special build variables in the project propert the sysroot path in those variables to get any additional includes like `gpiod.h` in the Eclipse indexer. -# Q7S Utilities +# Q7S Utilities and Troubleshooting ## Creating files with cat and echo @@ -591,6 +591,17 @@ cat /tmp/test.txt For more useful combinations, see this [link](https://www.freecodecamp.org/news/the-cat-command-in-linux-how-to-create-a-text-file-with-cat-or-touch/). +## Using `system` when debugging + +Please note that when using a `system` call in C++/C code and debugging, a new thread will be +spawned which will appear on the left in Eclipse or Xilinx SDK as a `sh` program. +The debugger might attach to this child process automatically, depending on debugger configuration, +and the process needs to be selected and continued/started manually. You can enable or disable +this behaviour by selecting or deselecting the `Attach Process Children` option in the Remote +Application Configuration for the TCF plugin like shown in the following picture + +
+ ## Libgpiod Detect all gpio device files: @@ -666,9 +677,10 @@ candump can0 ## Useful Q7S Linux Commands Rebooting currently running image: -```` + +```sh xsc_boot_copy -r -```` +``` # Running the EIVE OBSW on a Raspberry Pi diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 55aa7657..6d9964c5 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -1,6 +1,8 @@ #include "Q7STestTask.h" + #include "fsfw/timemanager/Stopwatch.h" #include "fsfw/tasks/TaskFactory.h" + #include #include #include @@ -16,10 +18,27 @@ ReturnValue_t Q7STestTask::performOneShotAction() { void Q7STestTask::sdCardTests() { using namespace std; Stopwatch stopwatch; - ofstream testFile("/tmp/test.txt"); - testFile << "Hallo Welt" << endl; - testFile.close(); - //FILE* testFile = popen("q7hw sd info all", "r"); + 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(idx) << " is on" << endl; + } + else if(word == "off") { + sif::info << "SD card " << static_cast(idx) << " is off" << endl; + } + } + idx++; + } + std::remove("/tmp/sd_status.txt"); //TaskFactory::delayTask(3000); //int result = system(); //std::fstream fs(testFile); @@ -43,3 +62,13 @@ void Q7STestTask::sdCardTests() { // system("q7hw sd set 0 off > /tmp/sd_set.txt"); // stopwatch.stop(true); } + +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\""); +} diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index 4b1aea7e..7056853e 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -10,6 +10,7 @@ private: ReturnValue_t performOneShotAction() override; void sdCardTests(); + void fileTests(); }; diff --git a/doc/img/ProcessSettings.png b/doc/img/ProcessSettings.png new file mode 100644 index 00000000..5a8c3c99 Binary files /dev/null and b/doc/img/ProcessSettings.png differ