added event which is triggered when config of pdec is corrupted
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Jakob Meier 2023-08-07 17:08:33 +02:00
parent b2d9582a46
commit c3bca9bb54
5 changed files with 103 additions and 38 deletions

View File

@ -22,11 +22,11 @@ ReturnValue_t PdecConfig::write() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
result = writeFrameHeaderFirstOctet(); result = writeFrameHeaderFirstWord();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
result = writeFrameHeaderSecondOctet(); result = writeFrameHeaderSecondWord();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
@ -77,7 +77,7 @@ ReturnValue_t PdecConfig::setPositiveWindow(uint8_t pw) {
return result; return result;
} }
// Rewrite second config word which contains the positive window parameter // Rewrite second config word which contains the positive window parameter
writeFrameHeaderSecondOctet(); writeFrameHeaderSecondWord();
return returnvalue::OK; return returnvalue::OK;
} }
@ -92,7 +92,7 @@ ReturnValue_t PdecConfig::setNegativeWindow(uint8_t nw) {
return result; return result;
} }
// Rewrite second config word which contains the negative window parameter // Rewrite second config word which contains the negative window parameter
writeFrameHeaderSecondOctet(); writeFrameHeaderSecondWord();
return returnvalue::OK; return returnvalue::OK;
} }
@ -114,42 +114,14 @@ ReturnValue_t PdecConfig::getNegativeWindow(uint8_t& negativeWindow) {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PdecConfig::writeFrameHeaderFirstOctet() { ReturnValue_t PdecConfig::writeFrameHeaderFirstWord() {
uint32_t word = 0; uint32_t word = createFirstWord();
word |= (VERSION_ID << 30);
// Setting the bypass flag and the control command flag should not have any
// implication on the operation of the PDEC IP Core
word |= (BYPASS_FLAG << 29);
word |= (CONTROL_COMMAND_FLAG << 28);
word |= (RESERVED_FIELD_A << 26);
word |= (SPACECRAFT_ID << 16);
word |= (VIRTUAL_CHANNEL << 10);
word |= (DUMMY_BITS << 8);
uint8_t positiveWindow = 0;
ReturnValue_t result =
localParameterHandler.getValue(pdecconfigdefs::paramkeys::POSITIVE_WINDOW, positiveWindow);
if (result != returnvalue::OK) {
return result;
}
word |= static_cast<uint32_t>(positiveWindow);
*(memoryBaseAddress + FRAME_HEADER_OFFSET) = word; *(memoryBaseAddress + FRAME_HEADER_OFFSET) = word;
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PdecConfig::writeFrameHeaderSecondOctet() { ReturnValue_t PdecConfig::writeFrameHeaderSecondWord() {
uint8_t negativeWindow = 0; uint32_t word = createSecondWord();
ReturnValue_t result =
localParameterHandler.getValue(pdecconfigdefs::paramkeys::NEGATIVE_WINDOW, negativeWindow);
if (result != returnvalue::OK) {
return result;
}
uint32_t word = 0;
word = 0;
word |= (static_cast<uint32_t>(negativeWindow) << 24);
word |= (HIGH_AU_MAP_ID << 16);
word |= (ENABLE_DERANDOMIZER << 8);
*(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = word; *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = word;
return returnvalue::OK; return returnvalue::OK;
} }
@ -189,3 +161,49 @@ uint8_t PdecConfig::getOddParity(uint8_t number) {
parityBit = ~(countBits & 0x1) & 0x1; parityBit = ~(countBits & 0x1) & 0x1;
return parityBit; return parityBit;
} }
uint32_t PdecConfig::createFirstWord() {
uint32_t word = 0;
word |= (VERSION_ID << 30);
// Setting the bypass flag and the control command flag should not have any
// implication on the operation of the PDEC IP Core
word |= (BYPASS_FLAG << 29);
word |= (CONTROL_COMMAND_FLAG << 28);
word |= (RESERVED_FIELD_A << 26);
word |= (SPACECRAFT_ID << 16);
word |= (VIRTUAL_CHANNEL << 10);
word |= (DUMMY_BITS << 8);
uint8_t positiveWindow = 0;
ReturnValue_t result =
localParameterHandler.getValue(pdecconfigdefs::paramkeys::POSITIVE_WINDOW, positiveWindow);
if (result != returnvalue::OK) {
return result;
}
word |= static_cast<uint32_t>(positiveWindow);
return word;
}
uint32_t PdecConfig::createSecondWord() {
uint8_t negativeWindow = 0;
ReturnValue_t result =
localParameterHandler.getValue(pdecconfigdefs::paramkeys::NEGATIVE_WINDOW, negativeWindow);
if (result != returnvalue::OK) {
return result;
}
uint32_t word = 0;
word = 0;
word |= (static_cast<uint32_t>(negativeWindow) << 24);
word |= (HIGH_AU_MAP_ID << 16);
word |= (ENABLE_DERANDOMIZER << 8);
return word;
}
uint32_t PdecConfig::readbackFirstWord() {
return *(memoryBaseAddress + FRAME_HEADER_OFFSET);
}
uint32_t PdecConfig::readbackSecondWord() {
return *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1);
}

View File

@ -48,6 +48,34 @@ class PdecConfig {
ReturnValue_t getPositiveWindow(uint8_t& positiveWindow); ReturnValue_t getPositiveWindow(uint8_t& positiveWindow);
ReturnValue_t getNegativeWindow(uint8_t& negativeWindow); ReturnValue_t getNegativeWindow(uint8_t& negativeWindow);
/**
* @brief Creates the first word of the PDEC configuration
*
* @return The created config word
*/
uint32_t createFirstWord();
/**
* @brief Creates the second word of the PDEC configuration
*
* @return The created config word
*/
uint32_t createSecondWord();
/**
* @brief Reads first config word from the config memory
*
* @return The config word
*/
uint32_t readbackFirstWord();
/**
* @brief Reads the second config word from the config memory
*
* @return The config word
*/
uint32_t readbackSecondWord();
private: private:
// TC transfer frame configuration parameters // TC transfer frame configuration parameters
static const uint8_t VERSION_ID = 0; static const uint8_t VERSION_ID = 0;
@ -102,8 +130,8 @@ class PdecConfig {
*/ */
ReturnValue_t createPersistentConfig(); ReturnValue_t createPersistentConfig();
ReturnValue_t writeFrameHeaderFirstOctet(); ReturnValue_t writeFrameHeaderFirstWord();
ReturnValue_t writeFrameHeaderSecondOctet(); ReturnValue_t writeFrameHeaderSecondWord();
void writeMapConfig(); void writeMapConfig();
/** /**

View File

@ -478,6 +478,7 @@ bool PdecHandler::checkFrameAna(uint32_t pdecFar) {
} }
case (FrameAna_t::FRAME_DIRTY): { case (FrameAna_t::FRAME_DIRTY): {
triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY_RETVAL); triggerEvent(INVALID_TC_FRAME, FRAME_DIRTY_RETVAL);
checkConfig();
sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl; sif::warning << "PdecHandler::checkFrameAna: Frame dirty" << std::endl;
break; break;
} }
@ -577,6 +578,15 @@ void PdecHandler::handleIReason(uint32_t pdecFar, ReturnValue_t parameter1) {
} }
} }
void PdecHandler::checkConfig() {
uint32_t firstWord = pdecConfig.createFirstWord();
uint32_t secondWord = pdecConfig.createSecondWord();
if (firstWord != pdecConfig.readbackFirstWord() or
secondWord != pdecConfig.readbackSecondWord()) {
triggerEvent(PDEC_CONFIG_CORRUPTED, firstWord, secondWord);
}
}
void PdecHandler::handleNewTc() { void PdecHandler::handleNewTc() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;

View File

@ -282,6 +282,11 @@ class PdecHandler : public SystemObject,
*/ */
void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1); void handleIReason(uint32_t pdecFar, ReturnValue_t parameter1);
/**
* @brief Checks if PDEC configuration is still correct
*/
void checkConfig();
/** /**
* @brief Handles the reception of new TCs. Reads the pointer to the storage location of the * @brief Handles the reception of new TCs. Reads the pointer to the storage location of the
* new TC segment, extracts the PUS packet and forwards the data to the object * new TC segment, extracts the PUS packet and forwards the data to the object

View File

@ -71,6 +71,10 @@ static constexpr Event OPEN_IRQ_FILE_FAILED = event::makeEvent(SUBSYSTEM_ID, 13,
//! [EXPORT] : [COMMENT] PDEC initialization failed. This might also be due to the persistent //! [EXPORT] : [COMMENT] PDEC initialization failed. This might also be due to the persistent
//! confiuration never becoming available, for example due to SD card issues. //! confiuration never becoming available, for example due to SD card issues.
static constexpr Event PDEC_INIT_FAILED = event::makeEvent(SUBSYSTEM_ID, 14, severity::HIGH); static constexpr Event PDEC_INIT_FAILED = event::makeEvent(SUBSYSTEM_ID, 14, severity::HIGH);
//! [EXPORT] : [COMMENT] The PDEC configuration area has been corrupted
//! P1: The first configuration word
//! P2: The second configuration word
static constexpr Event PDEC_CONFIG_CORRUPTED = event::makeEvent(SUBSYSTEM_ID, 15, severity::HIGH);
// Action IDs // Action IDs
static constexpr ActionId_t PRINT_CLCW = 0; static constexpr ActionId_t PRINT_CLCW = 0;