mpsoc startup command
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
#include "PlocMPSoCHandler.h"
|
||||
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
@ -6,14 +7,18 @@
|
||||
|
||||
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
|
||||
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
|
||||
Gpio uartIsolatorSwitch)
|
||||
Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
|
||||
: DeviceHandlerBase(objectId, uartComIFid, comCookie),
|
||||
plocMPSoCHelper(plocMPSoCHelper),
|
||||
uartIsolatorSwitch(uartIsolatorSwitch) {
|
||||
uartIsolatorSwitch(uartIsolatorSwitch),
|
||||
supervisorHandler(supervisorHandler),
|
||||
commandActionHelper(this) {
|
||||
if (comCookie == nullptr) {
|
||||
sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl;
|
||||
}
|
||||
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||
commandActionHelperQueue =
|
||||
QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||
}
|
||||
|
||||
PlocMPSoCHandler::~PlocMPSoCHandler() {}
|
||||
@ -60,6 +65,10 @@ ReturnValue_t PlocMPSoCHandler::initialize() {
|
||||
}
|
||||
plocMPSoCHelper->setComCookie(comCookie);
|
||||
plocMPSoCHelper->setSequenceCount(&sequenceCount);
|
||||
result = commandActionHelper.initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -77,6 +86,14 @@ void PlocMPSoCHandler::performOperationHook() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
CommandMessage message;
|
||||
for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&event); result == RETURN_OK;
|
||||
result = commandActionHelperQueue->receiveMessage(&event)) {
|
||||
result = commandActionHelper.handleReply(&message);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
@ -116,17 +133,34 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::doStartUp() {
|
||||
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
|
||||
setMode(MODE_NORMAL);
|
||||
#else
|
||||
setMode(_MODE_TO_ON);
|
||||
#endif
|
||||
uartIsolatorSwitch.pullHigh();
|
||||
switch(powerState) {
|
||||
case PowerState::OFF:
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC);
|
||||
powerState = PowerState::BOOTING;
|
||||
break;
|
||||
case PowerState::ON:
|
||||
setMode(_MODE_TO_ON);
|
||||
uartIsolatorSwitch.pullHigh();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::doShutDown() {
|
||||
uartIsolatorSwitch.pullLow();
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
switch(powerState) {
|
||||
case PowerState::ON:
|
||||
uartIsolatorSwitch.pullLow();
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
|
||||
powerState = PowerState::SHUTDOWN;
|
||||
break;
|
||||
case PowerState::OFF:
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::doShutDown: This should never happen" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
@ -331,7 +365,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
return NAME_TOO_LONG;
|
||||
return MPSoCReturnValuesIF::NAME_TOO_LONG;
|
||||
}
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
sequenceCount++;
|
||||
@ -670,6 +704,45 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
|
||||
return replyLen;
|
||||
}
|
||||
|
||||
MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() {
|
||||
return commandActionHelperQueue;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {
|
||||
return;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
ReturnValue_t returnCode) {
|
||||
handleActionCommandFailure(actionId);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||
return;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
switch(actionId) {
|
||||
case supv::START_MPSOC: {
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
}
|
||||
case supv::SHUTDOWN_MPSOC: {
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
default:
|
||||
sif::debug
|
||||
<< "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action reply"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||
handleActionCommandFailure(actionId);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
|
||||
DeviceCommandId_t replyId) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
@ -764,3 +837,20 @@ void PlocMPSoCHandler::printStatus(const uint8_t* data) {
|
||||
uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) {
|
||||
return *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
|
||||
switch (actionId) {
|
||||
case supv::START_MPSOC:
|
||||
powerState = PowerState::ON;
|
||||
break;
|
||||
case supv::SHUTDOWN_MPSOC:
|
||||
triggerEvent(MPSOC_SHUTDOWN_FAILED);
|
||||
// TODO: Setting state to on or off here?
|
||||
powerState = PowerState::OFF;
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Received unexpected action reply"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user