done
Some checks are pending
EIVE/eive-obsw/pipeline/head Build queued...
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
2023-03-24 02:34:38 +01:00
parent e8e01cf198
commit 21159107d7
18 changed files with 41 additions and 38 deletions

View File

@ -4,6 +4,7 @@
#include <fsfw/ipc/MutexGuard.h>
#include <fsfw/tasks/SemaphoreFactory.h>
#include <fsfw/tasks/TaskFactory.h>
#include <fsfw/timemanager/Stopwatch.h>
#include <fsfw_hal/linux/serial/SerialCookie.h>
#include <fsfw_hal/linux/serial/helper.h>
#include <unistd.h>
@ -23,6 +24,7 @@ ReturnValue_t SyrlinksComHandler::performOperation(uint8_t opCode) {
state = State::SLEEPING;
lock->unlockMutex();
semaphore->acquire();
// Stopwatch watch;
readOneReply();
}
return returnvalue::OK;
@ -113,7 +115,7 @@ ReturnValue_t SyrlinksComHandler::handleSerialReception() {
<< std::endl;
return FAILED;
} else if (bytesRead > 0) {
// sif::info << "Received " << bytesRead << " bytes from the STR" << std::endl;
// sif::debug << "Received " << bytesRead << " bytes from the Syrlinks" << std::endl;
// arrayprinter::print(recBuf.data(), bytesRead);
ringBuf.writeData(recBuf.data(), bytesRead);
}
@ -164,7 +166,7 @@ ReturnValue_t SyrlinksComHandler::readOneReply() {
ReturnValue_t SyrlinksComHandler::tryReadingOneSyrlinksReply() {
size_t bytesToRead = ringBuf.getAvailableReadData();
if (bytesToRead == 0) {
return returnvalue::OK;
return NO_PACKET_FOUND;
}
bool startMarkerFound = false;
size_t startIdx = 0;
@ -184,7 +186,7 @@ ReturnValue_t SyrlinksComHandler::tryReadingOneSyrlinksReply() {
if (startMarkerFound) {
{
MutexGuard mg(lock);
replyLen = idx - startIdx;
replyLen = idx - startIdx + 1;
}
// Copy detected packet to IPC buffer so it can be passed back to the device handler.
if (replyLen > ipcBuf.size()) {
@ -192,13 +194,14 @@ ReturnValue_t SyrlinksComHandler::tryReadingOneSyrlinksReply() {
ringBuf.deleteData(idx);
return returnvalue::FAILED;
}
// sif::debug << "Detected Syrlinks reply with length " << replyLen << std::endl;
std::memcpy(ipcBuf.data(), recBuf.data() + startIdx, replyLen);
ringBuf.deleteData(idx);
ringBuf.deleteData(idx + 1);
return returnvalue::OK;
} else {
// Probably lost a packet. Discard broken packet.
sif::warning << "SyrlinksComHandler: Detected 2 consecutive end markers" << std::endl;
ringBuf.deleteData(idx);
ringBuf.deleteData(idx + 1);
}
}
}

View File

@ -28,7 +28,7 @@ class SyrlinksComHandler : public DeviceCommunicationIF,
SemaphoreIF *semaphore;
int serialPort = 0;
struct termios tty {};
Countdown replyTimeout{};
Countdown replyTimeout = Countdown(2000);
std::array<uint8_t, 2048> recBuf{};
SimpleRingBuffer ringBuf;
std::array<uint8_t, 1024> ipcBuf{};

View File

@ -8,7 +8,7 @@ ReturnValue_t ArcsecDatalinkLayer::checkRingBufForFrame(const uint8_t** decodedF
size_t& frameLen) {
size_t currentLen = decodeRingBuf.getAvailableReadData();
if (currentLen == 0) {
return returnvalue::OK;
return DEC_IN_PROGRESS;
}
decodeRingBuf.readData(rxAnalysisBuffer, currentLen);
for (size_t idx = 0; idx < currentLen; idx++) {

View File

@ -1,7 +1,7 @@
/**
* @brief Auto-generated event translation file. Contains 279 translations.
* @brief Auto-generated event translation file. Contains 278 translations.
* @details
* Generated on: 2023-03-24 01:19:39
* Generated on: 2023-03-24 02:13:12
*/
#include "translateEvents.h"

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file.
* @details
* Contains 173 translations.
* Generated on: 2023-03-24 01:19:39
* Generated on: 2023-03-24 02:13:12
*/
#include "translateObjects.h"