v1.14.0 #304
@ -188,8 +188,8 @@ void UartTestClass::scexPeriodic() {
|
|||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
do {
|
do {
|
||||||
ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len);
|
ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len);
|
||||||
if(len == 0){
|
if (len == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ScexHelper helper;
|
ScexHelper helper;
|
||||||
const uint8_t* helperPtr = decodedPacket;
|
const uint8_t* helperPtr = decodedPacket;
|
||||||
@ -210,15 +210,19 @@ void UartTestClass::scexPeriodic() {
|
|||||||
}
|
}
|
||||||
// fram
|
// fram
|
||||||
// packetcounter eins höher, wenn mehr packet verloren -> merkt sich welches packet fehlt
|
// packetcounter eins höher, wenn mehr packet verloren -> merkt sich welches packet fehlt
|
||||||
//was wenn erstes packet fehlt; mit boolean var (firstpacketarrived=false) die immer mit finish false wird?
|
// was wenn erstes packet fehlt; mit boolean var (firstpacketarrived=false) die immer mit
|
||||||
|
// finish false wird?
|
||||||
// countdown (max 2min), wenn nicht if (helper.getPacketCounter() ==
|
// countdown (max 2min), wenn nicht if (helper.getPacketCounter() ==
|
||||||
// helper.getTotalPacketCounter()) { nach 2min reader->finish();
|
// helper.getTotalPacketCounter()) { nach 2min reader->finish();
|
||||||
if (helper.getCmd() == FRAM) {
|
if (helper.getCmd() == FRAM) {
|
||||||
|
if (not fileNameSet) {
|
||||||
|
fileId = gen_random(12);
|
||||||
|
fileName = "/tmp/scex-fram_" + fileId + ".bin";
|
||||||
|
fileNameSet = true;
|
||||||
|
}
|
||||||
if (helper.getPacketCounter() == 1) {
|
if (helper.getPacketCounter() == 1) {
|
||||||
//countdown starten
|
// countdown starten
|
||||||
finishCountdown.resetTimer();
|
finishCountdown.resetTimer();
|
||||||
fileId = gen_random(12);
|
|
||||||
fileName = "/tmp/scex-fram_"+fileId+".bin";
|
|
||||||
ofstream out(fileName,
|
ofstream out(fileName,
|
||||||
ofstream::binary); // neues file anlegen
|
ofstream::binary); // neues file anlegen
|
||||||
} else {
|
} else {
|
||||||
@ -227,8 +231,11 @@ void UartTestClass::scexPeriodic() {
|
|||||||
out << helper;
|
out << helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(finishCountdown.hasTimedOut()){
|
if (finishCountdown.hasTimedOut()) {
|
||||||
reader->finish();
|
reader->finish();
|
||||||
|
sif::warning << "Reader countdown expired" << endl;
|
||||||
|
cmdDone = true;
|
||||||
|
fileNameSet = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,8 +243,10 @@ void UartTestClass::scexPeriodic() {
|
|||||||
reader->finish();
|
reader->finish();
|
||||||
sif::info << "Reader is finished" << endl;
|
sif::info << "Reader is finished" << endl;
|
||||||
cmdDone = true;
|
cmdDone = true;
|
||||||
|
fileNameSet = false;
|
||||||
if (helper.getCmd() == scex::ScexCmds::PING) {
|
if (helper.getCmd() == scex::ScexCmds::PING) {
|
||||||
cmdSent = false;
|
cmdSent = false;
|
||||||
|
fileNameSet = true; // to not generate everytime new file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (len > 0);
|
} while (len > 0);
|
||||||
@ -374,17 +383,17 @@ void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string UartTestClass::gen_random(const int len) {
|
std::string UartTestClass::gen_random(const int len) {
|
||||||
static const char alphanum[] =
|
static const char alphanum[] =
|
||||||
"0123456789"
|
"0123456789"
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"abcdefghijklmnopqrstuvwxyz";
|
"abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
std::string tmp_s;
|
std::string tmp_s;
|
||||||
tmp_s.reserve(len);
|
tmp_s.reserve(len);
|
||||||
|
|
||||||
for (int i = 0; i < len; ++i) {
|
for (int i = 0; i < len; ++i) {
|
||||||
tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)];
|
tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmp_s;
|
return tmp_s;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ class UartTestClass : public TestTask {
|
|||||||
|
|
||||||
std::string fileId = "";
|
std::string fileId = "";
|
||||||
std::string fileName = "";
|
std::string fileName = "";
|
||||||
|
bool fileNameSet = false;
|
||||||
Countdown finishCountdown = Countdown(180 * 1000);
|
Countdown finishCountdown = Countdown(180 * 1000);
|
||||||
bool cmdSent = false;
|
bool cmdSent = false;
|
||||||
bool cmdDone = false;
|
bool cmdDone = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user