v1.14.0 #304

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

2
fsfw

@ -1 +1 @@
Subproject commit 49747fc8a49e85e7b3d442eabe668d34e44bad32 Subproject commit d1630cdc4c3fc801934f1e394efa80e898f8031b

View File

@ -35,7 +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; 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()));
@ -43,6 +43,9 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
{ {
MutexGuard mg(lock); MutexGuard mg(lock);
if (state == States::FINISH) { if (state == States::FINISH) {
dleParser.reset();
// Flush received and unread data
tcflush(serialPort, TCIOFLUSH);
state = States::IDLE; state = States::IDLE;
break; break;
} }
@ -52,6 +55,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
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) {
sif::info << "FOund dle packet, read " << bytesRead << " bytes" << std::endl;
// Packet found, advance read pointer. // Packet found, advance read pointer.
auto& decodedPacket = dleParser.getContext().decodedPacket; auto& decodedPacket = dleParser.getContext().decodedPacket;
handleFoundDlePacket(decodedPacket.first, decodedPacket.second); handleFoundDlePacket(decodedPacket.first, decodedPacket.second);
@ -142,14 +146,12 @@ ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendD
lock->unlockMutex(); lock->unlockMutex();
return FAILED; return FAILED;
} }
tcflush(serialPort, TCIOFLUSH);
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;
result = ReturnValue_t 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;
@ -161,6 +163,10 @@ 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;
} }