v1.14.0 #304

Merged
muellerr merged 366 commits from develop into main 2022-10-10 17:46:38 +02:00
5 changed files with 47 additions and 34 deletions
Showing only changes of commit e11c84a5ed - Show all commits

View File

@ -156,7 +156,7 @@ void UartTestClass::scexInit() {
std::string devname = "/dev/ul-scex";
#endif
uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096);
reader->setDebugMode(true);
reader->setDebugMode(false);
ReturnValue_t result = reader->initializeInterface(uartCookie);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "UartTestClass::gpsPeriodic: Initializing SCEX reader "
@ -186,9 +186,11 @@ void UartTestClass::scexPeriodic() {
if (cmdSent and not cmdDone) {
uint8_t* decodedPacket = nullptr;
size_t len = 0;
do {
ReturnValue_t result = reader->readReceivedMessage(uartCookie, &decodedPacket, &len);
if (len > 0) {
if(len == 0){
break;
}
ScexHelper helper;
const uint8_t* helperPtr = decodedPacket;
result = helper.deSerialize(&helperPtr, &len);
@ -207,15 +209,25 @@ void UartTestClass::scexPeriodic() {
out << helper;
}
// fram
//packetcounter eins höher, wenn mehr packet verloren ->
//countdown (max 2min), wenn nicht if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { nach 2min reader->finish();
// 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?
// countdown (max 2min), wenn nicht if (helper.getPacketCounter() ==
// helper.getTotalPacketCounter()) { nach 2min reader->finish();
if (helper.getCmd() == FRAM) {
if(helper.getPacketCounter() == 0) {
ofstream out("/tmp/scex-fram.bin", ofstream::binary ); // neues file anlegen wie oben ping
if (helper.getPacketCounter() == 1) {
//countdown starten
finishCountdown.resetTimer();
ofstream out("/tmp/scex-fram.bin",
ofstream::binary); // neues file anlegen wie oben ping
} else {
ofstream out("/tmp/scex-fram.bin", ofstream::binary | ofstream::app );// an bestehendes file hinzufügen
ofstream out("/tmp/scex-fram.bin",
ofstream::binary | ofstream::app); // an bestehendes file hinzufügen
out << helper;
}
if(finishCountdown.hasTimedOut()){
reader->finish();
}
}
if (helper.getPacketCounter() == helper.getTotalPacketCounter()) {
@ -226,7 +238,7 @@ void UartTestClass::scexPeriodic() {
cmdSent = false;
}
}
}
} while (len > 0);
}
}
}
@ -313,8 +325,9 @@ void UartTestClass::scexSimplePeriodic() {
<< errno << ", " << strerror(errno) << "]" << std::endl;
break;
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large enough"
<< std::endl;
sif::debug << "UartTestClass::performPeriodicAction: recv buffer might not be large "
"enough, bytes read:"
<< bytesRead << std::endl;
} else if (bytesRead > 0) {
dleParser->passData(recBuf.data(), bytesRead);
if (currCmd == ScexCmds::PING) {

View File

@ -4,6 +4,7 @@
#include <fsfw/container/SimpleRingBuffer.h>
#include <fsfw/globalfunctions/DleEncoder.h>
#include <fsfw/globalfunctions/DleParser.h>
#include <fsfw/timemanager/Countdown.h>
#include <fsfw_hal/linux/uart/UartCookie.h>
#include <termios.h> // Contains POSIX terminal control definitions
@ -46,6 +47,7 @@ class UartTestClass : public TestTask {
static void foundDlePacketHandler(const DleParser::Context& ctx);
void handleFoundDlePacket(uint8_t* packet, size_t len);
Countdown finishCountdown = Countdown(180 * 1000);
bool cmdSent = false;
bool cmdDone = false;
scex::ScexCmds currCmd = scex::ScexCmds::PING;
@ -59,7 +61,7 @@ class UartTestClass : public TestTask {
bool startFound = false;
ScexUartReader* reader = nullptr;
std::array<uint8_t, 64> cmdBuf = {};
std::array<uint8_t, 524> recBuf = {};
std::array<uint8_t, 4096> recBuf = {};
ScexDleParser* dleParser;
scex::ScexCmds cmdHelper;
uint8_t recvCnt = 0;

View File

@ -71,7 +71,7 @@ std::ostream& operator<<(std::ostream& os, const ScexHelper& h) {
sif::info << "PacketCounter: " << h.packetCounter << endl;
sif::info << "TotalPacketCount: " << h.totalPacketCounter << endl;
sif::info << "PayloadLength: " << h.payloadLen << endl;
sif::info << "TotalPacketLength: " << h.totalPacketLen << endl;
sif::info << "TotalPacketLength: " << h.totalPacketLen;
return os;
}

View File

@ -45,13 +45,14 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
state = States::IDLE;
break;
}
TaskFactory::delayTask(1000);
TaskFactory::delayTask(400);
} else if (bytesRead < 0) {
sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno
<< ", " << strerror(errno) << "]" << std::endl;
break;
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
sif::error << "ScexUartReader::performOperation: Receive buffer too small for " << bytesRead << " bytes" << std::endl;
sif::error << "ScexUartReader::performOperation: Receive buffer too small for " << bytesRead
<< " bytes" << std::endl;
} else if (bytesRead > 0) {
ReturnValue_t result = dleParser.passData(recBuf.data(), bytesRead);
if (debugMode) {
@ -76,7 +77,6 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) {
return RETURN_FAILED;
}
std::string devname = uartCookie->getDeviceFile();
sif::info << devname << std::endl;
/* Get file descriptor */
serialPort = open(devname.c_str(), O_RDWR);
if (serialPort < 0) {
@ -171,7 +171,7 @@ void ScexUartReader::foundDlePacketHandler(const DleParser::Context &ctx) {
void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
// TODO: insert data into IPC ring buffer here
sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl;
// sif::info << "Detected DLE encoded packet with decoded size " << len << std::endl;
MutexGuard mg(lock);
ReturnValue_t result = ipcQueue.insert(len);
if (result != RETURN_OK) {
@ -181,7 +181,7 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
if (result != RETURN_OK) {
sif::warning << "IPCRingBuf error" << std::endl;
}
sif::info << "DLE handler done" << std::endl;
// sif::info << "DLE handler done" << std::endl;
}
ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
@ -191,7 +191,6 @@ ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **bu
*size = 0;
return RETURN_OK;
}
sif::info << "returning data" << std::endl;
ipcQueue.retrieve(size);
*buffer = ipcBuffer.data();
ReturnValue_t result = ipcRingBuf.readData(ipcBuffer.data(), *size, true);

View File

@ -37,7 +37,6 @@ class ScexUartReader : public SystemObject, // strg+shift+n
DleEncoder dleEncoder = DleEncoder();
SimpleRingBuffer decodeRingBuf;
Countdown finishCountdown = Countdown(180 * 1000);
std::array<uint8_t, 256> cmdbuf = {};
std::array<uint8_t, 4096> recBuf = {};
std::array<uint8_t, 4096> encodedBuf = {};