v1.14.0 #304
@ -9,6 +9,9 @@
|
|||||||
#include <linux/devices/ScexUartReader.h>
|
#include <linux/devices/ScexUartReader.h>
|
||||||
#include <unistd.h> // write(), read(), close()
|
#include <unistd.h> // write(), read(), close()
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "fsfw/globalfunctions/CRC.h"
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
#include "fsfw/globalfunctions/DleEncoder.h"
|
#include "fsfw/globalfunctions/DleEncoder.h"
|
||||||
@ -216,7 +219,7 @@ void UartTestClass::scexPeriodic() {
|
|||||||
// helper.getTotalPacketCounter()) { nach 2min reader->finish();
|
// helper.getTotalPacketCounter()) { nach 2min reader->finish();
|
||||||
if (helper.getCmd() == FRAM) {
|
if (helper.getCmd() == FRAM) {
|
||||||
if (not fileNameSet) {
|
if (not fileNameSet) {
|
||||||
fileId = gen_random(12);
|
fileId = random_string(12);
|
||||||
fileName = "/tmp/scex-fram_" + fileId + ".bin";
|
fileName = "/tmp/scex-fram_" + fileId + ".bin";
|
||||||
fileNameSet = true;
|
fileNameSet = true;
|
||||||
}
|
}
|
||||||
@ -382,18 +385,21 @@ void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) {
|
|||||||
sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl;
|
sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string UartTestClass::gen_random(const int len) {
|
std::string UartTestClass::random_string(std::string::size_type length) {
|
||||||
static const char alphanum[] =
|
static auto& chrs =
|
||||||
"0123456789"
|
"0123456789"
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
"abcdefghijklmnopqrstuvwxyz";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
std::string tmp_s;
|
thread_local static std::mt19937 rg{std::random_device{}()};
|
||||||
tmp_s.reserve(len);
|
thread_local static std::uniform_int_distribution<std::string::size_type> pick(0,
|
||||||
|
sizeof(chrs) - 2);
|
||||||
|
|
||||||
for (int i = 0; i < len; ++i) {
|
std::string s;
|
||||||
tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)];
|
|
||||||
}
|
s.reserve(length);
|
||||||
|
|
||||||
return tmp_s;
|
while (length--) s += chrs[pick(rg)];
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class UartTestClass : public TestTask {
|
|||||||
|
|
||||||
static void foundDlePacketHandler(const DleParser::Context& ctx);
|
static void foundDlePacketHandler(const DleParser::Context& ctx);
|
||||||
void handleFoundDlePacket(uint8_t* packet, size_t len);
|
void handleFoundDlePacket(uint8_t* packet, size_t len);
|
||||||
std::string gen_random(const int len);
|
std::string random_string(std::string::size_type length);
|
||||||
|
|
||||||
std::string fileId = "";
|
std::string fileId = "";
|
||||||
std::string fileName = "";
|
std::string fileName = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user