add factory reset cmd
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-11-08 20:37:57 +01:00
parent 52f15906d8
commit d3da5bd2d8
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 73 additions and 36 deletions

View File

@ -102,10 +102,8 @@ static const DeviceCommandId_t FIRST_MRAM_DUMP = 30;
static const DeviceCommandId_t SET_GPIO = 34; static const DeviceCommandId_t SET_GPIO = 34;
static const DeviceCommandId_t READ_GPIO = 35; static const DeviceCommandId_t READ_GPIO = 35;
static const DeviceCommandId_t RESTART_SUPERVISOR = 36; static const DeviceCommandId_t RESTART_SUPERVISOR = 36;
static const DeviceCommandId_t FACTORY_RESET_CLEAR_ALL = 37;
static const DeviceCommandId_t LOGGING_REQUEST_COUNTERS = 38; static const DeviceCommandId_t LOGGING_REQUEST_COUNTERS = 38;
static const DeviceCommandId_t FACTORY_RESET_CLEAR_MIRROR = 40; static constexpr DeviceCommandId_t FACTORY_RESET = 39;
static const DeviceCommandId_t FACTORY_RESET_CLEAR_CIRCULAR = 41;
static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 43; static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 43;
static const DeviceCommandId_t START_MPSOC_QUIET = 45; static const DeviceCommandId_t START_MPSOC_QUIET = 45;
static const DeviceCommandId_t SET_SHUTDOWN_TIMEOUT = 46; static const DeviceCommandId_t SET_SHUTDOWN_TIMEOUT = 46;
@ -144,27 +142,6 @@ static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 31;
static const uint16_t SIZE_LOGGING_REPORT = 73; static const uint16_t SIZE_LOGGING_REPORT = 73;
static const uint16_t SIZE_ADC_REPORT = 72; 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;
/**
* APIDs of telecommand packets
*/
// 2 bits APID SRC, 00 for OBC, 2 bits APID DEST, 01 for SUPV, 7 bits CMD ID -> Mask 0x080 // 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_TC_SUPV_MASK = 0x080;
@ -292,6 +269,21 @@ static constexpr size_t MIN_PAYLOAD_LEN = SECONDARY_HEADER_LEN + CRC_LEN;
static constexpr size_t MIN_TMTC_LEN = ccsds::HEADER_LEN + MIN_PAYLOAD_LEN; static constexpr size_t MIN_TMTC_LEN = ccsds::HEADER_LEN + MIN_PAYLOAD_LEN;
static constexpr size_t PAYLOAD_OFFSET = ccsds::HEADER_LEN + SECONDARY_HEADER_LEN; static constexpr size_t PAYLOAD_OFFSET = ccsds::HEADER_LEN + SECONDARY_HEADER_LEN;
enum class FactoryResetSelect : uint8_t {
EVENT_BUF = 0x00,
ADC_BUF = 0x01,
SYS_CFG = 0x02,
DEBUG_CFG = 0x03,
BOOT_MAN_CFG = 0x04,
DATA_LOGGER_CFG = 0x05,
DATA_LOGGER_OP_DATA = 0x06,
LATCHUP_MON_CFG = 0x07,
ADC_MON_CFG = 0x08,
WDOG_MAN_CFG = 0x09,
HK_CFG = 0x0A,
MEM_MAN_CFG = 0xB9
};
struct UpdateParams { struct UpdateParams {
std::string file; std::string file;
uint8_t memId; uint8_t memId;
@ -646,6 +638,29 @@ class SetBootTimeout : public TcBase {
} }
}; };
class FactoryReset : public TcBase {
public:
FactoryReset(TcParams params)
: TcBase(params, Apid::DATA_LOGGER,
static_cast<uint8_t>(tc::DataLoggerServiceId::FACTORY_RESET), 0) {}
ReturnValue_t buildPacket(std::optional<uint8_t> op) {
if (op) {
setLenFromPayloadLen(1);
}
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
if (op) {
payloadStart[0] = op.value();
}
return calcAndSetCrc();
}
private:
};
/** /**
* @brief This class can be used to generate the space packet to set the maximum boot tries. * @brief This class can be used to generate the space packet to set the maximum boot tries.
*/ */

View File

