diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 27e8d02e..88a0895c 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -217,11 +217,13 @@ void UartTestClass::scexPeriodic() { if (helper.getPacketCounter() == 1) { //countdown starten finishCountdown.resetTimer(); - ofstream out("/tmp/scex-fram.bin", - ofstream::binary); // neues file anlegen wie oben ping + fileId = gen_random(12); + fileName = "/tmp/scex-fram_"+fileId+".bin"; + ofstream out(fileName, + ofstream::binary); // neues file anlegen } else { - ofstream out("/tmp/scex-fram.bin", - ofstream::binary | ofstream::app); // an bestehendes file hinzufügen + ofstream out(fileName, + ofstream::binary | ofstream::app); // an bestehendes file appenden out << helper; } @@ -370,3 +372,19 @@ void UartTestClass::foundDlePacketHandler(const DleParser::Context& ctx) { void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) { sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl; } + +std::string gen_random(const int len) { + static const char alphanum[] = + "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + + std::string tmp_s; + tmp_s.reserve(len); + + for (int i = 0; i < len; ++i) { + tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)]; + } + + return tmp_s; +} diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 28a8b8a7..dad9152e 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -46,7 +46,10 @@ class UartTestClass : public TestTask { static void foundDlePacketHandler(const DleParser::Context& ctx); void handleFoundDlePacket(uint8_t* packet, size_t len); + std::string gen_random(const int len); + std::string fileId = ""; + std::string fileName = ""; Countdown finishCountdown = Countdown(180 * 1000); bool cmdSent = false; bool cmdDone = false;