v1.14.0 #304
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit cfc00d02607d22ec306d0540f9f2329774df1cdd
|
Subproject commit 49747fc8a49e85e7b3d442eabe668d34e44bad32
|
@ -37,8 +37,9 @@ UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {
|
|||||||
DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()};
|
DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()};
|
||||||
auto decodedBuf = new std::array<uint8_t, 4096>;
|
auto decodedBuf = new std::array<uint8_t, 4096>;
|
||||||
DleParser::BufPair decodingBufPair{decodedBuf->data(), decodedBuf->size()};
|
DleParser::BufPair decodingBufPair{decodedBuf->data(), decodedBuf->size()};
|
||||||
|
// TODO: Code changes but this test class has not, might not work like this anymore
|
||||||
dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair,
|
dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair,
|
||||||
decodingBufPair, &foundDlePacketHandler, this);
|
decodingBufPair);
|
||||||
} else {
|
} else {
|
||||||
reader = new ScexUartReader(objects::SCEX_UART_READER);
|
reader = new ScexUartReader(objects::SCEX_UART_READER);
|
||||||
}
|
}
|
||||||
@ -380,15 +381,6 @@ int UartTestClass::prepareScexCmd(scex::Cmds cmd, bool tempCheck, uint8_t* cmdBu
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UartTestClass::foundDlePacketHandler(const DleParser::Context& ctx) {
|
|
||||||
UartTestClass* obj = reinterpret_cast<UartTestClass*>(ctx.userArgs);
|
|
||||||
if (ctx.getType() == DleParser::ContextType::PACKET_FOUND) {
|
|
||||||
obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second);
|
|
||||||
} else {
|
|
||||||
DleParser::defaultErrorHandler(ctx.error.first, ctx.error.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) {
|
void UartTestClass::handleFoundDlePacket(uint8_t* packet, size_t len) {
|
||||||
sif::info << "UartTestClass::handleFoundDlePacket: Detected DLE encoded packet with decoded size "
|
sif::info << "UartTestClass::handleFoundDlePacket: Detected DLE encoded packet with decoded size "
|
||||||
<< len << std::endl;
|
<< len << std::endl;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "ScexDleParser.h"
|
#include "ScexDleParser.h"
|
||||||
|
|
||||||
ScexDleParser::ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder,
|
ScexDleParser::ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder,
|
||||||
BufPair encodedBuf, BufPair decodedBuf, UserHandler handler,
|
BufPair encodedBuf, BufPair decodedBuf)
|
||||||
void *args)
|
: DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf){};
|
||||||
: DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler, args){};
|
|
||||||
ScexDleParser::~ScexDleParser(){};
|
ScexDleParser::~ScexDleParser(){};
|
||||||
|
@ -5,11 +5,7 @@
|
|||||||
class ScexDleParser : public DleParser {
|
class ScexDleParser : public DleParser {
|
||||||
public:
|
public:
|
||||||
ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, BufPair encodedBuf,
|
ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder, BufPair encodedBuf,
|
||||||
BufPair decodedBuf, UserHandler handler, void *args);
|
BufPair decodedBuf);
|
||||||
// ScexDleParser(SimpleRingBuffer &decodeRingBuf, DleEncoder &decoder,
|
|
||||||
// BufPair encodedBuf, BufPair decodedBuf, UserHandler handler,
|
|
||||||
// void *args) : DleParser(decodeRingBuf, decoder, encodedBuf, decodedBuf, handler,
|
|
||||||
// args){}
|
|
||||||
|
|
||||||
virtual ~ScexDleParser();
|
virtual ~ScexDleParser();
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ ScexUartReader::ScexUartReader(object_id_t objectId)
|
|||||||
ipcRingBuf(200 * 2048, true),
|
ipcRingBuf(200 * 2048, true),
|
||||||
ipcQueue(200),
|
ipcQueue(200),
|
||||||
dleParser(decodeRingBuf, dleEncoder, {encodedBuf.data(), encodedBuf.size()},
|
dleParser(decodeRingBuf, dleEncoder, {encodedBuf.data(), encodedBuf.size()},
|
||||||
{decodedBuf.data(), decodedBuf.size()}, &foundDlePacketHandler, (void *)this) {
|
{decodedBuf.data(), decodedBuf.size()}) {
|
||||||
semaphore = SemaphoreFactory::instance()->createBinarySemaphore();
|
semaphore = SemaphoreFactory::instance()->createBinarySemaphore();
|
||||||
semaphore->acquire();
|
semaphore->acquire();
|
||||||
lock = MutexFactory::instance()->createMutex();
|
lock = MutexFactory::instance()->createMutex();
|
||||||
@ -40,23 +40,27 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
|||||||
bytesRead = read(serialPort, reinterpret_cast<void *>(recBuf.data()),
|
bytesRead = read(serialPort, reinterpret_cast<void *>(recBuf.data()),
|
||||||
static_cast<unsigned int>(recBuf.size()));
|
static_cast<unsigned int>(recBuf.size()));
|
||||||
if (bytesRead == 0) {
|
if (bytesRead == 0) {
|
||||||
|
{
|
||||||
MutexGuard mg(lock);
|
MutexGuard mg(lock);
|
||||||
if (state == States::FINISH) {
|
if (state == States::FINISH) {
|
||||||
state = States::IDLE;
|
state = States::IDLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
size_t bytesRead = 0;
|
size_t bytesRead = 0;
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
while (result != DleParser::NO_PACKET_FOUND) {
|
while (result != DleParser::NO_PACKET_FOUND) {
|
||||||
result = dleParser.parseRingBuf(bytesRead);
|
result = dleParser.parseRingBuf(bytesRead);
|
||||||
if (result == returnvalue::OK) {
|
if (result == returnvalue::OK) {
|
||||||
// Packet found, advance read pointer.
|
// Packet found, advance read pointer.
|
||||||
// currentBytesRead = 0;
|
auto& decodedPacket = dleParser.getContext().decodedPacket;
|
||||||
|
handleFoundDlePacket(decodedPacket.first, decodedPacket.second);
|
||||||
dleParser.confirmBytesRead(bytesRead);
|
dleParser.confirmBytesRead(bytesRead);
|
||||||
} else if (result == DleParser::POSSIBLE_PACKET_LOSS) {
|
} else if (result != DleParser::NO_PACKET_FOUND) {
|
||||||
|
sif::warning << "ScexUartReader::performOperation: Possible packet loss" << std::endl;
|
||||||
// Markers found at wrong place
|
// Markers found at wrong place
|
||||||
// which might be a hint for a possibly lost packet.
|
// which might be a hint for a possibly lost packet.
|
||||||
// currentBytesRead = 0;
|
dleParser.defaultErrorHandler();
|
||||||
dleParser.confirmBytesRead(bytesRead);
|
dleParser.confirmBytesRead(bytesRead);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,15 +181,6 @@ ReturnValue_t ScexUartReader::finish() {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScexUartReader::foundDlePacketHandler(const ScexDleParser::Context &ctx) {
|
|
||||||
ScexUartReader *obj = reinterpret_cast<ScexUartReader *>(ctx.userArgs);
|
|
||||||
if (ctx.getType() == ScexDleParser::ContextType::PACKET_FOUND) {
|
|
||||||
obj->handleFoundDlePacket(ctx.decodedPacket.first, ctx.decodedPacket.second);
|
|
||||||
} else {
|
|
||||||
ScexDleParser::defaultErrorHandler(ctx.error.first, ctx.error.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
|
void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
|
||||||
MutexGuard mg(lock);
|
MutexGuard mg(lock);
|
||||||
ReturnValue_t result = ipcQueue.insert(len);
|
ReturnValue_t result = ipcQueue.insert(len);
|
||||||
|
Loading…
Reference in New Issue
Block a user