Merge remote-tracking branch 'origin/develop' into mueller/master
This commit is contained in:
@@ -95,6 +95,13 @@ void initmission::initTasks() {
|
||||
initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK);
|
||||
}
|
||||
|
||||
PeriodicTaskIF* plocUpdaterTask = factory->createPeriodicTask(
|
||||
"PLOC_UPDATER_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc);
|
||||
result = plocUpdaterTask->addComponent(objects::PLOC_UPDATER);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
initmission::printAddObjectError("PLOC_UPDATER_TASK", objects::PLOC_UPDATER);
|
||||
}
|
||||
|
||||
|
||||
// FS task, task interval does not matter because it runs in permanent loop, priority low
|
||||
// because it is a non-essential background task
|
||||
@@ -137,6 +144,7 @@ void initmission::initTasks() {
|
||||
tmtcBridgeTask->startTask();
|
||||
tmtcPollingTask->startTask();
|
||||
coreController->startTask();
|
||||
plocUpdaterTask->startTask();
|
||||
|
||||
taskStarter(pstTasks, "PST task vector");
|
||||
taskStarter(pusTasks, "PUS task vector");
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include "mission/devices/RadiationSensorHandler.h"
|
||||
#include "mission/devices/RwHandler.h"
|
||||
#include "mission/devices/StarTrackerHandler.h"
|
||||
#include "mission/devices/PlocUpdater.h"
|
||||
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
|
||||
#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h"
|
||||
#include "mission/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
||||
@@ -179,6 +180,7 @@ void ObjectFactory::produce(void* args){
|
||||
|
||||
#endif
|
||||
|
||||
new PlocUpdater(objects::PLOC_UPDATER);
|
||||
}
|
||||
|
||||
void ObjectFactory::createTmpComponents() {
|
||||
|
@@ -1,3 +1,8 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
#include "PlocSupervisorHandler.h"
|
||||
#include "OBSWConfig.h"
|
||||
|
||||
@@ -28,6 +33,9 @@ ReturnValue_t PlocSupervisorHandler::initialize() {
|
||||
sif::warning << "PlocSupervisorHandler::initialize: Invalid uart com if" << std::endl;
|
||||
return INVALID_UART_COM_IF;
|
||||
}
|
||||
|
||||
sdcMan = SdCardManager::instance();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -112,11 +120,6 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
|
||||
prepareEmptyCmd(PLOC_SPV::APID_GET_BOOT_STATUS_RPT);
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case(PLOC_SPV::UPDATE_AVAILABLE): {
|
||||
prepareUpdateAvailableCmd(commandData);
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case(PLOC_SPV::WATCHDOGS_ENABLE): {
|
||||
prepareWatchdogsEnableCmd(commandData);
|
||||
@@ -207,6 +210,11 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
|
||||
prepareSetDbgVerbosityCmd(commandData);
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case(PLOC_SPV::CAN_LOOPBACK_TEST): {
|
||||
prepareEmptyCmd(PLOC_SPV::APID_CAN_LOOPBACK_TEST);
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case(PLOC_SPV::SET_GPIO): {
|
||||
prepareSetGpioCmd(commandData);
|
||||
@@ -241,6 +249,16 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
}
|
||||
case(PLOC_SPV::UPDATE_AVAILABLE):
|
||||
case(PLOC_SPV::UPDATE_IMAGE_DATA):
|
||||
case(PLOC_SPV::UPDATE_VERIFY):
|
||||
// Simply forward data from PLOC Updater to supervisor
|
||||
std::memcpy(commandBuffer, commandData, commandDataLen);
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = commandDataLen;
|
||||
nextReplyId = PLOC_SPV::ACK_REPORT;
|
||||
result = RETURN_OK;
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
|
||||
<< std::endl;
|
||||
@@ -271,6 +289,8 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION);
|
||||
this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT);
|
||||
this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE);
|
||||
this->insertInCommandMap(PLOC_SPV::UPDATE_VERIFY);
|
||||
this->insertInCommandMap(PLOC_SPV::UPDATE_IMAGE_DATA);
|
||||
this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE);
|
||||
this->insertInCommandMap(PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT);
|
||||
this->insertInCommandMap(PLOC_SPV::ENABLE_LATCHUP_ALERT);
|
||||
@@ -296,6 +316,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_ALL);
|
||||
this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR);
|
||||
this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR);
|
||||
this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST);
|
||||
this->insertInCommandAndReplyMap(PLOC_SPV::DUMP_MRAM, 3);
|
||||
this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT);
|
||||
this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT);
|
||||
@@ -506,6 +527,8 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
|
||||
case PLOC_SPV::RESET_MPSOC:
|
||||
case PLOC_SPV::SET_TIME_REF:
|
||||
case PLOC_SPV::UPDATE_AVAILABLE:
|
||||
case PLOC_SPV::UPDATE_IMAGE_DATA:
|
||||
case PLOC_SPV::UPDATE_VERIFY:
|
||||
case PLOC_SPV::WATCHDOGS_ENABLE:
|
||||
case PLOC_SPV::WATCHDOGS_CONFIG_TIMEOUT:
|
||||
case PLOC_SPV::ENABLE_LATCHUP_ALERT:
|
||||
@@ -1004,26 +1027,6 @@ void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t * commandData)
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareUpdateAvailableCmd(const uint8_t * commandData) {
|
||||
uint8_t offset = 0;
|
||||
uint8_t imageSelect = *(commandData + offset);
|
||||
offset += 1;
|
||||
uint8_t imagePartition = *(commandData + offset);
|
||||
offset += 1;
|
||||
uint32_t imageSize = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
|
||||
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
offset += 4;
|
||||
uint32_t imageCrc = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
|
||||
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
offset += 4;
|
||||
uint32_t numberOfPackets = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16
|
||||
| *(commandData + offset + 2) << 8 | *(commandData + offset + 3);
|
||||
|
||||
PLOC_SPV::UpdateAvailable packet(imageSelect, imagePartition, imageSize, imageCrc,
|
||||
numberOfPackets);
|
||||
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
|
||||
}
|
||||
|
||||
void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t * commandData) {
|
||||
uint8_t offset = 0;
|
||||
uint8_t watchdogPs = *(commandData + offset);
|
||||
@@ -1315,7 +1318,7 @@ ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, siz
|
||||
bufferTop += 1;
|
||||
*foundLen += 1;
|
||||
if (bufferTop >= PLOC_SPV::SPACE_PACKET_HEADER_LENGTH) {
|
||||
packetLen = spacePacketBuffer[4] << 8 | spacePacketBuffer[5];
|
||||
packetLen = readSpacePacketLength(spacePacketBuffer);
|
||||
}
|
||||
|
||||
if (bufferTop == PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1) {
|
||||
@@ -1341,15 +1344,17 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket() {
|
||||
|
||||
// Prepare packet for downlink
|
||||
if (packetInBuffer) {
|
||||
uint16_t packetLen = spacePacketBuffer[4] << 8 | spacePacketBuffer[5];
|
||||
uint16_t packetLen = readSpacePacketLength(spacePacketBuffer);
|
||||
result = verifyPacket(spacePacketBuffer, PLOC_SPV::SPACE_PACKET_HEADER_LENGTH + packetLen + 1);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl;
|
||||
return result;
|
||||
}
|
||||
//TODO: Write MRAM dump to SD card handler
|
||||
handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1,
|
||||
PLOC_SPV::DUMP_MRAM);
|
||||
handleMramDumpFile();
|
||||
if (downlinkMramDump == true) {
|
||||
handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1,
|
||||
PLOC_SPV::DUMP_MRAM);
|
||||
}
|
||||
packetInBuffer = false;
|
||||
receivedMramDumpPackets++;
|
||||
if (expectedMramDumpPackets == receivedMramDumpPackets) {
|
||||
@@ -1416,3 +1421,73 @@ ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() {
|
||||
}
|
||||
return APERIODIC_REPLY;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::handleMramDumpFile() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
uint16_t packetLen = readSpacePacketLength(spacePacketBuffer);
|
||||
uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer);
|
||||
if (sequenceFlags == static_cast<uint8_t>(PLOC_SPV::SequenceFlags::FIRST_PKT)) {
|
||||
result = createMramDumpFile();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (not std::filesystem::exists(activeMramFile)) {
|
||||
sif::warning << "PlocSupervisorHandler::handleMramDumpFile: MRAM file does not exist"
|
||||
<< std::endl;
|
||||
return MRAM_FILE_NOT_EXISTS;
|
||||
}
|
||||
std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out);
|
||||
file.write(
|
||||
reinterpret_cast<const char*>(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH),
|
||||
packetLen - 1);
|
||||
file.close();
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
uint16_t PlocSupervisorHandler::readSpacePacketLength(uint8_t* spacePacket) {
|
||||
return spacePacket[4] << 8 | spacePacket[5];
|
||||
}
|
||||
|
||||
uint8_t PlocSupervisorHandler::readSequenceFlags(uint8_t* spacePacket) {
|
||||
return spacePacketBuffer[2] >> 6;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::createMramDumpFile() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
std::string timeStamp;
|
||||
result = getTimeStampString(timeStamp);
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string filename = "mram-dump--" + timeStamp + ".bin";
|
||||
std::string currentMountPrefix = sdcMan->getCurrentMountPrefix();
|
||||
|
||||
// Check if path to PLOC directory exists
|
||||
if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) {
|
||||
sif::warning << "PlocSupervisorHandler::createMramDumpFile: Ploc path does not exist"
|
||||
<< std::endl;
|
||||
return PATH_DOES_NOT_EXIST;
|
||||
}
|
||||
activeMramFile = currentMountPrefix + "/" + plocFilePath + "/" + filename;
|
||||
// Create new file
|
||||
std::ofstream file(activeMramFile, std::ios_base::out);
|
||||
file.close();
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp) {
|
||||
Clock::TimeOfDay_t time;
|
||||
ReturnValue_t result = Clock::getDateAndTime(&time);
|
||||
if (result != RETURN_OK) {
|
||||
sif::warning << "PlocSupervisorHandler::createMramDumpFile: Failed to get current time"
|
||||
<< std::endl;
|
||||
return GET_TIME_FAILURE;
|
||||
}
|
||||
timeStamp = std::to_string(time.year) + "-" + std::to_string(time.month) + "-"
|
||||
+ std::to_string(time.day) + "--" + std::to_string(time.hour) + "-"
|
||||
+ std::to_string(time.minute) + "-" + std::to_string(time.second);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
#include <mission/devices/devicedefinitions/PlocSupervisorDefinitions.h>
|
||||
#include <cstring>
|
||||
#include <fsfw_hal/linux/uart/UartComIF.h>
|
||||
#include <bsp_q7s/memory/SdCardManager.h>
|
||||
|
||||
/**
|
||||
* @brief This is the device handler for the supervisor of the PLOC which is programmed by
|
||||
@@ -79,10 +79,14 @@ private:
|
||||
static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC);
|
||||
//! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with other apid.
|
||||
static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD);
|
||||
//! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist
|
||||
static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAE);
|
||||
//! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have been created with the reception of the first dump packet.
|
||||
static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF);
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] PLOC supervrisor crc failure in telemetry packet
|
||||
//! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet
|
||||
static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] PLOC supervisor received acknowledgment failure report
|
||||
static const Event SUPV_ACK_FAILURE = MAKE_EVENT(2, severity::LOW);
|
||||
@@ -120,6 +124,15 @@ private:
|
||||
/** This buffer is used to concatenate space packets received in two different read steps */
|
||||
uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE];
|
||||
|
||||
SdCardManager* sdcMan = nullptr;
|
||||
|
||||
/** Path to PLOC specific files on SD card */
|
||||
std::string plocFilePath = "ploc";
|
||||
std::string activeMramFile;
|
||||
|
||||
/** Setting this variable to true will enable direct downlink of MRAM packets */
|
||||
bool downlinkMramDump = false;
|
||||
|
||||
/**
|
||||
* @brief This function checks the crc of the received PLOC reply.
|
||||
*
|
||||
@@ -211,12 +224,6 @@ private:
|
||||
|
||||
void prepareRestartTriesCmd(const uint8_t * commandData);
|
||||
|
||||
/**
|
||||
* @brief This function fills the command buffer with the packet to notify the supervisor
|
||||
* about the availability of an update for the MPSoC
|
||||
*/
|
||||
void prepareUpdateAvailableCmd(const uint8_t * commandData);
|
||||
|
||||
/**
|
||||
* @brief This function fills the command buffer with the packet to enable or disable the
|
||||
* watchdogs on the PLOC.
|
||||
@@ -299,6 +306,34 @@ private:
|
||||
* MRAM dump packet.
|
||||
*/
|
||||
ReturnValue_t checkMramPacketApid();
|
||||
|
||||
/**
|
||||
* @brief Writes the data of the MRAM dump to a file. The file will be created when receiving
|
||||
* the first packet.
|
||||
*/
|
||||
ReturnValue_t handleMramDumpFile();
|
||||
|
||||
/**
|
||||
* @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer.
|
||||
*
|
||||
* @param spacePacket Pointer to the buffer holding the space packet.
|
||||
*
|
||||
* @return The value stored in the length field of the data field.
|
||||
*/
|
||||
uint16_t readSpacePacketLength(uint8_t* spacePacket);
|
||||
|
||||
/**
|
||||
* @brief Extracts the sequence flags from a space packet referenced by the spacePacket
|
||||
* pointer.
|
||||
*
|
||||
* @param spacePacket Pointer to the buffer holding the space packet.
|
||||
*
|
||||
* @return uint8_t where the two least significant bits hold the sequence flags.
|
||||
*/
|
||||
uint8_t readSequenceFlags(uint8_t* spacePacket);
|
||||
|
||||
ReturnValue_t createMramDumpFile();
|
||||
ReturnValue_t getTimeStampString(std::string& timeStamp);
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */
|
||||
|
@@ -179,7 +179,7 @@ public:
|
||||
sd::SdCard prefSdCard = sd::SdCard::NONE);
|
||||
|
||||
/**
|
||||
* If sd::SdCard::NONE is passed as an argument, this funtion will get the currently
|
||||
* If sd::SdCard::NONE is passed as an argument, this function will get the currently
|
||||
* preferred SD card from the scratch buffer.
|
||||
* @param prefSdCardPtr
|
||||
* @return
|
||||
|
Reference in New Issue
Block a user