v1.12.0 #269

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

View File

@ -55,15 +55,16 @@ static const DeviceCommandId_t LOGGING_CLEAR_COUNTERS = 55;
static const DeviceCommandId_t LOGGING_SET_TOPIC = 56; static const DeviceCommandId_t LOGGING_SET_TOPIC = 56;
static const DeviceCommandId_t REQUEST_ADC_REPORT = 57; static const DeviceCommandId_t REQUEST_ADC_REPORT = 57;
static const DeviceCommandId_t RESET_PL = 58; static const DeviceCommandId_t RESET_PL = 58;
static const DeviceCommandId_t ENABLE_NVMS = 59;
/** Reply IDs */ /** Reply IDs */
static const DeviceCommandId_t ACK_REPORT = 50; static const DeviceCommandId_t ACK_REPORT = 100;
static const DeviceCommandId_t EXE_REPORT = 51; static const DeviceCommandId_t EXE_REPORT = 101;
static const DeviceCommandId_t HK_REPORT = 52; static const DeviceCommandId_t HK_REPORT = 102;
static const DeviceCommandId_t BOOT_STATUS_REPORT = 53; static const DeviceCommandId_t BOOT_STATUS_REPORT = 103;
static const DeviceCommandId_t LATCHUP_REPORT = 54; static const DeviceCommandId_t LATCHUP_REPORT = 104;
static const DeviceCommandId_t LOGGING_REPORT = 55; static const DeviceCommandId_t LOGGING_REPORT = 105;
static const DeviceCommandId_t ADC_REPORT = 56; static const DeviceCommandId_t ADC_REPORT = 106;
// Size of complete space packet (6 byte header + size of data + 2 byte CRC) // 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_ACK_REPORT = 14;
@ -122,6 +123,7 @@ static const uint16_t APID_SET_ADC_THRESHOLD = 0xE3;
static const uint16_t APID_GET_LATCHUP_STATUS_REPORT = 0xD9; 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_COPY_ADC_DATA_TO_MRAM = 0xDA;
static const uint16_t APID_REQUEST_ADC_REPORT = 0xDB; 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_RUN_AUTO_EM_TESTS = 0xF2;
static const uint16_t APID_WIPE_MRAM = 0xF3; static const uint16_t APID_WIPE_MRAM = 0xF3;
static const uint16_t APID_DUMP_MRAM = 0xF4; static const uint16_t APID_DUMP_MRAM = 0xF4;
@ -357,6 +359,50 @@ class MPSoCBootSelect : public SpacePacket {
} }
}; };
/**
* @brief This class creates the command to enable or disable the NVMs connected to the
* supervisor.
*/
class EnableNvms : public SpacePacket {
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(uint8_t nvm01, uint8_t nvm3)
: SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_ENABLE_NVMS, DEFAULT_SEQUENCE_COUNT),
nvm01(nvm01),
nvm3(nvm3) {
initPacket();
}
private:
static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
static const uint8_t DATA_FIELD_LENGTH = 4;
static const uint8_t CRC_OFFSET = 2;
uint8_t nvm01 = 0;
uint8_t nvm3 = 0;
void initPacket() {
*(this->localData.fields.buffer) = nvm01;
*(this->localData.fields.buffer + 1) = nvm3;
/* Calculate crc */
uint16_t crc = CRC::crc16ccitt(this->localData.byteStream,
sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2);
/* Add crc to packet data field of space packet */
size_t serializedSize = 0;
uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET;
SerializeAdapter::serialize<uint16_t>(&crc, &crcPos, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
}
};
/** /**
* @brief This class generates the space packet to update the time of the PLOC supervisor. * @brief This class generates the space packet to update the time of the PLOC supervisor.
*/ */
@ -1664,13 +1710,7 @@ class BootStatusReport : public StaticLocalDataSet<BOOT_REPORT_SET_ENTRIES> {
*/ */
class HkSet : public StaticLocalDataSet<HK_SET_ENTRIES> { class HkSet : public StaticLocalDataSet<HK_SET_ENTRIES> {
public: public:
enum class SocState { OFF = 0, BOOTING = 1, OPERATIONAL = 3, SHUTDOWN = 4 };
enum class SocState {
OFF = 0,
BOOTING = 1,
OPERATIONAL = 3,
SHUTDOWN = 4
};
HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {} HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {}

View File

@ -147,7 +147,7 @@ void PlocSupervisorHandler::doStartUp() {
case StartupState::BOOTING: { case StartupState::BOOTING: {
if (bootTimeout.hasTimedOut()) { if (bootTimeout.hasTimedOut()) {
uartIsolatorSwitch.pullHigh(); uartIsolatorSwitch.pullHigh();
// startupState = StartupState::SET_TIME; // startupState = StartupState::SET_TIME;
startupState = StartupState::ON; startupState = StartupState::ON;
} }
} }
@ -377,6 +377,10 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
result = RETURN_OK; result = RETURN_OK;
break; break;
} }
case ENABLE_NVMS: {
result = prepareEnableNvmsCommand(commandData);
break;
}
default: default:
sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented"
<< std::endl; << std::endl;
@ -432,6 +436,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(LOGGING_CLEAR_COUNTERS); this->insertInCommandMap(LOGGING_CLEAR_COUNTERS);
this->insertInCommandMap(LOGGING_SET_TOPIC); this->insertInCommandMap(LOGGING_SET_TOPIC);
this->insertInCommandMap(RESET_PL); this->insertInCommandMap(RESET_PL);
this->insertInCommandMap(ENABLE_NVMS);
this->insertInCommandAndReplyMap(FIRST_MRAM_DUMP, 3); this->insertInCommandAndReplyMap(FIRST_MRAM_DUMP, 3);
this->insertInCommandAndReplyMap(CONSECUTIVE_MRAM_DUMP, 3); this->insertInCommandAndReplyMap(CONSECUTIVE_MRAM_DUMP, 3);
this->insertInReplyMap(ACK_REPORT, 3, nullptr, SIZE_ACK_REPORT); this->insertInReplyMap(ACK_REPORT, 3, nullptr, SIZE_ACK_REPORT);
@ -552,6 +557,7 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
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:
enabledReplies = 2; enabledReplies = 2;
break; break;
default: default:
@ -878,7 +884,7 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
case SupvReturnValuesIF::RECEIVED_ACK_FAILURE: { case SupvReturnValuesIF::RECEIVED_ACK_FAILURE: {
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1 #if OBSW_DEBUG_PLOC_SUPERVISOR == 1
sif::debug << "PlocSupervisorHandler: Received Ack failure report with status code: 0x" sif::debug << "PlocSupervisorHandler: Received Ack failure report with status code: 0x"
<< std::hex << ack.getStatusCode() << std::endl; << std::hex << ack.getStatusCode() << std::endl;
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
DeviceCommandId_t commandId = getPendingCommand(); DeviceCommandId_t commandId = getPendingCommand();
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
@ -1176,7 +1182,7 @@ ReturnValue_t PlocSupervisorHandler::handleLoggingReport(const uint8_t* data) {
if (result == SupvReturnValuesIF::CRC_FAILURE) { if (result == SupvReturnValuesIF::CRC_FAILURE) {
sif::warning << "PlocSupervisorHandler::handleLoggingReport: Logging report has " sif::warning << "PlocSupervisorHandler::handleLoggingReport: Logging report has "
<< "invalid crc" << std::endl; << "invalid crc" << std::endl;
return result; return result;
} }
@ -1533,6 +1539,15 @@ ReturnValue_t PlocSupervisorHandler::prepareLoggingRequest(const uint8_t* comman
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t PlocSupervisorHandler::prepareEnableNvmsCommand(const uint8_t* commandData) {
using namespace supv;
uint8_t nvm01 = *(commandData);
uint8_t nvm3 = *(commandData + 1);
EnableNvms packet(nvm01, nvm3);
packetToOutBuffer(packet.getWholeData(), packet.getFullSize());
return RETURN_OK;
}
void PlocSupervisorHandler::disableAllReplies() { void PlocSupervisorHandler::disableAllReplies() {
DeviceReplyMap::iterator iter; DeviceReplyMap::iterator iter;
@ -1872,8 +1887,8 @@ void PlocSupervisorHandler::handleExecutionSuccessReport(const uint8_t* data) {
} }
uint8_t data[sizeof(gpioState)]; uint8_t data[sizeof(gpioState)];
size_t size = 0; size_t size = 0;
ReturnValue_t result = SerializeAdapter::serialize( ReturnValue_t result = SerializeAdapter::serialize(&gpioState, data, &size, sizeof(gpioState),
&gpioState, data, &size, sizeof(gpioState), SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler: Failed to deserialize GPIO state" << std::endl; sif::debug << "PlocSupervisorHandler: Failed to deserialize GPIO state" << std::endl;
} }

View File

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