v1.17.0 #327

Merged
muellerr merged 131 commits from develop into main 2022-11-28 18:29:31 +01:00
5 changed files with 171 additions and 228 deletions
Showing only changes of commit e46bb42266 - Show all commits

View File

@ -33,6 +33,8 @@ typedef struct {
uint8_t tm_year; // years since 1900
} tas_time_t;
static constexpr uint16_t DEFAULT_SEQ_COUNT = 0;
/** Command IDs */
static const DeviceCommandId_t NONE = 0;
static const DeviceCommandId_t GET_HK_REPORT = 1;
@ -122,14 +124,16 @@ static const uint16_t APID_DATA_LOGGER_DATA = 0x20D;
// 2 bits APID SRC, 00 for OBC, 2 bits APID DEST, 01 for SUPV, 7 bits CMD ID -> Mask 0x080
static constexpr uint16_t APID_TC_SUPV_MASK = 0x080;
static constexpr uint16_t APID_TMTC_MAN = 0x00;
static constexpr uint16_t APID_HK = 0x01;
static constexpr uint16_t APID_BOOT_MAN = 0x02;
static constexpr uint16_t APID_LATCHUP_MON = 0x03;
static constexpr uint16_t APID_ADC_MON = 0x04;
static constexpr uint16_t APID_MEM_MAN = 0x05;
static constexpr uint16_t APID_DATA_LOGGER = 0x06;
static constexpr uint16_t APID_WDOG_MAN = 0x07;
enum Apids {
TMTC_MAN = 0x00,
HK = 0x01,
BOOT_MAN = 0x02,
LATCHUP_MON = 0x03,
ADC_MON = 0x04,
MEM_MAN = 0x05,
DATA_LOGGER = 0x06,
WDOG_MAN = 0x07
};
enum class HkServiceIds : uint8_t {
ENABLE = 0x01,
@ -170,7 +174,13 @@ enum class LatchupMonServiceIds : uint8_t {
// Right now, none of the commands seem to be implemented, but still
// keep the enum here in case some are added
enum class AdcMonServiceIds : uint8_t {};
enum class AdcMonServiceIds : uint8_t {
SET_SWEEP_PERIOD = 0x01,
SET_ENABLED_CHANNELS = 0x02,
SET_WINDOW_STRIDE = 0x03,
SET_ADC_THRESHOLD = 0x04,
COPY_ADC_DATA_TO_MRAM = 0x05
};
enum class DataLoggerServiceIds : uint8_t { FACTORY_RESET = 0x07 };
@ -178,49 +188,9 @@ enum class DataLoggerServiceIds : uint8_t { FACTORY_RESET = 0x07 };
// keep the enum here in case some are added
enum class WdogManServiceIds : uint8_t {};
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;
static const uint16_t APID_SET_BOOT_TIMEOUT = 0xA4;
static const uint16_t APID_SET_MAX_RESTART_TRIES = 0xA5;
static const uint16_t APID_RESET_MPSOC = 0xA6;
static const uint16_t APID_RESET_PL = 0xA7;
static const uint16_t APID_GET_BOOT_STATUS_RPT = 0xA8;
static const uint16_t APID_PREPARE_UPDATE = 0xA9;
static const uint16_t APID_START_MPSOC_QUIET = 0xAA;
static const uint16_t APID_SET_SHUTDOWN_TIMEOUT = 0xAB;
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_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_SET_ALERT_LIMIT = 0xD3;
static const uint16_t APID_SET_ADC_ENABLED_CHANNELS = 0xE1;
static const uint16_t APID_SET_ADC_WINDOW_AND_STRIDE = 0xE2;
static const uint16_t APID_SET_ADC_THRESHOLD = 0xE3;
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_REQUEST_ADC_REPORT = 0xDB;
static const uint16_t APID_ENABLE_NVMS = 0xF0;
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_GPIO = 0xF9;
static const uint16_t APID_READ_GPIO = 0xFA;
static const uint16_t APID_RESTART_SUPERVISOR = 0xFB;
static const uint16_t APID_FACTORY_RESET = 0xFC;
static const uint16_t APID_REQUEST_LOGGING_DATA = 0xFD;
static const uint16_t APID_GET_HK_REPORT = 0xC6;
static const uint16_t APID_MASK = 0x3FF;
static const uint16_t SEQUENCE_COUNT_MASK = 0xFFF;
static constexpr uint16_t DEFAULT_SEQUENCE_COUNT = 1;
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;
@ -369,29 +339,43 @@ struct TcParams : public ploc::SpTcParams {
class TcBase : public ploc::SpTcBase {
public:
TcBase(TcParams params) : ploc::SpTcBase(params) { setup(); }
TcBase(TcParams params) : TcBase(params, 0x00, 0x00, MIN_PAYLOAD_LEN) {}
TcBase(TcParams params, uint16_t apid, uint8_t serviceId, uint16_t seqCount)
: ploc::SpTcBase(params, apid, seqCount), serviceId(serviceId) {
if (setup() == OK and params.buf != nullptr) {
params.buf[supv::PAYLOAD_OFFSET] = serviceId;
TcBase(TcParams params, uint16_t apid) : TcBase(params, apid, 0x00, MIN_PAYLOAD_LEN) {}
TcBase(TcParams params, uint16_t apid, uint8_t service, size_t payloadLen)
: TcBase(params, apid, service, payloadLen, DEFAULT_SEQ_COUNT) {}
TcBase(TcParams params, uint16_t apid, uint8_t serviceId, size_t payloadLen, uint16_t seqCount)
: ploc::SpTcBase(params, apid, fullSpDataLenFromPayloadLen(payloadLen), seqCount) {
setup(serviceId);
}
void setServiceId(uint8_t id) {
if (spParams.maxSize < MIN_PAYLOAD_LEN) {
return;
}
payloadStart[supv::PAYLOAD_OFFSET] = id;
}
static size_t fullSpDataLenFromPayloadLen(size_t payloadLen) {
return SECONDARY_HEADER_LEN + payloadLen + CRC_LEN;
}
void setLenFromPayloadLen(size_t payloadLen) {
spParams.setFullPayloadLen(ccsds::HEADER_LEN + SECONDARY_HEADER_LEN + payloadLen + CRC_LEN);
spParams.setFullPayloadLen(fullSpDataLenFromPayloadLen(payloadLen));
updateLenFromParams();
}
private:
uint8_t serviceId = 0;
ReturnValue_t setup() {
ReturnValue_t setup(uint8_t serviceId) {
if (spParams.maxSize < MIN_PAYLOAD_LEN) {
sif::error << "SupvTcBase::SupvTcBase: Passed buffer is too small" << std::endl;
return returnvalue::FAILED;
}
std::memset(spParams.buf + ccsds::HEADER_LEN, 0, TIMESTAMP_LEN);
payloadStart = spParams.buf + SECONDARY_HEADER_LEN;
payloadStart = spParams.buf + ccsds::HEADER_LEN + SECONDARY_HEADER_LEN;
payloadStart[supv::PAYLOAD_OFFSET] = serviceId;
return returnvalue::OK;
}
};
@ -402,7 +386,8 @@ class NoPayloadPacket : public TcBase {
: NoPayloadPacket(params, apid, serviceId, 0) {}
NoPayloadPacket(TcParams params, uint16_t apid, uint8_t serviceId, uint16_t seqId)
: TcBase(params, apid, serviceId, seqId) {}
: TcBase(params, apid, serviceId, MIN_PAYLOAD_LEN, seqId) {}
ReturnValue_t buildPacket() {
ReturnValue_t result = checkSizeAndSerializeHeader();
if (result != OK) {
@ -433,11 +418,8 @@ class MPSoCBootSelect : public TcBase {
*
* @note Selection of partitions is currently not supported.
*/
MPSoCBootSelect(TcParams params) : TcBase(params) {
params.setLenFromPayloadLen(4);
spParams.creator.setApid(APID_SEL_MPSOC_BOOT_IMAGE);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
MPSoCBootSelect(TcParams params)
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::SELECT_IMAGE), 4) {}
ReturnValue_t buildPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) {
auto res = checkSizeAndSerializeHeader();
@ -449,16 +431,11 @@ class MPSoCBootSelect : public TcBase {
}
private:
static const uint8_t MEM_OFFSET = 0;
static const uint8_t BP0_OFFSET = 1;
static const uint8_t BP1_OFFSET = 2;
static const uint8_t BP2_OFFSET = 3;
void initPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) {
payloadStart[0] = mem;
std::memcpy(payloadStart + BP0_OFFSET, &bp0, sizeof(bp0));
std::memcpy(payloadStart + BP1_OFFSET, &bp1, sizeof(bp1));
std::memcpy(payloadStart + BP2_OFFSET, &bp2, sizeof(bp2));
payloadStart[1] = bp0;
payloadStart[2] = bp1;
payloadStart[3] = bp2;
}
};
@ -466,51 +443,49 @@ class MPSoCBootSelect : public TcBase {
* @brief This class creates the command to enable or disable the NVMs connected to the
* supervisor.
*/
class EnableNvms : public ploc::SpTcBase {
public:
/**
* @brief Constructor
*
* @param mem The memory to boot from: NVM0 (0), NVM1 (1)
* @param bp0 Partition pin 0
* @param bp1 Partition pin 1
* @param bp2 Partition pin 2
*/
EnableNvms(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_ENABLE_NVMS);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket(uint8_t nvm01, uint8_t nvm3) {
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
initPacket(nvm01, nvm3);
return calcAndSetCrc();
}
private:
static const uint8_t DATA_FIELD_LENGTH = 4;
static const uint8_t CRC_OFFSET = 2;
void initPacket(uint8_t nvm01, uint8_t nvm3) {
payloadStart[0] = nvm01;
payloadStart[1] = nvm3;
}
};
// class EnableNvms : public ploc::SpTcBase {
// public:
// /**
// * @brief Constructor
// *
// * @param mem The memory to boot from: NVM0 (0), NVM1 (1)
// * @param bp0 Partition pin 0
// * @param bp1 Partition pin 1
// * @param bp2 Partition pin 2
// */
// EnableNvms(ploc::SpTcParams params) : ploc::SpTcBase(params) {
// spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
// spParams.creator.setApid(APID_ENABLE_NVMS);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// }
//
// ReturnValue_t buildPacket(uint8_t nvm01, uint8_t nvm3) {
// auto res = checkSizeAndSerializeHeader();
// if (res != returnvalue::OK) {
// return res;
// }
// initPacket(nvm01, nvm3);
// return calcAndSetCrc();
// }
//
// private:
// static const uint8_t DATA_FIELD_LENGTH = 4;
// static const uint8_t CRC_OFFSET = 2;
//
// void initPacket(uint8_t nvm01, uint8_t nvm3) {
// payloadStart[0] = nvm01;
// payloadStart[1] = nvm3;
// }
// };
/**
* @brief This class generates the space packet to update the time of the PLOC supervisor.
*/
class SetTimeRef : public ploc::SpTcBase {
class SetTimeRef : public TcBase {
public:
SetTimeRef(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_TIME_REF);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
static constexpr size_t PAYLOAD_LEN = 8;
SetTimeRef(TcParams params)
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(TmtcServiceIds::TIME_REF), 8) {}
ReturnValue_t buildPacket(Clock::TimeOfDay_t* time) {
auto res = checkSizeAndSerializeHeader();
@ -525,8 +500,6 @@ class SetTimeRef : public ploc::SpTcBase {
}
private:
static const uint16_t DATA_FIELD_LENGTH = 10;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
static const uint16_t SYNC = 0x8000;
ReturnValue_t initPacket(Clock::TimeOfDay_t* time) {
@ -578,18 +551,17 @@ class SetTimeRef : public ploc::SpTcBase {
/**
* @brief This class can be used to generate the set boot timout command.
*/
class SetBootTimeout : public ploc::SpTcBase {
class SetBootTimeout : public TcBase {
public:
static constexpr size_t PAYLOAD_LEN = 4;
/**
* @brief Constructor
*
* @param timeout The boot timeout in milliseconds.
*/
SetBootTimeout(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_BOOT_TIMEOUT);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
SetBootTimeout(TcParams params)
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::SET_BOOT_TIMEOUT),
PAYLOAD_LEN) {}
ReturnValue_t buildPacket(uint32_t timeout) {
auto res = checkSizeAndSerializeHeader();
@ -601,9 +573,6 @@ class SetBootTimeout : public ploc::SpTcBase {
}
private:
/** boot timeout value (uint32_t) and crc (uint16_t) */
static const uint16_t DATA_FIELD_LENGTH = 6;
void initPacket(uint32_t timeout) {
size_t serializedSize = 0;
uint8_t* dataFieldPtr = payloadStart;
@ -615,18 +584,16 @@ class SetBootTimeout : public ploc::SpTcBase {
/**
* @brief This class can be used to generate the space packet to set the maximum boot tries.
*/
class SetRestartTries : public ploc::SpTcBase {
class SetRestartTries : public TcBase {
public:
/**
* @brief Constructor
*
* @param restartTries Maximum restart tries to set.
*/
SetRestartTries(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_MAX_RESTART_TRIES);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
SetRestartTries(TcParams params)
: TcBase(params, Apids::BOOT_MAN,
static_cast<uint8_t>(BootManServiceIds::SET_MAX_REBOOT_TRIES), 1) {}
ReturnValue_t buildPacket(uint8_t restartTries) {
auto res = checkSizeAndSerializeHeader();
@ -640,9 +607,6 @@ class SetRestartTries : public ploc::SpTcBase {
private:
uint8_t restartTries = 0;
/** Restart tries value (uint8_t) and crc (uint16_t) */
static const uint16_t DATA_FIELD_LENGTH = 3;
void initPacket(uint8_t restartTries) { payloadStart[0] = restartTries; }
};
@ -651,16 +615,13 @@ class SetRestartTries : public ploc::SpTcBase {
* of housekeeping data. Normally, this will be disabled by default. However, adding this
* command can be useful for debugging.
*/
class DisablePeriodicHkTransmission : public ploc::SpTcBase {
class DisablePeriodicHkTransmission : public TcBase {
public:
/**
* @brief Constructor
*/
DisablePeriodicHkTransmission(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_DISABLE_HK);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
DisablePeriodicHkTransmission(TcParams params)
: TcBase(params, Apids::HK, static_cast<uint8_t>(HkServiceIds::ENABLE), 1) {}
ReturnValue_t buildPacket() {
auto res = checkSizeAndSerializeHeader();
@ -672,9 +633,6 @@ class DisablePeriodicHkTransmission : public ploc::SpTcBase {
}
private:
/** Restart tries value (uint8_t) and crc (uint16_t) */
static const uint16_t DATA_FIELD_LENGTH = 3;
void initPacket() { payloadStart[0] = false; }
};
@ -683,7 +641,7 @@ class DisablePeriodicHkTransmission : public ploc::SpTcBase {
*
* @details There are 7 different latchup alerts.
*/
class LatchupAlert : public ploc::SpTcBase {
class LatchupAlert : public TcBase {
public:
/**
* @brief Constructor
@ -692,16 +650,13 @@ class LatchupAlert : public ploc::SpTcBase {
* @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC,
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
*/
LatchupAlert(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
LatchupAlert(TcParams params) : TcBase(params, Apids::LATCHUP_MON) { setLenFromPayloadLen(1); }
ReturnValue_t buildPacket(bool state, uint8_t latchupId) {
if (state) {
spParams.creator.setApid(APID_ENABLE_LATCHUP_ALERT);
setServiceId(static_cast<uint8_t>(LatchupMonServiceIds::ENABLE));
} else {
spParams.creator.setApid(APID_DISABLE_LATCHUP_ALERT);
setServiceId(static_cast<uint8_t>(LatchupMonServiceIds::DISABLE));
}
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
@ -712,16 +667,12 @@ class LatchupAlert : public ploc::SpTcBase {
}
private:
static const uint16_t DATA_FIELD_LENGTH = 3;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t latchupId = 0;
void initPacket(uint8_t latchupId) { payloadStart[0] = latchupId; }
};
class SetAlertlimit : public ploc::SpTcBase {
class SetAlertlimit : public TcBase {
public:
/**
* @brief Constructor
@ -730,11 +681,9 @@ class SetAlertlimit : public ploc::SpTcBase {
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
* @param dutycycle
*/
SetAlertlimit(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ALERT_LIMIT);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
SetAlertlimit(TcParams params)
: TcBase(params, Apids::LATCHUP_MON,
static_cast<uint8_t>(LatchupMonServiceIds::SET_ALERT_LIMIT), 5) {}
ReturnValue_t buildPacket(uint8_t latchupId, uint32_t dutycycle) {
auto res = checkSizeAndSerializeHeader();
@ -749,9 +698,6 @@ class SetAlertlimit : public ploc::SpTcBase {
}
private:
static const uint16_t DATA_FIELD_LENGTH = 7;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
uint8_t latchupId = 0;
uint32_t dutycycle = 0;
@ -766,18 +712,16 @@ class SetAlertlimit : public ploc::SpTcBase {
/**
* @brief This class packages the space packet to enable or disable ADC channels.
*/
class SetAdcEnabledChannels : public ploc::SpTcBase {
class SetAdcEnabledChannels : public TcBase {
public:
/**
* @brief Constructor
*
* @param ch Defines channels to be enabled or disabled.
*/
SetAdcEnabledChannels(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ADC_ENABLED_CHANNELS);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
SetAdcEnabledChannels(TcParams params)
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(AdcMonServiceIds::SET_ENABLED_CHANNELS),
2) {}
ReturnValue_t buildPacket(uint16_t ch) {
auto res = checkSizeAndSerializeHeader();
@ -789,10 +733,6 @@ class SetAdcEnabledChannels : public ploc::SpTcBase {
}
private:
static const uint16_t DATA_FIELD_LENGTH = 4;
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
void initPacket(uint16_t ch) {
size_t serializedSize = 0;
SerializeAdapter::serialize(&ch, &payloadStart, &serializedSize, sizeof(ch),
@ -814,8 +754,8 @@ class SetAdcWindowAndStride : public ploc::SpTcBase {
*/
SetAdcWindowAndStride(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ADC_WINDOW_AND_STRIDE);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// spParams.creator.setApid(APID_SET_ADC_WINDOW_AND_STRIDE);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket(uint16_t windowSize, uint16_t stridingStepSize) {
@ -854,7 +794,7 @@ class SetAdcThreshold : public ploc::SpTcBase {
*/
SetAdcThreshold(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ADC_THRESHOLD);
// spParams.creator.setApid(APID_SET_ADC_THRESHOLD);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
@ -892,7 +832,7 @@ class RunAutoEmTests : public ploc::SpTcBase {
*/
RunAutoEmTests(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_RUN_AUTO_EM_TESTS);
// spParams.creator.setApid(APID_RUN_AUTO_EM_TESTS);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
@ -934,14 +874,14 @@ class MramCmd : public ploc::SpTcBase {
*/
MramCmd(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket(uint32_t start, uint32_t stop, MramAction action) {
if (action == MramAction::WIPE) {
spParams.creator.setApid(APID_WIPE_MRAM);
// spParams.creator.setApid(APID_WIPE_MRAM);
} else if (action == MramAction::DUMP) {
spParams.creator.setApid(APID_DUMP_MRAM);
// spParams.creator.setApid(APID_DUMP_MRAM);
} else {
sif::debug << "WipeMram: Invalid action specified";
}
@ -988,7 +928,7 @@ class SetGpio : public ploc::SpTcBase {
*/
SetGpio(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_GPIO);
// spParams.creator.setApid(APID_SET_GPIO);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
@ -1032,7 +972,7 @@ class ReadGpio : public ploc::SpTcBase {
*/
ReadGpio(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_READ_GPIO);
// spParams.creator.setApid(APID_READ_GPIO);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
@ -1078,7 +1018,7 @@ class FactoryReset : public ploc::SpTcBase {
* @param op
*/
FactoryReset(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.creator.setApid(APID_FACTORY_RESET);
// spParams.creator.setApid(APID_FACTORY_RESET);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
@ -1116,8 +1056,8 @@ class SetShutdownTimeout : public ploc::SpTcBase {
public:
SetShutdownTimeout(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(PAYLOAD_LEN + 2);
spParams.creator.setApid(APID_SET_SHUTDOWN_TIMEOUT);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// spParams.creator.setApid(APID_SET_SHUTDOWN_TIMEOUT);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket(uint32_t timeout) {
@ -1155,8 +1095,8 @@ class CheckMemory : public ploc::SpTcBase {
*/
CheckMemory(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
spParams.creator.setApid(APID_CHECK_MEMORY);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// spParams.creator.setApid(APID_CHECK_MEMORY);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
@ -1202,8 +1142,8 @@ class WriteMemory : public ploc::SpTcBase {
* @param updateData Pointer to buffer containing update data
*/
WriteMemory(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.creator.setApid(APID_WRITE_MEMORY);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// spParams.creator.setApid(APID_WRITE_MEMORY);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket(ccsds::SequenceFlags seqFlags, uint16_t sequenceCount, uint8_t memoryId,
@ -1268,8 +1208,8 @@ class EraseMemory : public ploc::SpTcBase {
public:
EraseMemory(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
spParams.creator.setApid(APID_ERASE_MEMORY);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// spParams.creator.setApid(APID_ERASE_MEMORY);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
@ -1310,8 +1250,8 @@ class EnableAutoTm : public ploc::SpTcBase {
public:
EnableAutoTm(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
spParams.creator.setApid(APID_AUTO_TM);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// spParams.creator.setApid(APID_AUTO_TM);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket() {
@ -1335,8 +1275,8 @@ class DisableAutoTm : public ploc::SpTcBase {
public:
DisableAutoTm(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
spParams.creator.setApid(APID_AUTO_TM);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// spParams.creator.setApid(APID_AUTO_TM);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket() {
@ -1370,8 +1310,8 @@ class RequestLoggingData : public ploc::SpTcBase {
RequestLoggingData(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
spParams.creator.setApid(APID_REQUEST_LOGGING_DATA);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// spParams.creator.setApid(APID_REQUEST_LOGGING_DATA);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
/**

View File

@ -221,17 +221,17 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
spParams.buf = commandBuffer;
switch (deviceCommand) {
case GET_HK_REPORT: {
prepareEmptyCmd(APID_HK, static_cast<uint8_t>(HkServiceIds::GET_REPORT));
prepareEmptyCmd(Apids::HK, static_cast<uint8_t>(HkServiceIds::GET_REPORT));
result = returnvalue::OK;
break;
}
case START_MPSOC: {
prepareEmptyCmd(APID_BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::START_MPSOC));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::START_MPSOC));
result = returnvalue::OK;
break;
}
case SHUTDOWN_MPSOC: {
prepareEmptyCmd(APID_BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::SHUTDOWN_MPSOC));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::SHUTDOWN_MPSOC));
result = returnvalue::OK;
break;
}
@ -241,7 +241,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case RESET_MPSOC: {
prepareEmptyCmd(APID_BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::RESET_MPSOC));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::RESET_MPSOC));
result = returnvalue::OK;
break;
}
@ -265,7 +265,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case GET_BOOT_STATUS_REPORT: {
prepareEmptyCmd(APID_BOOT_MAN,
prepareEmptyCmd(Apids::BOOT_MAN,
static_cast<uint8_t>(BootManServiceIds::GET_BOOT_STATUS_REPORT));
result = returnvalue::OK;
break;
@ -298,7 +298,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case GET_LATCHUP_STATUS_REPORT: {
prepareEmptyCmd(APID_LATCHUP_MON,
prepareEmptyCmd(Apids::LATCHUP_MON,
static_cast<uint8_t>(LatchupMonServiceIds::GET_STATUS_REPORT));
result = returnvalue::OK;
break;
@ -380,7 +380,7 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case FACTORY_FLASH: {
prepareEmptyCmd(APID_BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::FACTORY_FLASH));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::FACTORY_FLASH));
result = returnvalue::OK;
break;
}
@ -434,14 +434,14 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case RESET_PL: {
prepareEmptyCmd(APID_BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::RESET_PL));
prepareEmptyCmd(Apids::BOOT_MAN, static_cast<uint8_t>(BootManServiceIds::RESET_PL));
result = returnvalue::OK;
break;
}
case ENABLE_NVMS: {
result = prepareEnableNvmsCommand(commandData);
break;
}
// case ENABLE_NVMS: {
// result = prepareEnableNvmsCommand(commandData);
// break;
// }
default:
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
<< std::endl;
@ -1701,18 +1701,18 @@ ReturnValue_t PlocSupervisorHandler::prepareLoggingRequest(const uint8_t* comman
return returnvalue::OK;
}
ReturnValue_t PlocSupervisorHandler::prepareEnableNvmsCommand(const uint8_t* commandData) {
using namespace supv;
uint8_t nvm01 = *(commandData);
uint8_t nvm3 = *(commandData + 1);
EnableNvms packet(spParams);
ReturnValue_t result = packet.buildPacket(nvm01, nvm3);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(packet.getFullPacketLen());
return returnvalue::OK;
}
// ReturnValue_t PlocSupervisorHandler::prepareEnableNvmsCommand(const uint8_t* commandData) {
// using namespace supv;
// uint8_t nvm01 = *(commandData);
// uint8_t nvm3 = *(commandData + 1);
// EnableNvms packet(spParams);
// ReturnValue_t result = packet.buildPacket(nvm01, nvm3);
// if (result != returnvalue::OK) {
// return result;
// }
// finishTcPrep(packet.getFullPacketLen());
// return returnvalue::OK;
// }
void PlocSupervisorHandler::disableAllReplies() {
using namespace supv;

View File

@ -283,7 +283,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
ReturnValue_t prepareSetGpioCmd(const uint8_t* commandData);
ReturnValue_t prepareReadGpioCmd(const uint8_t* commandData);
ReturnValue_t prepareLoggingRequest(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareEnableNvmsCommand(const uint8_t* commandData);
// ReturnValue_t prepareEnableNvmsCommand(const uint8_t* commandData);
/**
* @brief Copies the content of a space packet to the command buffer.

View File

@ -499,7 +499,7 @@ ReturnValue_t PlocSupvHelper::selectMemory() {
ReturnValue_t PlocSupvHelper::prepareUpdate() {
ReturnValue_t result = returnvalue::OK;
resetSpParams();
supv::NoPayloadPacket packet(spParams, supv::APID_BOOT_MAN,
supv::NoPayloadPacket packet(spParams, Apids::BOOT_MAN,
static_cast<uint8_t>(BootManServiceIds::PREPARE_UPDATE));
result = packet.buildPacket();
if (result != returnvalue::OK) {

View File

@ -24,23 +24,26 @@ struct SpTcParams {
class SpTcBase {
public:
SpTcBase(SpTcParams params) : spParams(params) {
payloadStart = spParams.buf + ccsds::HEADER_LEN;
updateSpFields();
}
SpTcBase(SpTcParams params) : SpTcBase(params, 0x00, 1, 0) {}
SpTcBase(SpTcParams params, uint16_t apid, uint16_t seqCount) : spParams(params) {
SpTcBase(SpTcParams params, uint16_t apid, size_t payloadLen)
: SpTcBase(params, apid, payloadLen, 0) {}
SpTcBase(SpTcParams params, uint16_t apid, size_t payloadLen, uint16_t seqCount)
: spParams(params) {
spParams.creator.setApid(apid);
spParams.creator.setSeqCount(seqCount);
payloadStart = spParams.buf + ccsds::HEADER_LEN;
spParams.fullPayloadLen = payloadLen;
updateSpFields();
}
void updateSpFields() {
spParams.creator.setDataLenField(spParams.fullPayloadLen - 1);
updateLenFromParams();
spParams.creator.setPacketType(ccsds::PacketType::TC);
}
void updateLenFromParams() { spParams.creator.setDataLenField(spParams.fullPayloadLen - 1); }
const uint8_t* getFullPacket() const { return spParams.buf; }
size_t getFullPacketLen() const { return spParams.creator.getFullPacketLen(); }