update
EIVE/eive-obsw/pipeline/head This commit looks good Details

This commit is contained in:
Irini Kosmidou 2022-04-29 13:31:14 +02:00
parent 7c15eb57bb
commit 57f3103e52
2 changed files with 18 additions and 12 deletions

View File

@ -9,6 +9,9 @@
#include <linux/devices/ScexUartReader.h>
#include <unistd.h> // write(), read(), close()
#include <random>
#include <string>
#include "OBSWConfig.h"
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/globalfunctions/DleEncoder.h"
@ -216,7 +219,7 @@ void UartTestClass::scexPeriodic() {
// helper.getTotalPacketCounter()) { nach 2min reader->finish();
if (helper.getCmd() == FRAM) {
if (not fileNameSet) {
fileId = gen_random(12);
fileId = random_string(12);
fileName = "/tmp/scex-fram_" + fileId + ".bin";
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;
}
std::string UartTestClass::gen_random(const int len) {
static const char alphanum[] =
std::string UartTestClass::random_string(std::string::size_type length) {
static auto& chrs =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
std::string tmp_s;
tmp_s.reserve(len);
thread_local static std::mt19937 rg{std::random_device{}()};
thread_local static std::uniform_int_distribution<std::string::size_type> pick(0,
sizeof(chrs) - 2);
for (int i = 0; i < len; ++i) {
tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)];
}
std::string s;
return tmp_s;
s.reserve(length);
while (length--) s += chrs[pick(rg)];
return s;
}

View File

@ -46,7 +46,7 @@ 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 random_string(std::string::size_type length);
std::string fileId = "";
std::string fileName = "";