v1.12.0 #269

Merged
muellerr merged 493 commits from develop into main 2022-07-04 11:19:05 +02:00
12 changed files with 627 additions and 789 deletions
Showing only changes of commit bd8cd49117 - Show all commits

View File

@ -8,8 +8,6 @@
FilesystemHelper::FilesystemHelper() {}
FilesystemHelper::~FilesystemHelper() {}
ReturnValue_t FilesystemHelper::checkPath(std::string path) {
SdCardManager* sdcMan = SdCardManager::instance();
if (sdcMan == nullptr) {

View File

@ -20,11 +20,8 @@ class FilesystemHelper : public HasReturnvaluesIF {
//! [EXPORT] : [COMMENT] Specified file does not exist on filesystem
static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA1);
FilesystemHelper();
virtual ~FilesystemHelper();
/**
* @brief In case the path points to a directory on the sd card the function checks if the
* @brief In case the path points to a directory on the sd card, the function checks if the
* appropriate SD card is mounted.
*
* @param path Path to check
@ -44,6 +41,9 @@ class FilesystemHelper : public HasReturnvaluesIF {
* @return RETURN_OK if file exists, otherwise return error code.
*/
static ReturnValue_t fileExists(std::string file);
private:
FilesystemHelper();
};
#endif /* BSP_Q7S_MEMORY_FILESYSTEMHELPER_H_ */

View File

@ -15,7 +15,6 @@ namespace supv {
/** Command IDs */
static const DeviceCommandId_t NONE = 0;
static const DeviceCommandId_t GET_HK_REPORT = 1;
static const DeviceCommandId_t RESTART_MPSOC = 2;
static const DeviceCommandId_t START_MPSOC = 3;
static const DeviceCommandId_t SHUTDOWN_MPSOC = 4;
static const DeviceCommandId_t SEL_MPSOC_BOOT_IMAGE = 5;
@ -25,33 +24,23 @@ static const DeviceCommandId_t RESET_MPSOC = 8;
static const DeviceCommandId_t SET_TIME_REF = 9;
static const DeviceCommandId_t DISABLE_PERIOIC_HK_TRANSMISSION = 10;
static const DeviceCommandId_t GET_BOOT_STATUS_REPORT = 11;
/** Notifies the supervisor that a new update is available for the MPSoC */
static const DeviceCommandId_t WATCHDOGS_ENABLE = 13;
static const DeviceCommandId_t WATCHDOGS_CONFIG_TIMEOUT = 14;
static const DeviceCommandId_t ENABLE_LATCHUP_ALERT = 15;
static const DeviceCommandId_t DISABLE_LATCHUP_ALERT = 16;
static const DeviceCommandId_t AUTO_CALIBRATE_ALERT = 17;
static const DeviceCommandId_t SET_ALERT_LIMIT = 18;
static const DeviceCommandId_t SET_ALERT_IRQ_FILTER = 19;
static const DeviceCommandId_t SET_ADC_SWEEP_PERIOD = 20;
static const DeviceCommandId_t SET_ADC_ENABLED_CHANNELS = 21;
static const DeviceCommandId_t SET_ADC_WINDOW_AND_STRIDE = 22;
static const DeviceCommandId_t SET_ADC_THRESHOLD = 23;
static const DeviceCommandId_t GET_LATCHUP_STATUS_REPORT = 24;
static const DeviceCommandId_t COPY_ADC_DATA_TO_MRAM = 25;
static const DeviceCommandId_t ENABLE_NVMS = 26;
static const DeviceCommandId_t SELECT_NVM = 27;
static const DeviceCommandId_t RUN_AUTO_EM_TESTS = 28;
static const DeviceCommandId_t WIPE_MRAM = 29;
static const DeviceCommandId_t FIRST_MRAM_DUMP = 30;
static const DeviceCommandId_t SET_DBG_VERBOSITY = 31;
static const DeviceCommandId_t CAN_LOOPBACK_TEST = 32;
static const DeviceCommandId_t PRINT_CPU_STATS = 33;
static const DeviceCommandId_t SET_GPIO = 34;
static const DeviceCommandId_t READ_GPIO = 35;
static const DeviceCommandId_t RESTART_SUPERVISOR = 36;
static const DeviceCommandId_t FACTORY_RESET_CLEAR_ALL = 37;
static const DeviceCommandId_t REQUEST_LOGGING_DATA = 38;
static const DeviceCommandId_t LOGGING_REQUEST_COUNTERS = 38;
static const DeviceCommandId_t FACTORY_RESET_CLEAR_MIRROR = 40;
static const DeviceCommandId_t FACTORY_RESET_CLEAR_CIRCULAR = 41;
static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 43;
@ -62,6 +51,11 @@ static const DeviceCommandId_t PERFORM_UPDATE = 48;
static const DeviceCommandId_t TERMINATE_SUPV_HELPER = 49;
static const DeviceCommandId_t ENABLE_AUTO_TM = 50;
static const DeviceCommandId_t DISABLE_AUTO_TM = 51;
static const DeviceCommandId_t ENABLE_ADC_MONITOR_TASK = 52;
static const DeviceCommandId_t DISABLE_ADC_MONITOR_TASK = 53;
static const DeviceCommandId_t LOGGING_REQUEST_EVENT_BUFFERS = 54;
static const DeviceCommandId_t LOGGING_CLEAR_COUNTERS = 55;
static const DeviceCommandId_t LOGGING_SET_TOPIC = 56;
/** Reply IDs */
static const DeviceCommandId_t ACK_REPORT = 50;
@ -69,12 +63,15 @@ static const DeviceCommandId_t EXE_REPORT = 51;
static const DeviceCommandId_t HK_REPORT = 52;
static const DeviceCommandId_t BOOT_STATUS_REPORT = 53;
static const DeviceCommandId_t LATCHUP_REPORT = 54;
static const DeviceCommandId_t LOGGING_REPORT = 55;
// Size of complete space packet (6 byte header + size of data + 2 byte CRC)
static const uint16_t SIZE_ACK_REPORT = 14;
static const uint16_t SIZE_EXE_REPORT = 14;
static const uint16_t SIZE_HK_REPORT = 52;
static const uint16_t SIZE_BOOT_STATUS_REPORT = 24;
static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 31;
static const uint16_t SIZE_LOGGING_REPORT = 44;
/**
* SpacePacket apids of telemetry packets
@ -97,7 +94,6 @@ static const uint16_t APID_DATA_LOGGER_DATA = 0x20D;
/**
* APIDs of telecommand packets
*/
static const uint16_t APID_RESTART_MPSOC = 0xA0;
static const uint16_t APID_START_MPSOC = 0xA1;
static const uint16_t APID_SHUTWOWN_MPSOC = 0xA2;
static const uint16_t APID_SEL_MPSOC_BOOT_IMAGE = 0xA3;
@ -112,29 +108,21 @@ static const uint16_t APID_FACTORY_FLASH = 0xAC;
static const uint16_t APID_ERASE_MEMORY = 0xB0;
static const uint16_t APID_WRITE_MEMORY = 0xB1;
static const uint16_t APID_CHECK_MEMORY = 0xB2;
static const uint16_t APID_WTD_ENABLE = 0xC0;
static const uint16_t APID_WTD_CONFIG_TIMEOUT = 0xC1;
static const uint16_t APID_SET_TIME_REF = 0xC2;
static const uint16_t APID_DISABLE_HK = 0xC3;
static const uint16_t APID_AUTO_TM = 0xC5;
static const uint16_t APID_ENABLE_LATCHUP_ALERT = 0xD0;
static const uint16_t APID_DISABLE_LATCHUP_ALERT = 0xD1;
static const uint16_t APID_AUTO_CALIBRATE_ALERT = 0xD2;
static const uint16_t APID_SET_ALERT_LIMIT = 0xD3;
static const uint16_t APID_SET_ALERT_IRQ_FILTER = 0xD4;
static const uint16_t APID_SET_ADC_SWEEP_PERIOD = 0xD5;
static const uint16_t APID_SET_ADC_ENABLED_CHANNELS = 0xD6;
static const uint16_t APID_SET_ADC_WINDOW_AND_STRIDE = 0xD7;
static const uint16_t APID_SET_ADC_THRESHOLD = 0xD8;
static const uint16_t APID_GET_LATCHUP_STATUS_REPORT = 0xD9;
static const uint16_t APID_COPY_ADC_DATA_TO_MRAM = 0xDA;
static const uint16_t APID_ENABLE_NVMS = 0xF0;
static const uint16_t APID_SELECT_NVM = 0xF1;
static const uint16_t APID_ADC_MONITOR_TASK = 0xDB;
static const uint16_t APID_RUN_AUTO_EM_TESTS = 0xF2;
static const uint16_t APID_WIPE_MRAM = 0xF3;
static const uint16_t APID_DUMP_MRAM = 0xF4;
static const uint16_t APID_SET_DBG_VERBOSITY = 0xF5;
static const uint16_t APID_CAN_LOOPBACK_TEST = 0xF6;
static const uint16_t APID_PRINT_CPU_STATS = 0xF8;
static const uint16_t APID_SET_GPIO = 0xF9;
static const uint16_t APID_READ_GPIO = 0xFA;
@ -212,15 +200,27 @@ enum PoolIds : lp_id_t {
LATCHUP_RPT_TIME_YEAR,
LATCHUP_RPT_TIME_MSEC,
LATCHUP_RPT_IS_SET,
SUPERVISOR_REBOOTS,
LATCHUP_EVENTS,
ADC_TRIGGERS,
PS_HEARTBEATS_LOST,
PL_HEARTBEATS_LOST,
TC_RECEIVED,
TM_RECEIVED,
SOC_BOOTS,
SOC_BOOT_FAILS
};
static const uint8_t HK_SET_ENTRIES = 13;
static const uint8_t BOOT_REPORT_SET_ENTRIES = 10;
static const uint8_t LATCHUP_RPT_SET_ENTRIES = 16;
static const uint8_t LOGGING_RPT_SET_ENTRIES = 9;
static const uint32_t HK_SET_ID = HK_REPORT;
static const uint32_t BOOT_REPORT_SET_ID = BOOT_STATUS_REPORT;
static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT;
static const uint32_t LOGGING_RPT_ID = LOGGING_REQUEST_COUNTERS;
/**
* @brief This class creates a space packet containing only the header data and the CRC.
@ -465,101 +465,6 @@ class DisablePeriodicHkTransmission : public SpacePacket {
}
};
/**
* @brief This class packages the command to enable the watchdogs of the PLOC.
*/
class WatchdogsEnable : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param watchdogPs Enables processing system watchdog
* @param watchdogPl Enables programmable logic wathdog
* @param watchdogInt
*/
WatchdogsEnable(uint8_t watchdogPs, uint8_t watchdogPl, uint8_t watchdogInt)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_ENABLE, DEFAULT_SEQUENCE_COUNT),
watchdogPs(watchdogPs),
watchdogPl(watchdogPl),
watchdogInt(watchdogInt) {
initPacket();
}
private:
static const uint16_t DATA_FIELD_LENGTH = 5;
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t watchdogPs = 0;
uint8_t watchdogPl = 0;
uint8_t watchdogInt = 0;
void initPacket() {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&watchdogPs, &dataFieldPtr, &serializedSize,
sizeof(watchdogPs), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&watchdogPl, &dataFieldPtr, &serializedSize,
sizeof(watchdogPl), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&watchdogInt, &dataFieldPtr, &serializedSize,
sizeof(watchdogInt), SerializeIF::Endianness::BIG);
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This class packages the command to set the timeout of one of the three watchdogs (PS,
* PL, INT)
*/
class WatchdogsConfigTimeout : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param watchdogPs Selects the watchdog to configure (0 - PS, 1 - PL, 2 - INT)
* @param timeout The timeout to set
*/
WatchdogsConfigTimeout(uint8_t watchdog, uint32_t timeout)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_WTD_CONFIG_TIMEOUT, DEFAULT_SEQUENCE_COUNT),
watchdog(watchdog),
timeout(timeout) {
initPacket();
}
private:
static const uint16_t DATA_FIELD_LENGTH = 7;
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t watchdog = 0;
uint32_t timeout = 0;
void initPacket() {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&watchdog, &dataFieldPtr, &serializedSize,
sizeof(watchdog), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint32_t>(&timeout, &dataFieldPtr, &serializedSize, sizeof(timeout),
SerializeIF::Endianness::BIG);
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This class packages the command to enable of disable the latchup alert.
*
@ -595,8 +500,8 @@ class LatchupAlert : public SpacePacket {
void initPacket() {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&latchupId, &dataFieldPtr, &serializedSize,
uint8_t* data_field_ptr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&latchupId, &data_field_ptr, &serializedSize,
sizeof(latchupId), SerializeIF::Endianness::BIG);
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
@ -607,51 +512,6 @@ class LatchupAlert : public SpacePacket {
}
};
/**
* @brief This class packages the command to calibrate a certain latchup alert.
*/
class AutoCalibrateAlert : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC,
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
* @param mg
*/
AutoCalibrateAlert(uint8_t latchupId, uint32_t mg)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_AUTO_CALIBRATE_ALERT, DEFAULT_SEQUENCE_COUNT),
latchupId(latchupId),
mg(mg) {
initPacket();
}
private:
static const uint16_t DATA_FIELD_LENGTH = 7;
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t latchupId = 0;
uint32_t mg = 0;
void initPacket() {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&latchupId, &dataFieldPtr, &serializedSize,
sizeof(latchupId), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint32_t>(&mg, &dataFieldPtr, &serializedSize, sizeof(mg),
SerializeIF::Endianness::BIG);
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
class SetAlertlimit : public SpacePacket {
public:
/**
@ -694,91 +554,6 @@ class SetAlertlimit : public SpacePacket {
}
};
class SetAlertIrqFilter : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC,
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
* @param tp
* @param div
*/
SetAlertIrqFilter(uint8_t latchupId, uint8_t tp, uint8_t div)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ALERT_IRQ_FILTER, DEFAULT_SEQUENCE_COUNT),
tp(tp),
div(div) {
initPacket();
}
private:
static const uint16_t DATA_FIELD_LENGTH = 5;
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t latchupId = 0;
uint8_t tp = 0;
uint8_t div = 0;
void initPacket() {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&latchupId, &dataFieldPtr, &serializedSize,
sizeof(latchupId), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&tp, &dataFieldPtr, &serializedSize, sizeof(tp),
SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&div, &dataFieldPtr, &serializedSize, sizeof(div),
SerializeIF::Endianness::BIG);
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This class packages the space packet to set the sweep period of the ADC.
*/
class SetAdcSweepPeriod : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param sweepPeriod Sweep period in us. minimum is 21 us
*/
SetAdcSweepPeriod(uint32_t sweepPeriod)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_ADC_SWEEP_PERIOD, DEFAULT_SEQUENCE_COUNT),
sweepPeriod(sweepPeriod) {
initPacket();
}
private:
static const uint16_t DATA_FIELD_LENGTH = 6;
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint32_t sweepPeriod = 0;
void initPacket() {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint32_t>(&sweepPeriod, &dataFieldPtr, &serializedSize,
sizeof(sweepPeriod), SerializeIF::Endianness::BIG);
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This class packages the space packet to enable or disable ADC channels.
*/
@ -902,88 +677,6 @@ class SetAdcThreshold : public SpacePacket {
}
};
/**
* @brief This class packages the space packet to select between NVM 0 and NVM 1.
*/
class SelectNvm : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param mem 0 - select NVM0, 1 - select NVM1.
*/
SelectNvm(uint8_t mem)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SELECT_NVM, DEFAULT_SEQUENCE_COUNT),
mem(mem) {
initPacket();
}
private:
static const uint16_t DATA_FIELD_LENGTH = 3;
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t mem = 0;
void initPacket() {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&mem, &dataFieldPtr, &serializedSize, sizeof(mem),
SerializeIF::Endianness::BIG);
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This class packages the space packet to power the NVMs on or off.
*/
class EnableNvms : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param n01 Set to one to power NVM0 and NVM1 on. 0 powers off memory.
* @param n3 Set to one to power NVM3 on. 0 powers off the memory.
*/
EnableNvms(uint8_t n01, uint8_t n3)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT),
n01(n01),
n3(n3) {
initPacket();
}
private:
static const uint16_t DATA_FIELD_LENGTH = 4;
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t n01 = 0;
uint8_t n3 = 0;
void initPacket() {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&n01, &dataFieldPtr, &serializedSize, sizeof(n01),
SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&n3, &dataFieldPtr, &serializedSize, sizeof(n3),
SerializeIF::Endianness::BIG);
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This class packages the space packet to run auto EM tests.
*/
@ -1061,45 +754,6 @@ class PrintCpuStats : public SpacePacket {
}
};
/**
* @brief This class packages the space packet to set the print verbosity in the supervisor
* software.
*/
class SetDbgVerbosity : public SpacePacket {
public:
/**
* @brief Constructor
*
* @param vb 0: None, 1: Error, 2: Warn, 3: Info
*/
SetDbgVerbosity(uint8_t vb)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_DBG_VERBOSITY, DEFAULT_SEQUENCE_COUNT),
vb(vb) {
initPacket();
}
private:
static const uint16_t DATA_FIELD_LENGTH = 3;
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t vb = 0;
void initPacket() {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&vb, &dataFieldPtr, &serializedSize, sizeof(vb),
SerializeIF::Endianness::BIG);
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/**
* @brief This class packages the space packet to wipe or dump parts of the MRAM.
*/
@ -1537,6 +1191,61 @@ class DisableAutoTm : public SupvTcSpacePacket {
static const uint8_t DISABLE = 0;
};
/**
* @brief This class creates the space packet to enable the auto TM generation
*/
class EnableAdcMonitorTask : public SupvTcSpacePacket {
public:
EnableAdcMonitorTask() : SupvTcSpacePacket(PAYLOAD_LENGTH, APID_ADC_MONITOR_TASK) {
*(this->localData.fields.buffer) = ENABLE;
makeCrc();
}
private:
static const uint16_t PAYLOAD_LENGTH = 1; // length without CRC field
static const uint8_t ENABLE = 1;
};
/**
* @brief This class creates the space packet to enable the auto TM generation
*/
class DisableAdcMonitorTask : public SupvTcSpacePacket {
public:
DisableAdcMonitorTask() : SupvTcSpacePacket(PAYLOAD_LENGTH, APID_ADC_MONITOR_TASK) {
*(this->localData.fields.buffer) = DISABLE;
makeCrc();
}
private:
static const uint16_t PAYLOAD_LENGTH = 1; // length without CRC field
static const uint8_t DISABLE = 0;
};
/**
* @brief This class creates the space packet to request the logging data from the supervisor
*/
class RequestLoggingData : public SupvTcSpacePacket {
public:
enum class Sa : uint8_t {
REQUEST_COUNTERS = 1,
REQUEST_EVENT_BUFFERS = 2,
CLEAR_COUNTERS = 3,
SET_LOGGING_TOPIC = 4
};
RequestLoggingData(Sa sa, uint8_t tpc = 0)
: SupvTcSpacePacket(PAYLOAD_LENGTH, APID_REQUEST_LOGGING_DATA) {
*(this->localData.fields.buffer) = static_cast<uint8_t>(sa);
*(this->localData.fields.buffer + TPC_OFFSET) = tpc;
makeCrc();
}
private:
static const uint16_t PAYLOAD_LENGTH = 2; // length without CRC field
static const uint8_t TPC_OFFSET = 1;
};
/**
* @brief Class for handling tm replies of the supervisor.
*/
@ -1547,8 +1256,15 @@ class TmPacket : public SpacePacket {
*/
TmPacket() : SpacePacket(PACKET_MAX_SIZE) {}
/**
* @brief Returns the payload data length (data field length without CRC)
*/
uint16_t getPayloadDataLength() {
this->getPacketDataLength() - 1;
}
ReturnValue_t checkCrc() {
uint8_t* crcPtr = this->getPacketData() + this->getPacketDataLength() - 1;
uint8_t* crcPtr = this->getPacketData() + this->getPayloadDataLength();
uint16_t receivedCrc = *(crcPtr) << 8 | *(crcPtr + 1);
uint16_t recalculatedCrc =
CRC::crc16ccitt(this->localData.byteStream, this->getFullSize() - CRC_SIZE);
@ -1643,6 +1359,42 @@ class LatchupStatusReport : public StaticLocalDataSet<LATCHUP_RPT_SET_ENTRIES> {
static const uint8_t IS_SET_BIT_POS = 15;
};
/**
* @brief This dataset stores the logging report.
*/
class LoggingReport : public StaticLocalDataSet<LOGGING_RPT_SET_ENTRIES> {
public:
LoggingReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LOGGING_RPT_ID) {}
LoggingReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LOGGING_RPT_ID)) {}
lp_var_t<uint32_t> supervisorReboots =
lp_var_t<uint32_t>(sid.objectId, PoolIds::SUPERVISOR_REBOOTS, this);
lp_var_t<uint32_t> latchupEvents =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_EVENTS, this);
lp_var_t<uint32_t> adcTriggers = lp_var_t<uint32_t>(sid.objectId, PoolIds::ADC_TRIGGERS, this);
lp_var_t<uint32_t> psHeartbeatsLost =
lp_var_t<uint32_t>(sid.objectId, PoolIds::PS_HEARTBEATS_LOST, this);
lp_var_t<uint32_t> plHeartbeatsLost =
lp_var_t<uint32_t>(sid.objectId, PoolIds::PL_HEARTBEATS_LOST, this);
lp_var_t<uint32_t> tcReceived = lp_var_t<uint32_t>(sid.objectId, PoolIds::TC_RECEIVED, this);
lp_var_t<uint32_t> tmReceived = lp_var_t<uint32_t>(sid.objectId, PoolIds::TM_RECEIVED, this);
lp_var_t<uint32_t> socBoots = lp_var_t<uint32_t>(sid.objectId, PoolIds::SOC_BOOTS, this);
lp_var_t<uint32_t> socBootFails = lp_var_t<uint32_t>(sid.objectId, PoolIds::SOC_BOOT_FAILS, this);
void printSet() {
sif::info << "LoggingReport: Supervisor reboots: " << this->supervisorReboots << std::endl;
sif::info << "LoggingReport: Latchup events: " << this->latchupEvents << std::endl;
sif::info << "LoggingReport: ADC triggers: " << this->adcTriggers << std::endl;
sif::info << "LoggingReport: PS heartbeats lost: " << this->psHeartbeatsLost << std::endl;
sif::info << "LoggingReport: PL heartbeats lost: " << this->plHeartbeatsLost << std::endl;
sif::info << "LoggingReport: TC received: " << this->tcReceived << std::endl;
sif::info << "LoggingReport: TM received: " << this->tmReceived << std::endl;
sif::info << "LoggingReport: SoC boots: " << this->socBoots << std::endl;
sif::info << "LoggingReport: SoC boot fails: " << this->socBootFails << std::endl;
}
};
class UpdateStatusReport : public TmPacket {
public:
UpdateStatusReport() : TmPacket() {}

View File

@ -21,6 +21,7 @@ PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t u
hkset(this),
bootStatusReport(this),
latchupStatusReport(this),
loggingReport(this),
powerSwitch(powerSwitch),
supvHelper(supvHelper) {
if (comCookie == NULL) {
@ -81,10 +82,11 @@ void PlocSupervisorHandler::performOperationHook() {
ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) {
using namespace supv;
ReturnValue_t result = RETURN_OK;
switch (actionId) {
case supv::TERMINATE_SUPV_HELPER: {
case TERMINATE_SUPV_HELPER: {
supvHelper->stopProcess();
break;
}
@ -97,7 +99,7 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
}
switch (actionId) {
case supv::PERFORM_UPDATE: {
case PERFORM_UPDATE: {
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return SupvReturnValuesIF::FILENAME_TOO_LONG;
}
@ -115,6 +117,11 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
plocSupvHelperExecuting = true;
return EXECUTION_FINISHED;
}
case LOGGING_REQUEST_EVENT_BUFFERS:
if (size > config::MAX_PATH_SIZE) {
return SupvReturnValuesIF::FILENAME_TOO_LONG;
}
supvHelper->startEventbBufferRequest(std::string(reinterpret_cast<const char*>(data), size));
default:
break;
}
@ -142,213 +149,193 @@ ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(DeviceCommandI
ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
using namespace supv;
ReturnValue_t result = RETURN_FAILED;
switch (deviceCommand) {
case (supv::GET_HK_REPORT): {
prepareEmptyCmd(supv::APID_GET_HK_REPORT);
case GET_HK_REPORT: {
prepareEmptyCmd(APID_GET_HK_REPORT);
result = RETURN_OK;
break;
}
case (supv::RESTART_MPSOC): {
prepareEmptyCmd(supv::APID_RESTART_MPSOC);
case START_MPSOC: {
prepareEmptyCmd(APID_START_MPSOC);
result = RETURN_OK;
break;
}
case (supv::START_MPSOC): {
prepareEmptyCmd(supv::APID_START_MPSOC);
case SHUTDOWN_MPSOC: {
prepareEmptyCmd(APID_SHUTWOWN_MPSOC);
result = RETURN_OK;
break;
}
case (supv::SHUTDOWN_MPSOC): {
prepareEmptyCmd(supv::APID_SHUTWOWN_MPSOC);
result = RETURN_OK;
break;
}
case (supv::SEL_MPSOC_BOOT_IMAGE): {
case SEL_MPSOC_BOOT_IMAGE: {
prepareSelBootImageCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::RESET_MPSOC): {
prepareEmptyCmd(supv::APID_RESET_MPSOC);
case RESET_MPSOC: {
prepareEmptyCmd(APID_RESET_MPSOC);
result = RETURN_OK;
break;
}
case (supv::SET_TIME_REF): {
case SET_TIME_REF: {
result = prepareSetTimeRefCmd();
break;
}
case (supv::SET_BOOT_TIMEOUT): {
case SET_BOOT_TIMEOUT: {
prepareSetBootTimeoutCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::SET_MAX_RESTART_TRIES): {
case SET_MAX_RESTART_TRIES: {
prepareRestartTriesCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::DISABLE_PERIOIC_HK_TRANSMISSION): {
case DISABLE_PERIOIC_HK_TRANSMISSION: {
prepareDisableHk();
result = RETURN_OK;
break;
}
case (supv::GET_BOOT_STATUS_REPORT): {
prepareEmptyCmd(supv::APID_GET_BOOT_STATUS_RPT);
case GET_BOOT_STATUS_REPORT: {
prepareEmptyCmd(APID_GET_BOOT_STATUS_RPT);
result = RETURN_OK;
break;
}
case (supv::WATCHDOGS_ENABLE): {
prepareWatchdogsEnableCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::WATCHDOGS_CONFIG_TIMEOUT): {
result = prepareWatchdogsConfigTimeoutCmd(commandData);
break;
}
case (supv::ENABLE_LATCHUP_ALERT): {
case ENABLE_LATCHUP_ALERT: {
result = prepareLatchupConfigCmd(commandData, deviceCommand);
break;
}
case (supv::DISABLE_LATCHUP_ALERT): {
case DISABLE_LATCHUP_ALERT: {
result = prepareLatchupConfigCmd(commandData, deviceCommand);
break;
}
case (supv::AUTO_CALIBRATE_ALERT): {
result = prepareAutoCalibrateAlertCmd(commandData);
break;
}
case (supv::SET_ALERT_LIMIT): {
case SET_ALERT_LIMIT: {
result = prepareSetAlertLimitCmd(commandData);
break;
}
case (supv::SET_ALERT_IRQ_FILTER): {
result = prepareSetAlertIrqFilterCmd(commandData);
break;
}
case (supv::SET_ADC_SWEEP_PERIOD): {
result = prepareSetAdcSweetPeriodCmd(commandData);
break;
}
case (supv::SET_ADC_ENABLED_CHANNELS): {
case SET_ADC_ENABLED_CHANNELS: {
prepareSetAdcEnabledChannelsCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::SET_ADC_WINDOW_AND_STRIDE): {
case SET_ADC_WINDOW_AND_STRIDE: {
prepareSetAdcWindowAndStrideCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::SET_ADC_THRESHOLD): {
case SET_ADC_THRESHOLD: {
prepareSetAdcThresholdCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::GET_LATCHUP_STATUS_REPORT): {
prepareEmptyCmd(supv::APID_GET_LATCHUP_STATUS_REPORT);
case GET_LATCHUP_STATUS_REPORT: {
prepareEmptyCmd(APID_GET_LATCHUP_STATUS_REPORT);
result = RETURN_OK;
break;
}
case (supv::COPY_ADC_DATA_TO_MRAM): {
prepareEmptyCmd(supv::APID_COPY_ADC_DATA_TO_MRAM);
case COPY_ADC_DATA_TO_MRAM: {
prepareEmptyCmd(APID_COPY_ADC_DATA_TO_MRAM);
result = RETURN_OK;
break;
}
case (supv::ENABLE_NVMS): {
prepareEnableNvmsCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::SELECT_NVM): {
prepareSelectNvmCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::RUN_AUTO_EM_TESTS): {
case RUN_AUTO_EM_TESTS: {
result = prepareRunAutoEmTest(commandData);
break;
}
case (supv::WIPE_MRAM): {
case WIPE_MRAM: {
result = prepareWipeMramCmd(commandData);
break;
}
case (supv::FIRST_MRAM_DUMP):
case (supv::CONSECUTIVE_MRAM_DUMP):
case FIRST_MRAM_DUMP:
case CONSECUTIVE_MRAM_DUMP:
result = prepareDumpMramCmd(commandData);
break;
case (supv::PRINT_CPU_STATS): {
preparePrintCpuStatsCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::SET_DBG_VERBOSITY): {
prepareSetDbgVerbosityCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::CAN_LOOPBACK_TEST): {
prepareEmptyCmd(supv::APID_CAN_LOOPBACK_TEST);
result = RETURN_OK;
break;
}
case (supv::SET_GPIO): {
case SET_GPIO: {
prepareSetGpioCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::READ_GPIO): {
case READ_GPIO: {
prepareReadGpioCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::RESTART_SUPERVISOR): {
prepareEmptyCmd(supv::APID_RESTART_SUPERVISOR);
case RESTART_SUPERVISOR: {
prepareEmptyCmd(APID_RESTART_SUPERVISOR);
result = RETURN_OK;
break;
}
case (supv::FACTORY_RESET_CLEAR_ALL): {
supv::FactoryReset packet(supv::FactoryReset::Op::CLEAR_ALL);
case FACTORY_RESET_CLEAR_ALL: {
FactoryReset packet(FactoryReset::Op::CLEAR_ALL);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case (supv::FACTORY_RESET_CLEAR_MIRROR): {
supv::FactoryReset packet(supv::FactoryReset::Op::MIRROR_ENTRIES);
case FACTORY_RESET_CLEAR_MIRROR: {
FactoryReset packet(FactoryReset::Op::MIRROR_ENTRIES);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case (supv::FACTORY_RESET_CLEAR_CIRCULAR): {
supv::FactoryReset packet(supv::FactoryReset::Op::CIRCULAR_ENTRIES);
case FACTORY_RESET_CLEAR_CIRCULAR: {
FactoryReset packet(FactoryReset::Op::CIRCULAR_ENTRIES);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case (supv::START_MPSOC_QUIET): {
prepareEmptyCmd(supv::APID_START_MPSOC_QUIET);
case START_MPSOC_QUIET: {
prepareEmptyCmd(APID_START_MPSOC_QUIET);
result = RETURN_OK;
break;
}
case (supv::SET_SHUTDOWN_TIMEOUT): {
case SET_SHUTDOWN_TIMEOUT: {
prepareSetShutdownTimeoutCmd(commandData);
result = RETURN_OK;
break;
}
case (supv::FACTORY_FLASH): {
prepareEmptyCmd(supv::APID_FACTORY_FLASH);
case FACTORY_FLASH: {
prepareEmptyCmd(APID_FACTORY_FLASH);
result = RETURN_OK;
break;
}
case (supv::ENABLE_AUTO_TM): {
supv::EnableAutoTm packet;
case ENABLE_AUTO_TM: {
EnableAutoTm packet;
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case (supv::DISABLE_AUTO_TM): {
supv::DisableAutoTm packet;
case DISABLE_AUTO_TM: {
DisableAutoTm packet;
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case ENABLE_ADC_MONITOR_TASK: {
EnableAdcMonitorTask packet;
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case DISABLE_ADC_MONITOR_TASK: {
DisableAdcMonitorTask packet;
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case LOGGING_REQUEST_COUNTERS: {
RequestLoggingData packet(RequestLoggingData::Sa::REQUEST_COUNTERS);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case LOGGING_CLEAR_COUNTERS: {
RequestLoggingData packet(RequestLoggingData::Sa::CLEAR_COUNTERS);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
}
case LOGGING_SET_TOPIC: {
RequestLoggingData packet(RequestLoggingData::Sa::SET_LOGGING_TOPIC);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
result = RETURN_OK;
break;
@ -371,57 +358,178 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
}
void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(supv::GET_HK_REPORT);
this->insertInCommandMap(supv::RESTART_MPSOC);
this->insertInCommandMap(supv::START_MPSOC);
this->insertInCommandMap(supv::SHUTDOWN_MPSOC);
this->insertInCommandMap(supv::SEL_MPSOC_BOOT_IMAGE);
this->insertInCommandMap(supv::SET_BOOT_TIMEOUT);
this->insertInCommandMap(supv::SET_MAX_RESTART_TRIES);
this->insertInCommandMap(supv::RESET_MPSOC);
this->insertInCommandMap(supv::SET_TIME_REF);
this->insertInCommandMap(supv::DISABLE_PERIOIC_HK_TRANSMISSION);
this->insertInCommandMap(supv::GET_BOOT_STATUS_REPORT);
this->insertInCommandMap(supv::WATCHDOGS_ENABLE);
this->insertInCommandMap(supv::WATCHDOGS_CONFIG_TIMEOUT);
this->insertInCommandMap(supv::ENABLE_LATCHUP_ALERT);
this->insertInCommandMap(supv::DISABLE_LATCHUP_ALERT);
this->insertInCommandMap(supv::AUTO_CALIBRATE_ALERT);
this->insertInCommandMap(supv::SET_ALERT_LIMIT);
this->insertInCommandMap(supv::SET_ALERT_IRQ_FILTER);
this->insertInCommandMap(supv::SET_ADC_SWEEP_PERIOD);
this->insertInCommandMap(supv::SET_ADC_ENABLED_CHANNELS);
this->insertInCommandMap(supv::SET_ADC_WINDOW_AND_STRIDE);
this->insertInCommandMap(supv::SET_ADC_THRESHOLD);
this->insertInCommandMap(supv::GET_LATCHUP_STATUS_REPORT);
this->insertInCommandMap(supv::COPY_ADC_DATA_TO_MRAM);
this->insertInCommandMap(supv::ENABLE_NVMS);
this->insertInCommandMap(supv::SELECT_NVM);
this->insertInCommandMap(supv::RUN_AUTO_EM_TESTS);
this->insertInCommandMap(supv::WIPE_MRAM);
this->insertInCommandMap(supv::PRINT_CPU_STATS);
this->insertInCommandMap(supv::SET_DBG_VERBOSITY);
this->insertInCommandMap(supv::SET_GPIO);
this->insertInCommandMap(supv::READ_GPIO);
this->insertInCommandMap(supv::RESTART_SUPERVISOR);
this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_ALL);
this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_MIRROR);
this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_CIRCULAR);
this->insertInCommandMap(supv::CAN_LOOPBACK_TEST);
this->insertInCommandMap(supv::START_MPSOC_QUIET);
this->insertInCommandMap(supv::SET_SHUTDOWN_TIMEOUT);
this->insertInCommandMap(supv::FACTORY_FLASH);
this->insertInCommandMap(supv::ENABLE_AUTO_TM);
this->insertInCommandMap(supv::DISABLE_AUTO_TM);
this->insertInCommandAndReplyMap(supv::FIRST_MRAM_DUMP, 3);
this->insertInCommandAndReplyMap(supv::CONSECUTIVE_MRAM_DUMP, 3);
this->insertInReplyMap(supv::ACK_REPORT, 3, nullptr, supv::SIZE_ACK_REPORT);
this->insertInReplyMap(supv::EXE_REPORT, 120, nullptr, supv::SIZE_EXE_REPORT);
this->insertInReplyMap(supv::HK_REPORT, 3, &hkset, supv::SIZE_HK_REPORT);
this->insertInReplyMap(supv::BOOT_STATUS_REPORT, 3, &bootStatusReport,
supv::SIZE_BOOT_STATUS_REPORT);
this->insertInReplyMap(supv::LATCHUP_REPORT, 3, &latchupStatusReport,
supv::SIZE_LATCHUP_STATUS_REPORT);
using namespace supv;
this->insertInCommandMap(GET_HK_REPORT);
this->insertInCommandMap(START_MPSOC);
this->insertInCommandMap(SHUTDOWN_MPSOC);
this->insertInCommandMap(SEL_MPSOC_BOOT_IMAGE);
this->insertInCommandMap(SET_BOOT_TIMEOUT);
this->insertInCommandMap(SET_MAX_RESTART_TRIES);
this->insertInCommandMap(RESET_MPSOC);
this->insertInCommandMap(SET_TIME_REF);
this->insertInCommandMap(DISABLE_PERIOIC_HK_TRANSMISSION);
this->insertInCommandMap(GET_BOOT_STATUS_REPORT);
this->insertInCommandMap(ENABLE_LATCHUP_ALERT);
this->insertInCommandMap(DISABLE_LATCHUP_ALERT);
this->insertInCommandMap(SET_ALERT_LIMIT);
this->insertInCommandMap(SET_ADC_ENABLED_CHANNELS);
this->insertInCommandMap(SET_ADC_WINDOW_AND_STRIDE);
this->insertInCommandMap(SET_ADC_THRESHOLD);
this->insertInCommandMap(GET_LATCHUP_STATUS_REPORT);
this->insertInCommandMap(COPY_ADC_DATA_TO_MRAM);
this->insertInCommandMap(RUN_AUTO_EM_TESTS);
this->insertInCommandMap(WIPE_MRAM);
this->insertInCommandMap(PRINT_CPU_STATS);
this->insertInCommandMap(SET_GPIO);
this->insertInCommandMap(READ_GPIO);
this->insertInCommandMap(RESTART_SUPERVISOR);
this->insertInCommandMap(FACTORY_RESET_CLEAR_ALL);
this->insertInCommandMap(FACTORY_RESET_CLEAR_MIRROR);
this->insertInCommandMap(FACTORY_RESET_CLEAR_CIRCULAR);
this->insertInCommandMap(START_MPSOC_QUIET);
this->insertInCommandMap(SET_SHUTDOWN_TIMEOUT);
this->insertInCommandMap(FACTORY_FLASH);
this->insertInCommandMap(ENABLE_AUTO_TM);
this->insertInCommandMap(DISABLE_AUTO_TM);
this->insertInCommandMap(ENABLE_ADC_MONITOR_TASK);
this->insertInCommandMap(DISABLE_ADC_MONITOR_TASK);
this->insertInCommandMap(LOGGING_REQUEST_COUNTERS);
this->insertInCommandAndReplyMap(FIRST_MRAM_DUMP, 3);
this->insertInCommandAndReplyMap(CONSECUTIVE_MRAM_DUMP, 3);
this->insertInReplyMap(ACK_REPORT, 3, nullptr, SIZE_ACK_REPORT);
this->insertInReplyMap(EXE_REPORT, 3, nullptr, SIZE_EXE_REPORT);
this->insertInReplyMap(HK_REPORT, 3, &hkset, SIZE_HK_REPORT);
this->insertInReplyMap(BOOT_STATUS_REPORT, 3, &bootStatusReport, SIZE_BOOT_STATUS_REPORT);
this->insertInReplyMap(LATCHUP_REPORT, 3, &latchupStatusReport, SIZE_LATCHUP_STATUS_REPORT);
this->insertInReplyMap(LOGGING_REPORT, 3, &loggingReport, SIZE_LOGGING_REPORT);
}
ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies,
bool useAlternateId,
DeviceCommandId_t alternateReplyID) {
ReturnValue_t result = RETURN_OK;
uint8_t enabledReplies = 0;
switch (command->first) {
case supv::GET_HK_REPORT: {
enabledReplies = 3;
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::HK_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::HK_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::GET_BOOT_STATUS_REPORT: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::BOOT_STATUS_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::BOOT_STATUS_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::GET_LATCHUP_STATUS_REPORT: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::LATCHUP_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::LATCHUP_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::LOGGING_REQUEST_COUNTERS: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::LOGGING_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::LOGGING_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::FIRST_MRAM_DUMP: {
enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::FIRST_MRAM_DUMP);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::FIRST_MRAM_DUMP << " not in replyMap" << std::endl;
}
break;
}
case supv::CONSECUTIVE_MRAM_DUMP: {
enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::CONSECUTIVE_MRAM_DUMP);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl;
}
break;
}
case supv::START_MPSOC:
case supv::SHUTDOWN_MPSOC:
case supv::SEL_MPSOC_BOOT_IMAGE:
case supv::SET_BOOT_TIMEOUT:
case supv::SET_MAX_RESTART_TRIES:
case supv::RESET_MPSOC:
case supv::SET_TIME_REF:
case supv::ENABLE_LATCHUP_ALERT:
case supv::DISABLE_LATCHUP_ALERT:
case supv::SET_ALERT_LIMIT:
case supv::SET_ADC_ENABLED_CHANNELS:
case supv::SET_ADC_WINDOW_AND_STRIDE:
case supv::SET_ADC_THRESHOLD:
case supv::COPY_ADC_DATA_TO_MRAM:
case supv::RUN_AUTO_EM_TESTS:
case supv::WIPE_MRAM:
case supv::PRINT_CPU_STATS:
case supv::SET_GPIO:
case supv::READ_GPIO:
case supv::RESTART_SUPERVISOR:
case supv::FACTORY_RESET_CLEAR_ALL:
case supv::FACTORY_RESET_CLEAR_MIRROR:
case supv::FACTORY_RESET_CLEAR_CIRCULAR:
case supv::DISABLE_PERIOIC_HK_TRANSMISSION:
case supv::START_MPSOC_QUIET:
case supv::SET_SHUTDOWN_TIMEOUT:
case supv::FACTORY_FLASH:
case supv::ENABLE_AUTO_TM:
case supv::DISABLE_AUTO_TM:
case supv::ENABLE_ADC_MONITOR_TASK:
case supv::DISABLE_ADC_MONITOR_TASK:
enabledReplies = 2;
break;
default:
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl;
break;
}
/**
* Every command causes at least one acknowledgment and one execution report. Therefore both
* replies will be enabled here.
*/
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::ACK_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::ACK_REPORT
<< " not in replyMap" << std::endl;
}
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::EXE_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::EXE_REPORT
<< " not in replyMap" << std::endl;
}
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t remainingSize,
@ -459,6 +567,10 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r
*foundLen = supv::SIZE_LATCHUP_STATUS_REPORT;
*foundId = supv::LATCHUP_REPORT;
break;
case (supv::APID_DATA_LOGGER_DATA):
*foundLen = supv::SIZE_LOGGING_REPORT;
*foundId = supv::LOGGING_REPORT;
break;
case (supv::APID_EXE_SUCCESS):
*foundLen = supv::SIZE_EXE_REPORT;
*foundId = supv::EXE_REPORT;
@ -508,6 +620,10 @@ ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
result = handleLatchupStatusReport(packet);
break;
}
case (supv::LOGGING_REPORT): {
result = handleLoggingReport(packet);
break;
}
case (supv::FIRST_MRAM_DUMP):
case (supv::CONSECUTIVE_MRAM_DUMP):
result = handleMramDumpPacket(id);
@ -587,133 +703,6 @@ void PlocSupervisorHandler::handleEvent(EventMessage* eventMessage) {
}
}
ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies,
bool useAlternateId,
DeviceCommandId_t alternateReplyID) {
ReturnValue_t result = RETURN_OK;
uint8_t enabledReplies = 0;
switch (command->first) {
case supv::GET_HK_REPORT: {
enabledReplies = 3;
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::HK_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::HK_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::GET_BOOT_STATUS_REPORT: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::BOOT_STATUS_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::BOOT_STATUS_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::GET_LATCHUP_STATUS_REPORT: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::LATCHUP_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::LATCHUP_REPORT << " not in replyMap" << std::endl;
}
break;
}
case supv::FIRST_MRAM_DUMP: {
enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::FIRST_MRAM_DUMP);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::FIRST_MRAM_DUMP << " not in replyMap" << std::endl;
}
break;
}
case supv::CONSECUTIVE_MRAM_DUMP: {
enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
supv::CONSECUTIVE_MRAM_DUMP);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id "
<< supv::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl;
}
break;
}
case supv::RESTART_MPSOC:
case supv::START_MPSOC:
case supv::SHUTDOWN_MPSOC:
case supv::SEL_MPSOC_BOOT_IMAGE:
case supv::SET_BOOT_TIMEOUT:
case supv::SET_MAX_RESTART_TRIES:
case supv::RESET_MPSOC:
case supv::SET_TIME_REF:
case supv::WATCHDOGS_ENABLE:
case supv::WATCHDOGS_CONFIG_TIMEOUT:
case supv::ENABLE_LATCHUP_ALERT:
case supv::DISABLE_LATCHUP_ALERT:
case supv::AUTO_CALIBRATE_ALERT:
case supv::SET_ALERT_LIMIT:
case supv::SET_ALERT_IRQ_FILTER:
case supv::SET_ADC_SWEEP_PERIOD:
case supv::SET_ADC_ENABLED_CHANNELS:
case supv::SET_ADC_WINDOW_AND_STRIDE:
case supv::SET_ADC_THRESHOLD:
case supv::COPY_ADC_DATA_TO_MRAM:
case supv::ENABLE_NVMS:
case supv::SELECT_NVM:
case supv::RUN_AUTO_EM_TESTS:
case supv::WIPE_MRAM:
case supv::SET_DBG_VERBOSITY:
case supv::CAN_LOOPBACK_TEST:
case supv::PRINT_CPU_STATS:
case supv::SET_GPIO:
case supv::READ_GPIO:
case supv::RESTART_SUPERVISOR:
case supv::FACTORY_RESET_CLEAR_ALL:
case supv::FACTORY_RESET_CLEAR_MIRROR:
case supv::FACTORY_RESET_CLEAR_CIRCULAR:
case supv::REQUEST_LOGGING_DATA:
case supv::DISABLE_PERIOIC_HK_TRANSMISSION:
case supv::START_MPSOC_QUIET:
case supv::SET_SHUTDOWN_TIMEOUT:
case supv::FACTORY_FLASH:
case supv::ENABLE_AUTO_TM:
case supv::DISABLE_AUTO_TM:
enabledReplies = 2;
break;
default:
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl;
break;
}
/**
* Every command causes at least one acknowledgment and one execution report. Therefore both
* replies will be enabled here.
*/
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::ACK_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::ACK_REPORT
<< " not in replyMap" << std::endl;
}
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::EXE_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::EXE_REPORT
<< " not in replyMap" << std::endl;
}
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
@ -1037,6 +1026,41 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da
return result;
}
ReturnValue_t PlocSupervisorHandler::handleLoggingReport(const uint8_t* data) {
ReturnValue_t result = RETURN_OK;
result = verifyPacket(data, supv::SIZE_LOGGING_REPORT);
if (result == SupvReturnValuesIF::CRC_FAILURE) {
sif::error << "PlocSupervisorHandler::handleLoggingReport: Logging report has "
<< "invalid crc" << std::endl;
return result;
}
const uint8_t* dataField = data + supv::DATA_FIELD_OFFSET + sizeof(sa);
result = loggingReport.read();
if (result != RETURN_OK) {
return result;
}
loggingReport.setValidityBufferGeneration(false);
size_t size = loggingReport.getSerializedSize();
result = loggingReport.deSerialize(&dataField, &size, SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::warning << "StarTrackerHandler::handleLoggingReport: Deserialization failed" << std::endl;
}
loggingReport.setValidityBufferGeneration(true);
loggingReport.setValidity(true, true);
result = loggingReport.commit();
if (result != RETURN_OK) {
return result;
}
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1
loggingReport.printSet();
#endif
nextReplyId = supv::EXE_REPORT;
return result;
}
void PlocSupervisorHandler::setNextReplyId() {
switch (getPendingCommand()) {
case supv::GET_HK_REPORT:
@ -1161,34 +1185,6 @@ void PlocSupervisorHandler::prepareRestartTriesCmd(const uint8_t* commandData) {
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
}
void PlocSupervisorHandler::prepareWatchdogsEnableCmd(const uint8_t* commandData) {
uint8_t offset = 0;
uint8_t watchdogPs = *(commandData + offset);
offset += 1;
uint8_t watchdogPl = *(commandData + offset);
offset += 1;
uint8_t watchdogInt = *(commandData + offset);
supv::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
}
ReturnValue_t PlocSupervisorHandler::prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData) {
uint8_t offset = 0;
uint8_t watchdog = *(commandData + offset);
offset += 1;
if (watchdog > 2) {
return SupvReturnValuesIF::INVALID_WATCHDOG;
}
uint32_t timeout = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 |
*(commandData + offset + 2) << 8 | *(commandData + offset + 3);
if (timeout < 1000 || timeout > 360000) {
return SupvReturnValuesIF::INVALID_WATCHDOG_TIMEOUT;
}
supv::WatchdogsConfigTimeout packet(watchdog, timeout);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* commandData,
DeviceCommandId_t deviceCommand) {
ReturnValue_t result = RETURN_OK;
@ -1217,32 +1213,6 @@ ReturnValue_t PlocSupervisorHandler::prepareLatchupConfigCmd(const uint8_t* comm
return result;
}
ReturnValue_t PlocSupervisorHandler::prepareAutoCalibrateAlertCmd(const uint8_t* commandData) {
uint8_t offset = 0;
uint8_t latchupId = *commandData;
offset += 1;
uint32_t mg = *(commandData + offset) << 24 | *(commandData + offset + 1) << 16 |
*(commandData + offset + 2) << 8 | *(commandData + offset + 3);
if (latchupId > 6) {
return SupvReturnValuesIF::INVALID_LATCHUP_ID;
}
supv::AutoCalibrateAlert packet(latchupId, mg);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::prepareSetAlertIrqFilterCmd(const uint8_t* commandData) {
uint8_t latchupId = *commandData;
uint8_t tp = *(commandData + 1);
uint8_t div = *(commandData + 2);
if (latchupId > 6) {
return SupvReturnValuesIF::INVALID_LATCHUP_ID;
}
supv::SetAlertIrqFilter packet(latchupId, tp, div);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* commandData) {
uint8_t offset = 0;
uint8_t latchupId = *commandData;
@ -1257,17 +1227,6 @@ ReturnValue_t PlocSupervisorHandler::prepareSetAlertLimitCmd(const uint8_t* comm
return RETURN_OK;
}
ReturnValue_t PlocSupervisorHandler::prepareSetAdcSweetPeriodCmd(const uint8_t* commandData) {
uint32_t sweepPeriod = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 |
*(commandData + 3);
if (sweepPeriod < 21) {
return SupvReturnValuesIF::SWEEP_PERIOD_TOO_SMALL;
}
supv::SetAdcSweepPeriod packet(sweepPeriod);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
return RETURN_OK;
}
void PlocSupervisorHandler::prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData) {
uint16_t ch = *(commandData) << 8 | *(commandData + 1);
supv::SetAdcEnabledChannels packet(ch);
@ -1290,19 +1249,6 @@ void PlocSupervisorHandler::prepareSetAdcThresholdCmd(const uint8_t* commandData
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
}
void PlocSupervisorHandler::prepareEnableNvmsCmd(const uint8_t* commandData) {
uint8_t n01 = *commandData;
uint8_t n3 = *(commandData + 1);
supv::EnableNvms packet(n01, n3);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
}
void PlocSupervisorHandler::prepareSelectNvmCmd(const uint8_t* commandData) {
uint8_t mem = *commandData;
supv::SelectNvm packet(mem);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
}
ReturnValue_t PlocSupervisorHandler::prepareRunAutoEmTest(const uint8_t* commandData) {
uint8_t test = *commandData;
if (test != 1 && test != 2) {
@ -1346,18 +1292,6 @@ ReturnValue_t PlocSupervisorHandler::prepareDumpMramCmd(const uint8_t* commandDa
return RETURN_OK;
}
void PlocSupervisorHandler::preparePrintCpuStatsCmd(const uint8_t* commandData) {
uint8_t en = *commandData;
supv::PrintCpuStats packet(en);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
}
void PlocSupervisorHandler::prepareSetDbgVerbosityCmd(const uint8_t* commandData) {
uint8_t vb = *commandData;
supv::SetDbgVerbosity packet(vb);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
}
void PlocSupervisorHandler::prepareSetGpioCmd(const uint8_t* commandData) {
uint8_t port = *commandData;
uint8_t pin = *(commandData + 1);
@ -1395,6 +1329,15 @@ void PlocSupervisorHandler::prepareSetShutdownTimeoutCmd(const uint8_t* commandD
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
}
ReturnValue_t PlocSupervisorHandler::prepareLoggingRequest(const uint8_t* commandData,
size_t commandDataLen) {
uint8_t sa = *commandData;
uint8_t tpc = *(commandData + 1);
supv::RequestLoggingData packet(sa, tpc);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
return RETURN_OK;
}
void PlocSupervisorHandler::disableAllReplies() {
DeviceReplyMap::iterator iter;
@ -1690,7 +1633,7 @@ ReturnValue_t PlocSupervisorHandler::eventSubscription() {
}
result = manager->subscribeToEventRange(
eventQueue->getId(), event::getEventId(PlocSupvHelper::SUPV_UPDATE_FAILED),
event::getEventId(PlocSupvHelper::TERMINATED_UPDATE_PROCEDURE));
event::getEventId(PlocSupvHelper::SUPV_EVENT_BUFFER_REQUEST_TERMINATED));
if (result != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PlocSupervisorHandler::eventSubscritpion: Failed to subscribe to events from "

View File

@ -92,6 +92,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
supv::HkSet hkset;
supv::BootStatusReport bootStatusReport;
supv::LatchupStatusReport latchupStatusReport;
supv::LoggingReport loggingReport;
const power::Switch_t powerSwitch = power::NO_SWITCH;
@ -175,6 +176,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
ReturnValue_t handleBootStatusReport(const uint8_t* data);
ReturnValue_t handleLatchupStatusReport(const uint8_t* data);
ReturnValue_t handleLoggingReport(const uint8_t* data);
/**
* @brief Depending on the current active command, this function sets the reply id of the
@ -235,22 +237,16 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData,
DeviceCommandId_t deviceCommand);
ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData);
void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData);
void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData);
void prepareSetAdcThresholdCmd(const uint8_t* commandData);
void prepareEnableNvmsCmd(const uint8_t* commandData);
void prepareSelectNvmCmd(const uint8_t* commandData);
ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData);
ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData);
ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData);
void preparePrintCpuStatsCmd(const uint8_t* commandData);
void prepareSetDbgVerbosityCmd(const uint8_t* commandData);
void prepareSetGpioCmd(const uint8_t* commandData);
void prepareReadGpioCmd(const uint8_t* commandData);
ReturnValue_t prepareLoggingRequest(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Copies the content of a space packet to the command buffer.

View File

@ -39,9 +39,26 @@ ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
case InternalState::UPDATE: {
result = performUpdate();
if (result == RETURN_OK) {
triggerEvent(SUPV_UPDATE_SUCCESSFUL);
triggerEvent(SUPV_UPDATE_SUCCESSFUL, result);
} else if (result == PROCESS_TERMINATED) {
// Event already triggered
break;
} else {
triggerEvent(SUPV_UPDATE_FAILED);
triggerEvent(SUPV_UPDATE_FAILED, result);
}
internalState = InternalState::IDLE;
break;
}
case InternalState::REQUEST_EVENT_BUFFER: {
result = performEventBufferRequest();
if (result == RETURN_OK) {
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL, result);
} else if (result == PROCESS_TERMINATED) {
// Event already triggered
break;
}
else {
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_FAILED, result);
}
internalState = InternalState::IDLE;
break;
@ -101,6 +118,23 @@ ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId,
return result;
}
ReturnValue_t PlocSupvHelper::startEventbBufferRequest(std::string path) {
#ifdef XIPHOS_Q7S
ReturnValue_t result = FilesystemHelper::checkPath(path);
if (result != RETURN_OK) {
return result;
}
#endif
if (not std::filesystem::exists(path)) {
return PATH_NOT_EXISTS;
}
eventBufferReq.path = path;
internalState = InternalState::REQUEST_EVENT_BUFFER;
uartComIF->flushUartTxAndRxBuf(comCookie);
semaphore.release();
return RETURN_OK;
}
void PlocSupvHelper::stopProcess() { terminate = true; }
ReturnValue_t PlocSupvHelper::performUpdate() {
@ -159,6 +193,28 @@ ReturnValue_t PlocSupvHelper::performUpdate() {
return result;
}
ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
using namespace supv;
ReturnValuet_t result = RETURN_OK;
RequestLoggingData packet(RequestLoggingData::Sa::REQUEST_EVENT_BUFFERS);
result = sendCommand(packet);
if (result != RETURN_OK) {
return result;
}
result = handleAck();
if (result != RETURN_OK) {
return result;
}
result = handleEventBufferReception();
if (result != RETURN_OK) {
return result;
}
result = handleExe();
if (result != RETURN_OK) {
return result;
}
}
ReturnValue_t PlocSupvHelper::prepareUpdate() {
ReturnValue_t result = RETURN_OK;
supv::ApidOnlyPacket packet(supv::APID_PREPARE_UPDATE);
@ -379,3 +435,33 @@ uint32_t PlocSupvHelper::getFileSize(std::string filename) {
file.seekg(0, file.end);
return file.tellg();
}
ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
std::sring filename = Filenaming::generateAbsoluteFilename(eventBufferReq.pat,
eventBufferReq.filename, timestamping);
std::ofstream file(filename, std::ios_base::app | std::ios_base::out);
uint32_t packetsRead = 0;
supv::TmPacket tmPacket;
for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS - 1; packetsRead++) {
if (terminate) {
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_TERMINATED, packetsRead - 1);
file.close();
return PROCESS_TERMINATED;
}
result = handleTmReception(&tmPacket, SIZE_EVENT_BUFFER_FULL_PACKET);
if (result != RETURN_OK) {
return result;
}
uint16_t apid = tmPacket.getAPID();
if (apid != supv::APID_MRAM_DUMP_TM) {
sif::warning << "PlocSupvHelper::handleEventBufferReception: Did not expect space packet "
<< "with APID " << std::hex << std::endl;
return EVENT_BUFFER_REQUEST_INVALID_APID;
}
file.write(reinterpret_cast<const char*>(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH),
packetLen - 1);
}
file.write(reinterpret_cast<const char*>(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH),
packetLen - 1);
}

View File

@ -29,41 +29,48 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
static const Event SUPV_UPDATE_SUCCESSFUL = MAKE_EVENT(1, severity::LOW);
//! [EXPORT] : [COMMENT] Terminated update procedure by command
static const Event TERMINATED_UPDATE_PROCEDURE = MAKE_EVENT(2, severity::LOW);
//! [EXPORT] : [COMMENT] Requesting event buffer was successful
static const Event SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL = MAKE_EVENT(3, severity::LOW);
//! [EXPORT] : [COMMENT] Requesting event buffer failed
static const Event SUPV_EVENT_BUFFER_REQUEST_FAILED = MAKE_EVENT(4, severity::LOW);
//! [EXPORT] : [COMMENT] Terminated event buffer request by command
//! P1: Number of packets read before process was terminated
static const Event SUPV_EVENT_BUFFER_REQUEST_TERMINATED = MAKE_EVENT(5, severity::LOW);
//! [EXPORT] : [COMMENT] Communication interface returned failure when trying to send the command
//! to the supervisor
//! P1: Return value returned by the communication interface sendMessage function
//! P2: Internal state of supervisor helper
static const Event SUPV_SENDING_COMMAND_FAILED = MAKE_EVENT(3, severity::LOW);
static const Event SUPV_SENDING_COMMAND_FAILED = MAKE_EVENT(6, severity::LOW);
//! [EXPORT] : [COMMENT] Request receive message of communication interface failed
//! P1: Return value returned by the communication interface requestReceiveMessage function
//! P2: Internal state of supervisor helper
static const Event SUPV_HELPER_REQUESTING_REPLY_FAILED = MAKE_EVENT(4, severity::LOW);
static const Event SUPV_HELPER_REQUESTING_REPLY_FAILED = MAKE_EVENT(7, severity::LOW);
//! [EXPORT] : [COMMENT] Reading receive message of communication interface failed
//! P1: Return value returned by the communication interface readingReceivedMessage function
//! P2: Internal state of supervisor helper
static const Event SUPV_HELPER_READING_REPLY_FAILED = MAKE_EVENT(5, severity::LOW);
static const Event SUPV_HELPER_READING_REPLY_FAILED = MAKE_EVENT(8, severity::LOW);
//! [EXPORT] : [COMMENT] Did not receive acknowledgement report
//! P1: Number of bytes missing
//! P2: Internal state of MPSoC helper
static const Event SUPV_MISSING_ACK = MAKE_EVENT(6, severity::LOW);
static const Event SUPV_MISSING_ACK = MAKE_EVENT(9, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor did not receive execution report
//! P1: Number of bytes missing
//! P2: Internal state of supervisor helper
static const Event SUPV_MISSING_EXE = MAKE_EVENT(7, severity::LOW);
static const Event SUPV_MISSING_EXE = MAKE_EVENT(10, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor received acknowledgment failure report
//! P1: Internal state of supervisor helper
static const Event SUPV_ACK_FAILURE_REPORT = MAKE_EVENT(8, severity::LOW);
static const Event SUPV_ACK_FAILURE_REPORT = MAKE_EVENT(11, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor received execution failure report
//! P1: Internal state of supervisor
static const Event SUPV_EXE_FAILURE_REPORT = MAKE_EVENT(9, severity::LOW);
static const Event SUPV_EXE_FAILURE_REPORT = MAKE_EVENT(12, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor expected acknowledgment report but received space packet with other apid
//! P1: Apid of received space packet
//! P2: Internal state of supervisor helper
static const Event SUPV_ACK_INVALID_APID = MAKE_EVENT(10, severity::LOW);
static const Event SUPV_ACK_INVALID_APID = MAKE_EVENT(13, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor helper expected execution report but received space packet with other apid
//! P1: Apid of received space packet
//! P2: Internal state of supervisor helper
static const Event SUPV_EXE_INVALID_APID = MAKE_EVENT(11, severity::LOW);
static const Event SUPV_EXE_INVALID_APID = MAKE_EVENT(14, severity::LOW);
PlocSupvHelper(object_id_t objectId);
virtual ~PlocSupvHelper();
@ -85,6 +92,11 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
*/
ReturnValue_t startUpdate(std::string file, uint8_t memoryId, uint32_t startAddress);
/**
* @brief Calling this function will initiate the procedure to request the event buffer
*/
ReturnValue_t startEventbBufferRequest(std::string path);
/**
* @brief Can be used to interrupt a running data transfer.
*/
@ -95,12 +107,22 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
//! [EXPORT] : [COMMENT] File accidentally close
static const ReturnValue_t FILE_CLOSED_ACCIDENTALLY = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Process has been terminated by command
static const ReturnValue_t PROCESS_TERMINATED = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Received command with invalid pathname
static const ReturnValue_t PATH_NOT_EXISTS = MAKE_RETURN_CODE(0xA2);
//! [EXPORT] : [COMMENT] Expected event buffer TM but received space packet with other APID
static const ReturnValue_t EVENT_BUFFER_REQUEST_INVALID_APID = MAKE_RETURN_CODE(0xA3);
// Maximum number of times the communication interface retries polling data from the reply
// buffer
static const int RETRIES = 10000;
static const uint16_t CRC16_INIT = 0xFFFF;
// Event buffer reply will carry 24 space packets with 1016 bytes and one space packet with
// 192 bytes
static const uint8_t NUM_EVENT_BUFFER_PACKETS = 25;
static const size_t SIZE_EVENT_BUFFER_FULL_PACKET = 1024;
static const size_t SIZE_EVENT_BUFFER_LAST_PACKET = 200;
struct Update {
uint8_t memoryId;
@ -114,7 +136,16 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
struct Update update;
enum class InternalState { IDLE, UPDATE };
struct EventBufferRequest {
std::string path = "";
// Default name of file where event buffer data will be written to. Timestamp will be added to
// name when new file is created
std::string filename = "event-buffer";
};
EventBufferRequest eventBufferReq;
enum class InternalState { IDLE, UPDATE, REQUEST_EVENT_BUFFER };
InternalState internalState = InternalState::IDLE;
@ -133,7 +164,10 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
// Communication cookie. Must be set by the supervisor Handler
CookieIF* comCookie = nullptr;
bool timestamping = true;
ReturnValue_t performUpdate();
ReturnValue_t performEventBufferRequest();
ReturnValue_t handlePacketTransmission(SpacePacket& packet);
ReturnValue_t sendCommand(SpacePacket& packet);
/**
@ -169,6 +203,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
* @return The size of the file
*/
uint32_t getFileSize(std::string filename);
ReturnValue_t handleEventBufferReception();
};
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */

View File

@ -8,6 +8,7 @@
#include "linux/devices/devicedefinitions/StarTrackerDefinitions.h"
#include "mission/utility/ProgressPrinter.h"
#include "mission/utility/Timestamp.h"
#include "mission/utility/Filenaming.h"
StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId) {}
@ -181,7 +182,8 @@ ReturnValue_t StrHelper::performImageDownload() {
struct DownloadActionRequest downloadReq;
uint32_t size = 0;
uint32_t retries = 0;
std::string image = makeFullFilename(downloadImage.path, downloadImage.filename);
std::string image = Filenaming::generateAbsoluteFilename(downloadImage.path,
downloadImage.filename, timestamping);
std::ofstream file(image, std::ios_base::out);
if (not std::filesystem::exists(image)) {
return FILE_CREATION_FAILED;
@ -400,7 +402,8 @@ ReturnValue_t StrHelper::performFlashRead() {
uint32_t size = 0;
uint32_t retries = 0;
Timestamp timestamp;
std::string fullname = makeFullFilename(flashRead.path, flashRead.filename);
std::string fullname =
Filenaming::generateAbsoluteFilename(flashRead.path, flashRead.filename, timestamping);
std::ofstream file(fullname, std::ios_base::app | std::ios_base::out);
if (not std::filesystem::exists(fullname)) {
return FILE_CREATION_FAILED;
@ -588,14 +591,3 @@ ReturnValue_t StrHelper::unlockAndEraseRegions(uint32_t from, uint32_t to) {
}
return result;
}
std::string StrHelper::makeFullFilename(std::string path, std::string filename) {
std::string image;
Timestamp timestamp;
if (timestamping) {
image = path + "/" + timestamp.str() + filename;
} else {
image = path + "/" + filename;
}
return image;
}

View File

@ -344,16 +344,6 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
*
*/
ReturnValue_t unlockAndEraseRegions(uint32_t from, uint32_t to);
/**
* @brief Creates full filename either with timestamp or without
*
* @param path Path where to create the file
* @param filename Name fo the file
*
* @return Full filename
*/
std::string makeFullFilename(std::string path, std::string filename);
};
#endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */

View File

@ -2,6 +2,7 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE
TmFunnel.cpp
Timestamp.cpp
ProgressPrinter.cpp
Filenaming.cpp
)

View File

@ -0,0 +1,17 @@
#include "Filenaming.h"
#include "Timestamp.h"
Filenaming::Filenaming() {
}
std::string FilesystemHelper::generateAbsoluteFilename(std::string path, std::string filename,
bool addTimestamp) {
std::string absoluteName;
Timestamp timestamp;
if (addTimestamp) {
absoluteName = path + "/" + timestamp.str() + filename;
} else {
absoluteName = path + "/" + filename;
}
return absoluteName;
}

View File

@ -0,0 +1,28 @@
#ifndef MISSION_UTILITY_FILENAMING_H_
#define MISSION_UTILITY_FILENAMING_H_
#include <string>
/**
* @brief Static functions related to file name creation
*/
class Filenaming {
public:
/**
* @brief Creates the absolute name of a file by merging the path name, the filename and adding
* an optional timestamp.
*
* @param path
* @param filename
* @param addTimestap Set to true if timestamp should be considered in name
*
* @return The absolute filename
*/
static std::string generateAbsoluteFilename(std::string path, std::string filename,
bool addTimestamp);
private:
Filenaming();
};
#endif /* MISSION_UTILITY_FILENAMING_H_ */