ploc supervisor watchdogs enable command

This commit is contained in:
Jakob.Meier 2021-07-26 16:30:20 +02:00
parent dc73036c7a
commit 6506baa7b6
4 changed files with 109 additions and 31 deletions

View File

@ -115,6 +115,11 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(
prepareUpdateAvailableCmd(commandData);
result = RETURN_OK;
break;
}
case(PLOC_SPV::WATCHDOGS_ENABLE): {
prepareWatchdogsEnableCmd(commandData);
result = RETURN_OK;
break;
}
default:
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
@ -145,6 +150,8 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(PLOC_SPV::SET_TIME_REF);
this->insertInCommandMap(PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION);
this->insertInCommandMap(PLOC_SPV::GET_BOOT_STATUS_REPORT);
this->insertInCommandMap(PLOC_SPV::UPDATE_AVAILABLE);
this->insertInCommandMap(PLOC_SPV::WATCHDOGS_ENABLE);
this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT);
this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT);
this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT);
@ -530,6 +537,8 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
case PLOC_SPV::SET_MAX_RESTART_TRIES:
case PLOC_SPV::RESET_MPSOC:
case PLOC_SPV::SET_TIME_REF:
case PLOC_SPV::UPDATE_AVAILABLE:
case PLOC_SPV::WATCHDOGS_ENABLE:
enabledReplies = 2;
break;
default:
@ -705,6 +714,20 @@ void PlocSupervisorHandler::prepareUpdateAvailableCmd(const uint8_t * commandDat
nextReplyId = PLOC_SPV::ACK_REPORT;
}
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);
PLOC_SPV::WatchdogsEnable packet(watchdogPs, watchdogPl, watchdogInt);
memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = packet.getFullSize();
nextReplyId = PLOC_SPV::ACK_REPORT;
}
void PlocSupervisorHandler::disableAllReplies() {
DeviceReplyMap::iterator iter;

View File

@ -172,7 +172,6 @@ private:
*/
void prepareEmptyCmd(uint16_t apid);
/**
* @brief This function initializes the space packet to select the boot image of the MPSoC.
*/
@ -200,6 +199,12 @@ private:
*/
void prepareUpdateAvailableCmd(const uint8_t * commandData);
/**
* @brief This function fills the command buffer with the packet to enable or disable the
* watchdogs on the PLOC.
*/
void prepareWatchdogsEnableCmd(const uint8_t * commandData);
/**
* @brief In case an acknowledgment failure reply has been received this function disables
* all previously enabled commands and resets the exepected replies variable of an

View File

@ -23,6 +23,7 @@ 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 UPDATE_AVAILABLE = 12;
static const DeviceCommandId_t WATCHDOGS_ENABLE = 13;
/** Reply IDs */
static const DeviceCommandId_t ACK_REPORT = 50;
@ -342,34 +343,6 @@ private:
}
};
/**
* @brief This dataset stores the boot status report of the supervisor.
*/
class BootStatusReport: public StaticLocalDataSet<BOOT_REPORT_SET_ENTRIES> {
public:
BootStatusReport(HasLocalDataPoolIF* owner) :
StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {
}
BootStatusReport(object_id_t objectId) :
StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {
}
/** Information about boot status of MPSoC */
lp_var_t<uint8_t> bootSignal = lp_var_t<uint8_t>(sid.objectId, PoolIds::BOOT_SIGNAL, this);
lp_var_t<uint8_t> resetCounter = lp_var_t<uint8_t>(sid.objectId, PoolIds::RESET_COUNTER, this);
/** Time the MPSoC needs for last boot */
lp_var_t<uint32_t> bootAfterMs = lp_var_t<uint32_t>(sid.objectId, PoolIds::BOOT_AFTER_MS, this);
/** The currently set boot timeout */
lp_var_t<uint32_t> bootTimeoutMs = lp_var_t<uint32_t>(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this);
lp_var_t<uint8_t> activeNvm = lp_var_t<uint8_t>(sid.objectId, PoolIds::ACTIVE_NVM, this);
/** States of the boot partition pins */
lp_var_t<uint8_t> bp0State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP0_STATE, this);
lp_var_t<uint8_t> bp1State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP1_STATE, this);
lp_var_t<uint8_t> bp2State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP2_STATE, this);
};
/**
* @brief This class packages the command to notify the supervisor that a new update for the
* MPSoC is available.
@ -428,7 +401,6 @@ private:
serializedSize = 0;
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
@ -470,6 +442,84 @@ private:
}
};
/**
* @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* data_field_ptr = this->localData.fields.buffer;
SerializeAdapter::serialize<uint8_t>(&watchdogPs, &data_field_ptr, &serializedSize,
sizeof(watchdogPs), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&watchdogPl, &data_field_ptr, &serializedSize,
sizeof(watchdogPl), SerializeIF::Endianness::BIG);
serializedSize = 0;
SerializeAdapter::serialize<uint8_t>(&watchdogInt, &data_field_ptr, &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 dataset stores the boot status report of the supervisor.
*/
class BootStatusReport: public StaticLocalDataSet<BOOT_REPORT_SET_ENTRIES> {
public:
BootStatusReport(HasLocalDataPoolIF* owner) :
StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {
}
BootStatusReport(object_id_t objectId) :
StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {
}
/** Information about boot status of MPSoC */
lp_var_t<uint8_t> bootSignal = lp_var_t<uint8_t>(sid.objectId, PoolIds::BOOT_SIGNAL, this);
lp_var_t<uint8_t> resetCounter = lp_var_t<uint8_t>(sid.objectId, PoolIds::RESET_COUNTER, this);
/** Time the MPSoC needs for last boot */
lp_var_t<uint32_t> bootAfterMs = lp_var_t<uint32_t>(sid.objectId, PoolIds::BOOT_AFTER_MS, this);
/** The currently set boot timeout */
lp_var_t<uint32_t> bootTimeoutMs = lp_var_t<uint32_t>(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this);
lp_var_t<uint8_t> activeNvm = lp_var_t<uint8_t>(sid.objectId, PoolIds::ACTIVE_NVM, this);
/** States of the boot partition pins */
lp_var_t<uint8_t> bp0State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP0_STATE, this);
lp_var_t<uint8_t> bp1State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP1_STATE, this);
lp_var_t<uint8_t> bp2State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP2_STATE, this);
};
/**
* @brief This dataset stores the housekeeping data of the supervisor.
*/

2
tmtc

@ -1 +1 @@
Subproject commit 6352a6f272b3138257831fcd1f5d9ffcd4902681
Subproject commit 75ae2c786b2422ea1986ce69bdcd528346e88f1a