refactor DLE parsing and move semaphore release up top
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
parent
68fdb68fe6
commit
0c389177e3
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit c47bed07606548fd2510caa45bdd9fc867732065
|
Subproject commit cfc00d02607d22ec306d0540f9f2329774df1cdd
|
@ -35,6 +35,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
semaphore->acquire();
|
semaphore->acquire();
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
|
// debugMode = true;
|
||||||
while (true) {
|
while (true) {
|
||||||
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()));
|
||||||
@ -44,6 +45,21 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
|||||||
state = States::IDLE;
|
state = States::IDLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
size_t bytesRead = 0;
|
||||||
|
ReturnValue_t result = returnvalue::OK;
|
||||||
|
while (result != DleParser::NO_PACKET_FOUND) {
|
||||||
|
result = dleParser.parseRingBuf(bytesRead);
|
||||||
|
if (result == returnvalue::OK) {
|
||||||
|
// Packet found, advance read pointer.
|
||||||
|
// currentBytesRead = 0;
|
||||||
|
dleParser.confirmBytesRead(bytesRead);
|
||||||
|
} else if (result == DleParser::POSSIBLE_PACKET_LOSS) {
|
||||||
|
// Markers found at wrong place
|
||||||
|
// which might be a hint for a possibly lost packet.
|
||||||
|
// currentBytesRead = 0;
|
||||||
|
dleParser.confirmBytesRead(bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
TaskFactory::delayTask(400);
|
TaskFactory::delayTask(400);
|
||||||
} else if (bytesRead < 0) {
|
} else if (bytesRead < 0) {
|
||||||
sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno
|
sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno
|
||||||
@ -124,8 +140,12 @@ ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendD
|
|||||||
}
|
}
|
||||||
state = States::RUNNING;
|
state = States::RUNNING;
|
||||||
lock->unlockMutex();
|
lock->unlockMutex();
|
||||||
|
ReturnValue_t result = semaphore->release();
|
||||||
|
if (result != OK) {
|
||||||
|
std::cout << "ScexUartReader::sendMessage: Releasing semaphore failed" << std::endl;
|
||||||
|
}
|
||||||
size_t encodedLen = 0;
|
size_t encodedLen = 0;
|
||||||
ReturnValue_t result =
|
result =
|
||||||
dleEncoder.encode(sendData, sendLen, cmdbuf.data(), cmdbuf.size(), &encodedLen, true);
|
dleEncoder.encode(sendData, sendLen, cmdbuf.data(), cmdbuf.size(), &encodedLen, true);
|
||||||
if (result != OK) {
|
if (result != OK) {
|
||||||
sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl;
|
sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl;
|
||||||
@ -137,10 +157,6 @@ ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendD
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
result = semaphore->release();
|
|
||||||
if (result != OK) {
|
|
||||||
std::cout << "ScexUartReader::sendMessage: Releasing semaphore failed" << std::endl;
|
|
||||||
}
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user