found the bug
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-10-04 23:04:50 +02:00
parent a44141c476
commit 1a192cd8fb
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
8 changed files with 60 additions and 44 deletions

View File

@ -23,7 +23,6 @@
#include "mission/devices/GyroADIS1650XHandler.h"
#include "mission/tmtc/TmFunnel.h"
#include "objects/systemObjectList.h"
#include "tmtc/apid.h"
#include "tmtc/pusIds.h"
/* UDP server includes */

View File

@ -4,7 +4,7 @@ RPiSdCardManager::RPiSdCardManager(std::string prefix) : prefix(std::move(prefix
const std::string& RPiSdCardManager::getCurrentMountPrefix() const { return prefix; }
bool RPiSdCardManager::isSdCardMounted(sd::SdCard sdCard) { return true; }
bool RPiSdCardManager::isSdCardUsable(sd::SdCard sdCard) { return true; }
std::optional<sd::SdCard> RPiSdCardManager::getPreferredSdCard() const { return std::nullopt; }

View File

@ -6,7 +6,7 @@ class RPiSdCardManager : public SdCardMountedIF {
public:
RPiSdCardManager(std::string prefix);
const std::string& getCurrentMountPrefix() const override;
bool isSdCardMounted(sd::SdCard sdCard) override;
bool isSdCardUsable(sd::SdCard sdCard) override;
std::optional<sd::SdCard> getPreferredSdCard() const override;
void setActiveSdCard(sd::SdCard sdCard) override;
std::optional<sd::SdCard> getActiveSdCard() const override;

2
fsfw

@ -1 +1 @@
Subproject commit d1630cdc4c3fc801934f1e394efa80e898f8031b
Subproject commit 1c53b60442f5b858b00938169ef1daba41ba272d

View File

@ -35,7 +35,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
while (true) {
semaphore->acquire();
int bytesRead = 0;
debugMode = true;
// debugMode = true;
while (true) {
bytesRead = read(serialPort, reinterpret_cast<void *>(recBuf.data()),
static_cast<unsigned int>(recBuf.size()));
@ -50,24 +50,11 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
break;
}
}
size_t bytesRead = 0;
ReturnValue_t result = returnvalue::OK;
while (result != DleParser::NO_PACKET_FOUND) {
result = dleParser.parseRingBuf(bytesRead);
if (result == returnvalue::OK) {
sif::info << "FOund dle packet, read " << bytesRead << " bytes" << std::endl;
// Packet found, advance read pointer.
auto& decodedPacket = dleParser.getContext().decodedPacket;
handleFoundDlePacket(decodedPacket.first, decodedPacket.second);
dleParser.confirmBytesRead(bytesRead);
} else if (result != DleParser::NO_PACKET_FOUND) {
sif::warning << "ScexUartReader::performOperation: Possible packet loss" << std::endl;
// Markers found at wrong place
// which might be a hint for a possibly lost packet.
dleParser.defaultErrorHandler();
dleParser.confirmBytesRead(bytesRead);
}
result = tryDleParsing();
}
TaskFactory::delayTask(400);
} else if (bytesRead < 0) {
sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno
@ -77,15 +64,16 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
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) {
sif::info << "Received " << bytesRead
<< " bytes from the Solar Cell Experiment:" << std::endl;
}
ReturnValue_t result = dleParser.passData(recBuf.data(), bytesRead);
if (result != OK) {
sif::warning << "ScexUartReader::performOperation: Passing data to DLE parser failed"
<< std::endl;
}
result = tryDleParsing();
}
};
}
@ -138,6 +126,7 @@ ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) {
ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendData,
size_t sendLen) {
ReturnValue_t result;
if (sendData == nullptr or sendLen == 0) {
return FAILED;
}
@ -146,13 +135,16 @@ ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendD
lock->unlockMutex();
return FAILED;
}
tcflush(serialPort, TCIOFLUSH);
tcflush(serialPort, TCIFLUSH);
state = States::RUNNING;
lock->unlockMutex();
result = semaphore->release();
if (result != OK) {
std::cout << "ScexUartReader::sendMessage: Releasing semaphore failed" << std::endl;
}
size_t encodedLen = 0;
ReturnValue_t result =
dleEncoder.encode(sendData, sendLen, cmdbuf.data(), cmdbuf.size(), &encodedLen, true);
result = dleEncoder.encode(sendData, sendLen, cmdbuf.data(), cmdbuf.size(), &encodedLen, true);
if (result != OK) {
sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl;
return FAILED;
@ -163,10 +155,7 @@ ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendD
<< std::endl;
return FAILED;
}
result = semaphore->release();
if (result != OK) {
std::cout << "ScexUartReader::sendMessage: Releasing semaphore failed" << std::endl;
}
return OK;
}
@ -199,6 +188,30 @@ void ScexUartReader::handleFoundDlePacket(uint8_t *packet, size_t len) {
}
}
ReturnValue_t ScexUartReader::tryDleParsing() {
size_t bytesRead = 0;
ReturnValue_t result = dleParser.parseRingBuf(bytesRead);
if (result == returnvalue::OK) {
// Packet found, advance read pointer.
auto &decodedPacket = dleParser.getContext().decodedPacket;
handleFoundDlePacket(decodedPacket.first, decodedPacket.second);
dleParser.confirmBytesRead(bytesRead);
} else if (result != DleParser::NO_PACKET_FOUND) {
sif::warning << "ScexUartReader::performOperation: Possible packet loss" << std::endl;
// Markers found at wrong place
// which might be a hint for a possibly lost packet.
dleParser.defaultErrorHandler();
dleParser.confirmBytesRead(bytesRead);
}
return result;
}
void ScexUartReader::reset() {
lock->lockMutex();
state = States::FINISH;
lock->unlockMutex();
}
ReturnValue_t ScexUartReader::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
size_t *size) {
MutexGuard mg(lock);

View File

@ -22,6 +22,7 @@ class ScexUartReader : public SystemObject, // strg+shift+n
enum class States { NOT_READY, IDLE, RUNNING, FINISH };
ScexUartReader(object_id_t objectId);
void reset();
ReturnValue_t finish();
void setDebugMode(bool enable);
@ -47,6 +48,7 @@ class ScexUartReader : public SystemObject, // strg+shift+n
static void foundDlePacketHandler(const DleParser::Context &ctx);
void handleFoundDlePacket(uint8_t *packet, size_t len);
ReturnValue_t tryDleParsing();
ReturnValue_t performOperation(uint8_t operationCode = 0) override;

View File

@ -5,10 +5,10 @@
#include <algorithm>
#include <ctime>
#include <iostream>
#include <fstream>
#include <random>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <random>
#include "fsfw/globalfunctions/CRC.h"
#include "mission/devices/devicedefinitions/ScexDefinitions.h"
@ -24,7 +24,10 @@ ScexDeviceHandler::~ScexDeviceHandler() {}
void ScexDeviceHandler::doStartUp() { setMode(MODE_ON); }
void ScexDeviceHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
void ScexDeviceHandler::doShutDown() {
reader.reset();
setMode(_MODE_POWER_DOWN);
}
ReturnValue_t ScexDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { return OK; }
@ -348,18 +351,16 @@ void ScexDeviceHandler::modeChanged() {}
void ScexDeviceHandler::setPowerSwitcher(PowerSwitchIF& powerSwitcher, power::Switch_t switchId) {
DeviceHandlerBase::setPowerSwitcher(&powerSwitcher);
this->switchId = switchId;
}
ReturnValue_t ScexDeviceHandler::initializeAfterTaskCreation() {
auto mntPrefix = sdcMan.getCurrentMountPrefix();
std::filesystem::path fullFilePath = mntPrefix;
fullFilePath /= "scex";
bool fileExists = std::filesystem::exists(fullFilePath);
auto mntPrefix = sdcMan.getCurrentMountPrefix();
std::filesystem::path fullFilePath = mntPrefix;
fullFilePath /= "scex";
bool fileExists = std::filesystem::exists(fullFilePath);
if(not fileExists){
std::filesystem::create_directory(fullFilePath);
}
return DeviceHandlerBase::initializeAfterTaskCreation();
if (not fileExists) {
std::filesystem::create_directory(fullFilePath);
}
return DeviceHandlerBase::initializeAfterTaskCreation();
}

View File

@ -1,14 +1,15 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SCEXDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_SCEXDEFINITIONS_H_
#include "eive/objects.h"
#include "eive/eventSubsystemIds.h"
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/events/Event.h>
#include <cstdint>
#include <vector>
#include "eive/eventSubsystemIds.h"
#include "eive/objects.h"
// Definitions for the Solar Cell Experiment
namespace scex {