continue refactoring
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
2022-11-08 14:26:52 +01:00
parent cfe7599f62
commit 9d02322cd7
4 changed files with 347 additions and 318 deletions

View File

@ -142,20 +142,20 @@ static const uint16_t SIZE_ADC_REPORT = 72;
/**
* SpacePacket apids of telemetry packets
*/
static const uint16_t APID_ACK_SUCCESS = 0x200;
static const uint16_t APID_ACK_FAILURE = 0x201;
static const uint16_t APID_EXE_SUCCESS = 0x202;
static const uint16_t APID_EXE_FAILURE = 0x203;
static const uint16_t APID_HK_REPORT = 0x204;
static const uint16_t APID_BOOT_STATUS_REPORT = 0x205;
static const uint16_t APID_UPDATE_STATUS_REPORT = 0x206;
static const uint16_t APID_ADC_REPORT = 0x207;
static const uint16_t APID_LATCHUP_STATUS_REPORT = 0x208;
static const uint16_t APID_SOC_SYSMON = 0x209;
static const uint16_t APID_MRAM_DUMP_TM = 0x20A;
static const uint16_t APID_SRAM = 0x20B;
static const uint16_t APID_NOR_DATA = 0x20C;
static const uint16_t APID_DATA_LOGGER_DATA = 0x20D;
// static const uint16_t APID_ACK_SUCCESS = 0x200;
// static const uint16_t APID_ACK_FAILURE = 0x201;
// static const uint16_t APID_EXE_SUCCESS = 0x202;
// static const uint16_t APID_EXE_FAILURE = 0x203;
// static const uint16_t APID_HK_REPORT = 0x204;
// static const uint16_t APID_BOOT_STATUS_REPORT = 0x205;
// static const uint16_t APID_UPDATE_STATUS_REPORT = 0x206;
// static const uint16_t APID_ADC_REPORT = 0x207;
// static const uint16_t APID_LATCHUP_STATUS_REPORT = 0x208;
// static const uint16_t APID_SOC_SYSMON = 0x209;
// static const uint16_t APID_MRAM_DUMP_TM = 0x20A;
// static const uint16_t APID_SRAM = 0x20B;
// static const uint16_t APID_NOR_DATA = 0x20C;
// static const uint16_t APID_DATA_LOGGER_DATA = 0x20D;
/**
* APIDs of telecommand packets
@ -163,7 +163,7 @@ 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;
enum Apids {
enum Apid {
TMTC_MAN = 0x00,
HK = 0x01,
BOOT_MAN = 0x02,
@ -445,6 +445,8 @@ class TcBase : public ploc::SpTcBase {
class TmBase : public ploc::SpTmReader {
public:
TmBase() = default;
TmBase(const uint8_t* data, size_t maxSize) : ploc::SpTmReader(data, maxSize) {
if (maxSize < MIN_TMTC_LEN) {
sif::error << "SupvTcBase::SupvTcBase: Passed buffer is too small" << std::endl;
@ -507,7 +509,7 @@ class MPSoCBootSelect : public TcBase {
* @note Selection of partitions is currently not supported.
*/
MPSoCBootSelect(TcParams params)
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SELECT_IMAGE), 4) {}
: TcBase(params, Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::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();
@ -534,7 +536,7 @@ class SetTimeRef : public TcBase {
public:
static constexpr size_t PAYLOAD_LEN = 8;
SetTimeRef(TcParams params)
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::TIME_REF), 8) {}
: TcBase(params, Apid::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::TIME_REF), 8) {}
ReturnValue_t buildPacket(Clock::TimeOfDay_t* time) {
auto res = checkSizeAndSerializeHeader();
@ -609,7 +611,7 @@ class SetBootTimeout : public TcBase {
* @param timeout The boot timeout in milliseconds.
*/
SetBootTimeout(TcParams params)
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SET_BOOT_TIMEOUT),
: TcBase(params, Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SET_BOOT_TIMEOUT),
PAYLOAD_LEN) {}
ReturnValue_t buildPacket(uint32_t timeout) {
@ -641,7 +643,7 @@ class SetRestartTries : public TcBase {
* @param restartTries Maximum restart tries to set.
*/
SetRestartTries(TcParams params)
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SET_MAX_REBOOT_TRIES),
: TcBase(params, Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SET_MAX_REBOOT_TRIES),
1) {}
ReturnValue_t buildPacket(uint8_t restartTries) {
@ -670,7 +672,7 @@ class DisablePeriodicHkTransmission : public TcBase {
* @brief Constructor
*/
DisablePeriodicHkTransmission(TcParams params)
: TcBase(params, Apids::HK, static_cast<uint8_t>(tc::HkId::ENABLE), 1) {}
: TcBase(params, Apid::HK, static_cast<uint8_t>(tc::HkId::ENABLE), 1) {}
ReturnValue_t buildPacket() {
auto res = checkSizeAndSerializeHeader();
@ -699,7 +701,7 @@ class LatchupAlert : public TcBase {
* @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(TcParams params) : TcBase(params, Apids::LATCHUP_MON) { setLenFromPayloadLen(1); }
LatchupAlert(TcParams params) : TcBase(params, Apid::LATCHUP_MON) { setLenFromPayloadLen(1); }
ReturnValue_t buildPacket(bool state, uint8_t latchupId) {
if (state) {
@ -731,7 +733,7 @@ class SetAlertlimit : public TcBase {
* @param dutycycle
*/
SetAlertlimit(TcParams params)
: TcBase(params, Apids::LATCHUP_MON, static_cast<uint8_t>(tc::LatchupMonId::SET_ALERT_LIMIT),
: TcBase(params, Apid::LATCHUP_MON, static_cast<uint8_t>(tc::LatchupMonId::SET_ALERT_LIMIT),
5) {}
ReturnValue_t buildPacket(uint8_t latchupId, uint32_t dutycycle) {
@ -771,7 +773,7 @@ class SetAdcWindowAndStride : public TcBase {
* @param stridingStepSize
*/
SetAdcWindowAndStride(TcParams params)
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_WINDOW_STRIDE), 4) {}
: TcBase(params, Apid::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_WINDOW_STRIDE), 4) {}
ReturnValue_t buildPacket(uint16_t windowSize, uint16_t stridingStepSize) {
auto res = checkSizeAndSerializeHeader();
@ -804,7 +806,7 @@ class SetAdcThreshold : public TcBase {
* @param threshold
*/
SetAdcThreshold(TcParams params)
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_ADC_THRESHOLD), 4) {}
: TcBase(params, Apid::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_ADC_THRESHOLD), 4) {}
ReturnValue_t buildPacket(uint32_t threshold) {
auto res = checkSizeAndSerializeHeader();
@ -834,7 +836,7 @@ class RunAutoEmTests : public TcBase {
* @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3)
*/
RunAutoEmTests(TcParams params)
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::RUN_AUTO_EM_TEST), 1) {}
: TcBase(params, Apid::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::RUN_AUTO_EM_TEST), 1) {}
ReturnValue_t buildPacket(uint8_t test) {
auto res = checkSizeAndSerializeHeader();
@ -865,7 +867,7 @@ class SetGpio : public TcBase {
* @param val
*/
SetGpio(TcParams params)
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::SET_GPIO), 3) {}
: TcBase(params, Apid::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::SET_GPIO), 3) {}
ReturnValue_t buildPacket(uint8_t port, uint8_t pin, uint8_t val) {
auto res = checkSizeAndSerializeHeader();
@ -901,7 +903,7 @@ class ReadGpio : public TcBase {
* @param pin
*/
ReadGpio(TcParams params)
: TcBase(params, Apids::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::READ_GPIO), 2) {}
: TcBase(params, Apid::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::READ_GPIO), 2) {}
ReturnValue_t buildPacket(uint8_t port, uint8_t pin) {
auto res = checkSizeAndSerializeHeader();
@ -925,7 +927,7 @@ class ReadGpio : public TcBase {
class SetShutdownTimeout : public TcBase {
public:
SetShutdownTimeout(TcParams params)
: TcBase(params, Apids::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_TIMEOUT), 4) {}
: TcBase(params, Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_TIMEOUT), 4) {}
ReturnValue_t buildPacket(uint32_t timeout) {
auto res = checkSizeAndSerializeHeader();
@ -957,7 +959,7 @@ class CheckMemory : public TcBase {
* @param length Length in bytes of memory region
*/
CheckMemory(TcParams params)
: TcBase(params, Apids::MEM_MAN, static_cast<uint8_t>(tc::MemManId::CHECK), 10) {}
: TcBase(params, Apid::MEM_MAN, static_cast<uint8_t>(tc::MemManId::CHECK), 10) {}
ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
auto res = checkSizeAndSerializeHeader();
@ -997,7 +999,7 @@ class WriteMemory : public TcBase {
* @param updateData Pointer to buffer containing update data
*/
WriteMemory(TcParams params)
: TcBase(params, Apids::MEM_MAN, static_cast<uint8_t>(tc::MemManId::WRITE), 1) {}
: TcBase(params, Apid::MEM_MAN, static_cast<uint8_t>(tc::MemManId::WRITE), 1) {}
ReturnValue_t buildPacket(ccsds::SequenceFlags seqFlags, uint16_t sequenceCount, uint8_t memoryId,
uint32_t startAddress, uint16_t length, uint8_t* updateData) {
@ -1060,7 +1062,7 @@ class WriteMemory : public TcBase {
class EraseMemory : public TcBase {
public:
EraseMemory(TcParams params)
: TcBase(params, Apids::MEM_MAN, static_cast<uint8_t>(tc::MemManId::ERASE), PAYLOAD_LENGTH) {}
: TcBase(params, Apid::MEM_MAN, static_cast<uint8_t>(tc::MemManId::ERASE), PAYLOAD_LENGTH) {}
ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
auto res = checkSizeAndSerializeHeader();
@ -1100,7 +1102,7 @@ class VerificationReport {
if (not readerBase.crcIsOk()) {
return result::CRC_FAILURE;
}
if (readerBase.getApid() != Apids::TMTC_MAN) {
if (readerBase.getApid() != Apid::TMTC_MAN) {
return result::INVALID_APID;
}
if (readerBase.getBufSize() < MIN_PAYLOAD_LEN + 8) {
@ -1823,7 +1825,7 @@ class FactoryReset : public TcBase {
*
* @param op
*/
FactoryReset(TcParams params) : TcBase(params, Apids::TMTC_MAN, 0x11, 1) {}
FactoryReset(TcParams params) : TcBase(params, Apid::TMTC_MAN, 0x11, 1) {}
ReturnValue_t buildPacket(Op op) {
auto res = checkSizeAndSerializeHeader();
@ -1867,7 +1869,7 @@ class EnableNvms : public TcBase {
* @param bp1 Partition pin 1
* @param bp2 Partition pin 2
*/
EnableNvms(TcParams params) : TcBase(params, Apids::TMTC_MAN, 0x06, 2) {}
EnableNvms(TcParams params) : TcBase(params, Apid::TMTC_MAN, 0x06, 2) {}
ReturnValue_t buildPacket(uint8_t nvm01, uint8_t nvm3) {
auto res = checkSizeAndSerializeHeader();
@ -1901,7 +1903,7 @@ class MramCmd : public TcBase {
*
* @note The content at the stop address is excluded from the dump or wipe operation.
*/
MramCmd(TcParams params) : TcBase(params, Apids::DATA_LOGGER) { setLenFromPayloadLen(6); }
MramCmd(TcParams params) : TcBase(params, Apid::DATA_LOGGER) { setLenFromPayloadLen(6); }
ReturnValue_t buildPacket(uint32_t start, uint32_t stop, MramAction action) {
if (action == MramAction::WIPE) {
@ -1996,8 +1998,8 @@ class SetAdcEnabledChannels : public TcBase {
* @param ch Defines channels to be enabled or disabled.
*/
SetAdcEnabledChannels(TcParams params)
: TcBase(params, Apids::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_ENABLED_CHANNELS),
2) {}
: TcBase(params, Apid::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_ENABLED_CHANNELS), 2) {
}
ReturnValue_t buildPacket(uint16_t ch) {
auto res = checkSizeAndSerializeHeader();