@ -310,6 +310,10 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
result = returnvalue::OK; result = returnvalue::OK;
break; break;
} }
case FACTORY_RESET: {
result = prepareFactoryResetCmd(commandData, commandDataLen);
break;
}
case READ_GPIO: { case READ_GPIO: {
prepareReadGpioCmd(commandData); prepareReadGpioCmd(commandData);
result = returnvalue::OK; result = returnvalue::OK;
@ -449,13 +453,13 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
insertInCommandMap(RUN_AUTO_EM_TESTS); insertInCommandMap(RUN_AUTO_EM_TESTS);
insertInCommandMap(SET_GPIO); insertInCommandMap(SET_GPIO);
insertInCommandMap(READ_GPIO); insertInCommandMap(READ_GPIO);
insertInCommandMap(FACTORY_RESET);
insertInCommandMap(SET_SHUTDOWN_TIMEOUT); insertInCommandMap(SET_SHUTDOWN_TIMEOUT);
insertInCommandMap(FACTORY_FLASH); insertInCommandMap(FACTORY_FLASH);
insertInCommandMap(RESET_PL); insertInCommandMap(RESET_PL);
// ACK replies, use countdown for them // ACK replies, use countdown for them
insertInReplyMap(ACK_REPORT, 0, nullptr, SIZE_ACK_REPORT, false, insertInReplyMap(ACK_REPORT, 0, nullptr, SIZE_ACK_REPORT, false, &acknowledgementReportTimeout);
&acknowledgementReportTimeout);
insertInReplyMap(EXE_REPORT, 0, nullptr, SIZE_EXE_REPORT, false, &executionReportTimeout); insertInReplyMap(EXE_REPORT, 0, nullptr, SIZE_EXE_REPORT, false, &executionReportTimeout);
// TM replies // TM replies
@ -556,25 +560,26 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
case SET_ADC_ENABLED_CHANNELS: case SET_ADC_ENABLED_CHANNELS:
case SET_ADC_WINDOW_AND_STRIDE: case SET_ADC_WINDOW_AND_STRIDE:
case SET_ADC_THRESHOLD: case SET_ADC_THRESHOLD:
//case COPY_ADC_DATA_TO_MRAM: // case COPY_ADC_DATA_TO_MRAM:
case RUN_AUTO_EM_TESTS: case RUN_AUTO_EM_TESTS:
//case WIPE_MRAM: // case WIPE_MRAM:
case SET_GPIO: case SET_GPIO:
case FACTORY_RESET:
case READ_GPIO: case READ_GPIO:
//case RESTART_SUPERVISOR: // case RESTART_SUPERVISOR:
//case FACTORY_RESET_CLEAR_ALL: // case FACTORY_RESET_CLEAR_ALL:
//case FACTORY_RESET_CLEAR_MIRROR: // case FACTORY_RESET_CLEAR_MIRROR:
//case FACTORY_RESET_CLEAR_CIRCULAR: // case FACTORY_RESET_CLEAR_CIRCULAR:
case DISABLE_PERIOIC_HK_TRANSMISSION: case DISABLE_PERIOIC_HK_TRANSMISSION:
//case START_MPSOC_QUIET: // case START_MPSOC_QUIET:
case SET_SHUTDOWN_TIMEOUT: case SET_SHUTDOWN_TIMEOUT:
case FACTORY_FLASH: case FACTORY_FLASH:
case ENABLE_AUTO_TM: case ENABLE_AUTO_TM:
case DISABLE_AUTO_TM: case DISABLE_AUTO_TM:
//case LOGGING_CLEAR_COUNTERS: // case LOGGING_CLEAR_COUNTERS:
//case LOGGING_SET_TOPIC: // case LOGGING_SET_TOPIC:
case RESET_PL: case RESET_PL:
//case ENABLE_NVMS: // case ENABLE_NVMS:
enabledReplies = 2; enabledReplies = 2;
break; break;
default: default:
@ -1565,6 +1570,21 @@ ReturnValue_t PlocSupervisorHandler::prepareReadGpioCmd(const uint8_t* commandDa
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PlocSupervisorHandler::prepareFactoryResetCmd(const uint8_t* commandData,
size_t len) {
FactoryReset resetCmd(spParams);
std::optional<uint8_t> op;
if (len > 0) {
op = commandData[0];
}
ReturnValue_t result = resetCmd.buildPacket(op);
if (result != returnvalue::OK) {
return result;
}
finishTcPrep(resetCmd.getFullPacketLen());
return returnvalue::OK;
}
void PlocSupervisorHandler::finishTcPrep(size_t packetLen) { void PlocSupervisorHandler::finishTcPrep(size_t packetLen) {
nextReplyId = supv::ACK_REPORT; nextReplyId = supv::ACK_REPORT;
rawPacket = commandBuffer; rawPacket = commandBuffer;

View File

@ -264,6 +264,8 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
ReturnValue_t prepareRestartTriesCmd(const uint8_t* commandData); ReturnValue_t prepareRestartTriesCmd(const uint8_t* commandData);
ReturnValue_t prepareFactoryResetCmd(const uint8_t* commandData, size_t len);
/** /**
* @brief This function fills the command buffer with the packet to enable or disable the * @brief This function fills the command buffer with the packet to enable or disable the
* watchdogs on the PLOC. * watchdogs on the PLOC.