2022-01-06 18:05:21 +01:00
|
|
|
#include "PlocMPSoCHandler.h"
|
2022-03-22 11:35:44 +01:00
|
|
|
|
|
|
|
#include "OBSWConfig.h"
|
2022-01-06 18:05:21 +01:00
|
|
|
#include "fsfw/datapool/PoolReadGuard.h"
|
2022-03-22 11:35:44 +01:00
|
|
|
#include "fsfw/globalfunctions/CRC.h"
|
2022-04-04 13:40:45 +02:00
|
|
|
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2022-08-18 10:42:18 +02:00
|
|
|
// TODO this is work in progress in adapting to new actions
|
2022-07-27 22:03:41 +02:00
|
|
|
|
2022-01-03 08:01:55 +01:00
|
|
|
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
|
2022-03-27 14:42:20 +02:00
|
|
|
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
|
2022-03-30 09:19:30 +02:00
|
|
|
Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
|
2022-03-27 14:42:20 +02:00
|
|
|
: DeviceHandlerBase(objectId, uartComIFid, comCookie),
|
|
|
|
plocMPSoCHelper(plocMPSoCHelper),
|
2022-03-30 09:19:30 +02:00
|
|
|
uartIsolatorSwitch(uartIsolatorSwitch),
|
|
|
|
supervisorHandler(supervisorHandler),
|
|
|
|
commandActionHelper(this) {
|
2022-03-27 14:42:20 +02:00
|
|
|
if (comCookie == nullptr) {
|
|
|
|
sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl;
|
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
2022-03-30 09:19:30 +02:00
|
|
|
commandActionHelperQueue =
|
|
|
|
QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
2021-03-29 14:37:52 +02:00
|
|
|
}
|
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
PlocMPSoCHandler::~PlocMPSoCHandler() {}
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2022-01-03 08:01:55 +01:00
|
|
|
ReturnValue_t PlocMPSoCHandler::initialize() {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
result = DeviceHandlerBase::initialize();
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
uartComIf = dynamic_cast<UartComIF*>(communicationInterface);
|
|
|
|
if (uartComIf == nullptr) {
|
|
|
|
sif::warning << "PlocMPSoCHandler::initialize: Invalid uart com if" << std::endl;
|
|
|
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
|
|
|
}
|
2022-01-06 18:05:21 +01:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
|
|
|
if (manager == nullptr) {
|
2022-01-06 18:05:21 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2022-03-22 11:35:44 +01:00
|
|
|
sif::error << "PlocMPSoCHandler::initialize: Invalid event manager" << std::endl;
|
2022-01-06 18:05:21 +01:00
|
|
|
#endif
|
2022-03-22 11:35:44 +01:00
|
|
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
|
|
|
;
|
|
|
|
}
|
|
|
|
result = manager->registerListener(eventQueue->getId());
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
result = manager->subscribeToEventRange(
|
|
|
|
eventQueue->getId(), event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_FAILED),
|
|
|
|
event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_SUCCESSFUL));
|
|
|
|
if (result != RETURN_OK) {
|
2022-01-06 18:05:21 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2022-03-22 11:35:44 +01:00
|
|
|
sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from "
|
|
|
|
" ploc mpsoc helper"
|
|
|
|
<< std::endl;
|
2022-01-06 18:05:21 +01:00
|
|
|
#endif
|
2022-03-22 11:35:44 +01:00
|
|
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
|
|
|
}
|
2022-01-06 18:05:21 +01:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
result = plocMPSoCHelper->setComIF(communicationInterface);
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
|
|
|
}
|
|
|
|
plocMPSoCHelper->setComCookie(comCookie);
|
|
|
|
plocMPSoCHelper->setSequenceCount(&sequenceCount);
|
2022-03-30 09:19:30 +02:00
|
|
|
result = commandActionHelper.initialize();
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
return result;
|
2022-01-03 08:01:55 +01:00
|
|
|
}
|
|
|
|
|
2022-01-07 09:50:04 +01:00
|
|
|
void PlocMPSoCHandler::performOperationHook() {
|
2022-03-22 11:35:44 +01:00
|
|
|
EventMessage event;
|
|
|
|
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK;
|
|
|
|
result = eventQueue->receiveMessage(&event)) {
|
|
|
|
switch (event.getMessageId()) {
|
|
|
|
case EventMessage::EVENT_MESSAGE:
|
|
|
|
handleEvent(&event);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sif::debug << "PlocMPSoCHandler::performOperationHook: Did not subscribe to this event"
|
|
|
|
<< " message" << std::endl;
|
|
|
|
break;
|
2022-01-07 09:50:04 +01:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
2022-03-30 09:19:30 +02:00
|
|
|
CommandMessage message;
|
2022-04-04 13:40:45 +02:00
|
|
|
for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&message);
|
|
|
|
result == RETURN_OK; result = commandActionHelperQueue->receiveMessage(&message)) {
|
2022-03-30 09:19:30 +02:00
|
|
|
result = commandActionHelper.handleReply(&message);
|
|
|
|
if (result == RETURN_OK) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2022-01-07 09:50:04 +01:00
|
|
|
}
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::executeAction(Action* action) {
|
|
|
|
switch (PlocMpSoCCommands(action->getId())) {
|
|
|
|
case PlocMpSoCCommands::SET_UART_TX_TRISTATE: {
|
2022-04-30 16:21:59 +02:00
|
|
|
uartIsolatorSwitch.pullLow();
|
|
|
|
return EXECUTION_FINISHED;
|
|
|
|
break;
|
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case PlocMpSoCCommands::RELEASE_UART_TX: {
|
2022-04-30 16:21:59 +02:00
|
|
|
uartIsolatorSwitch.pullHigh();
|
|
|
|
return EXECUTION_FINISHED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2022-04-29 22:55:01 +02:00
|
|
|
}
|
2022-01-06 18:05:21 +01:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
if (plocMPSoCHelperExecuting) {
|
|
|
|
return MPSoCReturnValuesIF::MPSOC_HELPER_EXECUTING;
|
|
|
|
}
|
2022-01-06 18:05:21 +01:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
switch (PlocMpSoCCommands(action->getId())) {
|
|
|
|
case PlocMpSoCCommands::TC_FLASHWRITE: {
|
|
|
|
// refer handling to the handleAction() below
|
|
|
|
return action->handle();
|
2022-03-27 12:56:39 +02:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case (PlocMpSoCCommands::OBSW_RESET_SEQ_COUNT): {
|
2022-03-27 12:56:39 +02:00
|
|
|
sequenceCount = 0;
|
|
|
|
return EXECUTION_FINISHED;
|
2022-01-06 18:05:21 +01:00
|
|
|
}
|
|
|
|
default:
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t result = DeviceHandlerBase::executeAction(action);
|
|
|
|
|
|
|
|
if (result == RETURN_OK) {
|
|
|
|
/**
|
|
|
|
* Flushing the receive buffer to make sure there are no data left from a faulty reply.
|
|
|
|
*/
|
|
|
|
uartComIf->flushUartRxBuffer(comCookie);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2022-01-06 18:05:21 +01:00
|
|
|
}
|
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
void PlocMPSoCHandler::doStartUp() {
|
2022-04-20 21:33:39 +02:00
|
|
|
#ifdef XIPHOS_Q7S
|
2022-04-28 18:30:40 +02:00
|
|
|
#if not OBSW_MPSOC_JTAG_BOOT == 1
|
2022-04-04 13:40:45 +02:00
|
|
|
switch (powerState) {
|
|
|
|
case PowerState::OFF:
|
2022-03-30 09:19:30 +02:00
|
|
|
commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC);
|
|
|
|
powerState = PowerState::BOOTING;
|
|
|
|
break;
|
2022-04-04 13:40:45 +02:00
|
|
|
case PowerState::ON:
|
2022-03-30 09:19:30 +02:00
|
|
|
setMode(_MODE_TO_ON);
|
|
|
|
uartIsolatorSwitch.pullHigh();
|
|
|
|
break;
|
2022-04-04 13:40:45 +02:00
|
|
|
default:
|
2022-03-30 09:19:30 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-04-20 21:33:39 +02:00
|
|
|
#else
|
2022-04-28 18:30:40 +02:00
|
|
|
powerState = PowerState::ON;
|
|
|
|
setMode(_MODE_TO_ON);
|
|
|
|
uartIsolatorSwitch.pullHigh();
|
2022-04-30 16:21:59 +02:00
|
|
|
#endif /* not MSPOC_JTAG_BOOT == 1 */
|
2022-04-28 18:30:40 +02:00
|
|
|
#else
|
|
|
|
powerState = PowerState::ON;
|
2022-04-20 21:33:39 +02:00
|
|
|
setMode(_MODE_TO_ON);
|
|
|
|
#endif /* XIPHOS_Q7S */
|
2021-03-29 14:37:52 +02:00
|
|
|
}
|
|
|
|
|
2022-03-27 14:42:20 +02:00
|
|
|
void PlocMPSoCHandler::doShutDown() {
|
2022-04-28 18:30:40 +02:00
|
|
|
#ifdef XIPHOS_Q7S
|
|
|
|
#if not OBSW_MPSOC_JTAG_BOOT == 1
|
2022-04-04 13:40:45 +02:00
|
|
|
switch (powerState) {
|
|
|
|
case PowerState::ON:
|
2022-03-30 09:19:30 +02:00
|
|
|
uartIsolatorSwitch.pullLow();
|
|
|
|
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
|
|
|
|
powerState = PowerState::SHUTDOWN;
|
|
|
|
break;
|
2022-04-04 13:40:45 +02:00
|
|
|
case PowerState::OFF:
|
2022-03-30 09:19:30 +02:00
|
|
|
setMode(_MODE_POWER_DOWN);
|
|
|
|
break;
|
2022-04-04 13:40:45 +02:00
|
|
|
default:
|
2022-03-30 09:19:30 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-04-28 18:30:40 +02:00
|
|
|
#else
|
|
|
|
uartIsolatorSwitch.pullLow();
|
|
|
|
setMode(_MODE_POWER_DOWN);
|
|
|
|
powerState = PowerState::OFF;
|
|
|
|
#endif
|
|
|
|
#endif
|
2022-03-27 14:42:20 +02:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
|
|
|
|
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
|
|
|
return NOTHING_TO_SEND;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
2022-03-31 11:50:33 +02:00
|
|
|
return NOTHING_TO_SEND;
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
void PlocMPSoCHandler::fillCommandAndReplyMap() {
|
2022-07-27 22:03:41 +02:00
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MEM_WRITE));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MEM_READ));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_FLASHDELETE));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_REPLAY_START));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_REPLAY_STOP));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_DOWNLINK_PWR_ON));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_DOWNLINK_PWR_OFF));
|
|
|
|
this->insertInCommandMap(
|
|
|
|
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MODE_REPLAY));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MODE_IDLE));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_CAM_CMD_SEND));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::RELEASE_UART_TX));
|
|
|
|
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::SET_UART_TX_TRISTATE));
|
|
|
|
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT), 3, nullptr,
|
|
|
|
mpsoc::SIZE_ACK_REPORT);
|
|
|
|
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT), 3, nullptr,
|
|
|
|
mpsoc::SIZE_EXE_REPORT);
|
|
|
|
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT),
|
|
|
|
2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
|
|
|
|
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT), 2,
|
|
|
|
nullptr, SpacePacket::PACKET_MAX_SIZE);
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
|
|
|
DeviceCommandId_t* foundId, size_t* foundLen) {
|
|
|
|
ReturnValue_t result = RETURN_OK;
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-04-20 21:33:39 +02:00
|
|
|
SpacePacket spacePacket;
|
|
|
|
std::memcpy(spacePacket.getWholeData(), start, remainingSize);
|
|
|
|
uint16_t apid = spacePacket.getAPID();
|
2022-03-22 11:35:44 +01:00
|
|
|
|
|
|
|
switch (apid) {
|
|
|
|
case (mpsoc::apid::ACK_SUCCESS):
|
|
|
|
*foundLen = mpsoc::SIZE_ACK_REPORT;
|
2022-07-27 22:03:41 +02:00
|
|
|
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT);
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
|
|
|
case (mpsoc::apid::ACK_FAILURE):
|
|
|
|
*foundLen = mpsoc::SIZE_ACK_REPORT;
|
2022-07-27 22:03:41 +02:00
|
|
|
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT);
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
|
|
|
case (mpsoc::apid::TM_MEMORY_READ_REPORT):
|
|
|
|
*foundLen = tmMemReadReport.rememberRequestedSize;
|
2022-07-27 22:03:41 +02:00
|
|
|
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT);
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
2022-04-20 21:33:39 +02:00
|
|
|
case (mpsoc::apid::TM_CAM_CMD_RPT):
|
|
|
|
*foundLen = spacePacket.getFullSize();
|
|
|
|
tmCamCmdRpt.rememberSpacePacketSize = *foundLen;
|
2022-07-27 22:03:41 +02:00
|
|
|
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT);
|
2022-04-20 21:33:39 +02:00
|
|
|
break;
|
2022-03-22 11:35:44 +01:00
|
|
|
case (mpsoc::apid::EXE_SUCCESS):
|
|
|
|
*foundLen = mpsoc::SIZE_EXE_REPORT;
|
2022-07-27 22:03:41 +02:00
|
|
|
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT);
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
|
|
|
case (mpsoc::apid::EXE_FAILURE):
|
|
|
|
*foundLen = mpsoc::SIZE_EXE_REPORT;
|
2022-07-27 22:03:41 +02:00
|
|
|
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT);
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
|
|
|
default: {
|
|
|
|
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl;
|
|
|
|
*foundLen = remainingSize;
|
|
|
|
return MPSoCReturnValuesIF::INVALID_APID;
|
|
|
|
}
|
|
|
|
}
|
2022-04-20 21:33:39 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
sequenceCount++;
|
|
|
|
uint16_t recvSeqCnt = (*(start + 2) << 8 | *(start + 3)) & PACKET_SEQUENCE_COUNT_MASK;
|
|
|
|
if (recvSeqCnt != sequenceCount) {
|
2022-05-03 14:59:23 +02:00
|
|
|
triggerEvent(MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH, sequenceCount, recvSeqCnt);
|
2022-03-22 11:35:44 +01:00
|
|
|
sequenceCount = recvSeqCnt;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
|
|
|
ReturnValue_t result = RETURN_OK;
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCCommands enumId = PlocMpSoCCommands(id);
|
|
|
|
|
|
|
|
switch (enumId) {
|
|
|
|
case PlocMpSoCCommands::ACK_REPORT: {
|
2022-03-22 11:35:44 +01:00
|
|
|
result = handleAckReport(packet);
|
|
|
|
break;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case (PlocMpSoCCommands::TM_MEMORY_READ_REPORT): {
|
2022-03-22 11:35:44 +01:00
|
|
|
result = handleMemoryReadReport(packet);
|
|
|
|
break;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case (PlocMpSoCCommands::TM_CAM_CMD_RPT): {
|
2022-04-20 21:33:39 +02:00
|
|
|
result = handleCamCmdRpt(packet);
|
|
|
|
break;
|
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case (PlocMpSoCCommands::EXE_REPORT): {
|
2022-03-22 11:35:44 +01:00
|
|
|
result = handleExecutionReport(packet);
|
|
|
|
break;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
|
|
|
default: {
|
2022-03-22 11:35:44 +01:00
|
|
|
sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
|
|
|
|
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
return result;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {}
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-03-31 11:50:33 +02:00
|
|
|
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; }
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
2022-03-22 11:35:44 +01:00
|
|
|
LocalDataPoolManager& poolManager) {
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
|
|
|
|
2022-01-07 09:50:04 +01:00
|
|
|
void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
|
2022-03-22 11:35:44 +01:00
|
|
|
object_id_t objectId = eventMessage->getReporter();
|
|
|
|
switch (objectId) {
|
2022-01-07 09:50:04 +01:00
|
|
|
case objects::PLOC_MPSOC_HELPER: {
|
2022-03-22 11:35:44 +01:00
|
|
|
plocMPSoCHelperExecuting = false;
|
|
|
|
break;
|
2022-01-07 09:50:04 +01:00
|
|
|
}
|
|
|
|
default:
|
2022-03-22 11:35:44 +01:00
|
|
|
sif::debug << "PlocMPSoCHandler::handleEvent: Did not subscribe to this event" << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
2022-01-07 09:50:04 +01:00
|
|
|
}
|
|
|
|
|
2022-08-18 10:42:18 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
|
|
|
const uint8_t* commandData,
|
|
|
|
size_t commandDataLen) {
|
|
|
|
return NOTHING_TO_SEND;
|
|
|
|
}
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCMemWriteAction* action) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcMemWrite tcMemWrite(sequenceCount);
|
2022-07-27 22:03:41 +02:00
|
|
|
result = tcMemWrite.createPacket(action);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
copyToCommandBuffer(&tcMemWrite);
|
|
|
|
return RETURN_OK;
|
2021-04-15 13:17:15 +02:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCMemReadAction* action) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcMemRead tcMemRead(sequenceCount);
|
2022-08-18 10:42:18 +02:00
|
|
|
// result = tcMemRead.createPacket(commandData, commandDataLen);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
copyToCommandBuffer(&tcMemRead);
|
|
|
|
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
|
|
|
|
return RETURN_OK;
|
2022-03-21 08:35:28 +01:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCFlashDeleteAction* action) {
|
|
|
|
// if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
|
|
|
// return MPSoCReturnValuesIF::NAME_TOO_LONG;
|
|
|
|
// }
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcFlashDelete tcFlashDelete(sequenceCount);
|
2022-08-18 10:42:18 +02:00
|
|
|
// result = tcFlashDelete.createPacket(
|
|
|
|
// std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
copyToCommandBuffer(&tcFlashDelete);
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReplayStartAction* action) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcReplayStart tcReplayStart(sequenceCount);
|
2022-08-18 10:42:18 +02:00
|
|
|
// result = tcReplayStart.createPacket(commandData, commandDataLen);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
copyToCommandBuffer(&tcReplayStart);
|
|
|
|
return RETURN_OK;
|
2022-03-21 11:05:41 +01:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReplayStopAction* action) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcReplayStop tcReplayStop(sequenceCount);
|
|
|
|
result = tcReplayStop.createPacket();
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
copyToCommandBuffer(&tcReplayStop);
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCDownlinkPwrOnAction* action) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(sequenceCount);
|
2022-08-18 10:42:18 +02:00
|
|
|
// result = tcDownlinkPwrOn.createPacket(commandData, commandDataLen);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
copyToCommandBuffer(&tcDownlinkPwrOn);
|
|
|
|
return RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCDownlinkPwrOffAction* action) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(sequenceCount);
|
|
|
|
result = tcDownlinkPwrOff.createPacket();
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
copyToCommandBuffer(&tcDownlinkPwrOff);
|
|
|
|
return RETURN_OK;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReplayWriteSequenceAction* action) {
|
2022-03-21 16:21:51 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(sequenceCount);
|
2022-08-18 10:42:18 +02:00
|
|
|
// result = tcReplayWriteSeq.createPacket(commandData, commandDataLen);
|
2022-03-21 16:21:51 +01:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
copyToCommandBuffer(&tcReplayWriteSeq);
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCModeReplayAction* action) {
|
2022-03-25 09:08:01 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcModeReplay tcModeReplay(sequenceCount);
|
|
|
|
result = tcModeReplay.createPacket();
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
memcpy(commandBuffer, tcModeReplay.getWholeData(), tcModeReplay.getFullSize());
|
|
|
|
rawPacket = commandBuffer;
|
|
|
|
rawPacketLen = tcModeReplay.getFullSize();
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::ACK_REPORT;
|
2022-03-25 09:08:01 +01:00
|
|
|
return RETURN_OK;
|
2022-03-24 17:39:50 +01:00
|
|
|
}
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCModeIdleAction* action) {
|
2022-04-20 21:33:39 +02:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcModeIdle tcModeIdle(sequenceCount);
|
|
|
|
result = tcModeIdle.createPacket();
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
memcpy(commandBuffer, tcModeIdle.getWholeData(), tcModeIdle.getFullSize());
|
|
|
|
rawPacket = commandBuffer;
|
|
|
|
rawPacketLen = tcModeIdle.getFullSize();
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::ACK_REPORT;
|
2022-04-20 21:33:39 +02:00
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCCamCmdSendAction* action) {
|
2022-04-20 21:33:39 +02:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
sequenceCount++;
|
|
|
|
mpsoc::TcCamcmdSend tcCamCmdSend(sequenceCount);
|
2022-08-18 10:42:18 +02:00
|
|
|
// result = tcCamCmdSend.createPacket(commandData, commandDataLen);
|
2022-04-20 21:33:39 +02:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sequenceCount--;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
copyToCommandBuffer(&tcCamCmdSend);
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::TM_CAM_CMD_RPT;
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCFlashWriteAction* action) {
|
2022-07-27 23:09:05 +02:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
2022-07-27 22:03:41 +02:00
|
|
|
// if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
|
|
|
// return MPSoCReturnValuesIF::FILENAME_TOO_LONG;
|
|
|
|
// }
|
|
|
|
mpsoc::FlashWritePusCmd flashWritePusCmd;
|
2022-08-18 10:42:18 +02:00
|
|
|
// result = flashWritePusCmd.extractFields(data, size);
|
2022-07-27 22:03:41 +02:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
|
|
|
|
flashWritePusCmd.getMPSoCFile());
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
plocMPSoCHelperExecuting = true;
|
|
|
|
return EXECUTION_FINISHED;
|
|
|
|
}
|
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCUartTxTristateAction* action) {
|
|
|
|
// not used
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReleaseUartTxAction* action) {
|
|
|
|
// not used
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCObswResetSeqCountAction* action) {
|
|
|
|
// not used
|
2022-04-20 21:33:39 +02:00
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
2022-01-05 11:26:01 +01:00
|
|
|
void PlocMPSoCHandler::copyToCommandBuffer(mpsoc::TcBase* tc) {
|
2022-03-22 11:35:44 +01:00
|
|
|
if (tc == nullptr) {
|
|
|
|
sif::debug << "PlocMPSoCHandler::copyToCommandBuffer: Invalid TC" << std::endl;
|
|
|
|
}
|
|
|
|
memcpy(commandBuffer, tc->getWholeData(), tc->getFullSize());
|
|
|
|
rawPacket = commandBuffer;
|
|
|
|
rawPacketLen = tc->getFullSize();
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::ACK_REPORT;
|
2022-01-05 11:26:01 +01:00
|
|
|
}
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
|
2022-03-22 11:35:44 +01:00
|
|
|
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
|
|
|
|
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
|
|
|
|
if (receivedCrc != recalculatedCrc) {
|
|
|
|
return MPSoCReturnValuesIF::CRC_FAILURE;
|
|
|
|
}
|
|
|
|
return RETURN_OK;
|
2021-04-11 12:04:13 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
2021-04-15 13:17:15 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
|
|
|
|
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
2022-03-25 09:40:43 +01:00
|
|
|
sif::warning << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::NONE;
|
2022-03-22 11:35:44 +01:00
|
|
|
replyRawReplyIfnotWiretapped(data, mpsoc::SIZE_ACK_REPORT);
|
|
|
|
triggerEvent(MPSOC_HANDLER_CRC_FAILURE);
|
2022-07-27 22:03:41 +02:00
|
|
|
sendFailureReport(PlocMpSoCCommands::ACK_REPORT, MPSoCReturnValuesIF::CRC_FAILURE);
|
2022-03-22 11:35:44 +01:00
|
|
|
disableAllReplies();
|
|
|
|
return IGNORE_REPLY_DATA;
|
|
|
|
}
|
2021-04-15 13:17:15 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
|
|
|
|
|
|
|
switch (apid) {
|
|
|
|
case mpsoc::apid::ACK_FAILURE: {
|
|
|
|
sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl;
|
|
|
|
DeviceCommandId_t commandId = getPendingCommand();
|
2022-03-25 09:08:01 +01:00
|
|
|
uint16_t status = getStatus(data);
|
2022-05-25 18:38:54 +02:00
|
|
|
printStatus(data);
|
2022-03-22 11:35:44 +01:00
|
|
|
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
2022-03-25 09:08:01 +01:00
|
|
|
triggerEvent(ACK_FAILURE, commandId, status);
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
sendFailureReport(PlocMpSoCCommands::ACK_REPORT, status);
|
2022-03-22 11:35:44 +01:00
|
|
|
disableAllReplies();
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::NONE;
|
2022-03-22 11:35:44 +01:00
|
|
|
result = IGNORE_REPLY_DATA;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mpsoc::apid::ACK_SUCCESS: {
|
|
|
|
setNextReplyId();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl;
|
|
|
|
result = RETURN_FAILED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
return result;
|
2021-03-29 14:37:52 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
2021-04-15 13:17:15 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
|
|
|
|
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
2022-03-25 09:40:43 +01:00
|
|
|
sif::warning << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::NONE;
|
2022-03-22 11:35:44 +01:00
|
|
|
return result;
|
|
|
|
}
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
switch (apid) {
|
2022-01-05 11:26:01 +01:00
|
|
|
case (mpsoc::apid::EXE_SUCCESS): {
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
2021-04-11 12:04:13 +02:00
|
|
|
}
|
2022-01-05 11:26:01 +01:00
|
|
|
case (mpsoc::apid::EXE_FAILURE): {
|
2022-03-22 11:35:44 +01:00
|
|
|
// TODO: Interpretation of status field in execution report
|
2022-03-25 09:40:43 +01:00
|
|
|
sif::warning << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report"
|
2022-03-26 20:47:25 +01:00
|
|
|
<< std::endl;
|
2022-03-22 11:35:44 +01:00
|
|
|
DeviceCommandId_t commandId = getPendingCommand();
|
|
|
|
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
2022-03-26 20:47:25 +01:00
|
|
|
uint16_t status = getStatus(data);
|
2022-03-25 09:40:43 +01:00
|
|
|
triggerEvent(EXE_FAILURE, commandId, status);
|
2022-03-22 11:35:44 +01:00
|
|
|
} else {
|
|
|
|
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
|
|
|
|
}
|
2022-03-24 17:39:50 +01:00
|
|
|
printStatus(data);
|
2022-07-27 22:03:41 +02:00
|
|
|
sendFailureReport(PlocMpSoCCommands::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
|
2022-03-22 11:35:44 +01:00
|
|
|
disableExeReportReply();
|
|
|
|
result = IGNORE_REPLY_DATA;
|
|
|
|
break;
|
2021-04-11 12:04:13 +02:00
|
|
|
}
|
2021-04-22 17:32:39 +02:00
|
|
|
default: {
|
2022-03-25 09:40:43 +01:00
|
|
|
sif::warning << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl;
|
2022-03-22 11:35:44 +01:00
|
|
|
result = RETURN_FAILED;
|
|
|
|
break;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::NONE;
|
2022-03-22 11:35:44 +01:00
|
|
|
return result;
|
2021-04-11 12:04:13 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
|
2022-03-22 11:35:44 +01:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
result = verifyPacket(data, tmMemReadReport.rememberRequestedSize);
|
|
|
|
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
2022-03-25 09:40:43 +01:00
|
|
|
sif::warning << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc"
|
2022-03-26 20:47:25 +01:00
|
|
|
<< std::endl;
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
|
|
|
uint16_t memLen =
|
|
|
|
*(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8 | *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1);
|
|
|
|
/** Send data to commanding queue */
|
|
|
|
handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4,
|
2022-07-27 22:03:41 +02:00
|
|
|
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT));
|
|
|
|
nextReplyId = PlocMpSoCCommands::EXE_REPORT;
|
2022-03-22 11:35:44 +01:00
|
|
|
return result;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
|
|
|
|
2022-04-20 21:33:39 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
|
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
SpacePacket packet;
|
|
|
|
std::memcpy(packet.getWholeData(), data, tmCamCmdRpt.rememberSpacePacketSize);
|
|
|
|
result = verifyPacket(data, tmCamCmdRpt.rememberSpacePacketSize);
|
|
|
|
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
|
|
|
sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl;
|
|
|
|
}
|
2022-05-25 18:38:54 +02:00
|
|
|
const uint8_t* dataFieldPtr = data + mpsoc::SPACE_PACKET_HEADER_SIZE + sizeof(uint16_t);
|
2022-04-22 14:09:08 +02:00
|
|
|
std::string camCmdRptMsg(
|
|
|
|
reinterpret_cast<const char*>(dataFieldPtr),
|
2022-05-25 18:38:54 +02:00
|
|
|
tmCamCmdRpt.rememberSpacePacketSize - mpsoc::SPACE_PACKET_HEADER_SIZE - sizeof(uint16_t) - 3);
|
2022-05-04 19:08:37 +02:00
|
|
|
#if OBSW_DEBUG_PLOC_MPSOC == 1
|
2022-05-06 20:33:46 +02:00
|
|
|
uint8_t ackValue = *(packet.getPacketData() + packet.getPacketDataLength() - 2);
|
2022-05-04 19:08:37 +02:00
|
|
|
sif::info << "PlocMPSoCHandler: CamCmdRpt message: " << camCmdRptMsg << std::endl;
|
|
|
|
sif::info << "PlocMPSoCHandler: CamCmdRpt Ack value: 0x" << std::hex
|
|
|
|
<< static_cast<unsigned int>(ackValue) << std::endl;
|
|
|
|
#endif /* OBSW_DEBUG_PLOC_MPSOC == 1 */
|
2022-06-17 08:31:36 +02:00
|
|
|
handleDeviceTM(packet.getPacketData() + sizeof(uint16_t), packet.getPacketDataLength() - 1,
|
2022-07-27 22:03:41 +02:00
|
|
|
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT));
|
2022-04-20 21:33:39 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
2022-03-22 11:35:44 +01:00
|
|
|
uint8_t expectedReplies, bool useAlternateId,
|
|
|
|
DeviceCommandId_t alternateReplyID) {
|
|
|
|
ReturnValue_t result = RETURN_OK;
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
uint8_t enabledReplies = 0;
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCCommands enumCommand = PlocMpSoCCommands(command->first);
|
|
|
|
|
|
|
|
switch (enumCommand) {
|
|
|
|
case PlocMpSoCCommands::TC_MEM_WRITE:
|
|
|
|
case PlocMpSoCCommands::TC_FLASHDELETE:
|
|
|
|
case PlocMpSoCCommands::TC_REPLAY_START:
|
|
|
|
case PlocMpSoCCommands::TC_REPLAY_STOP:
|
|
|
|
case PlocMpSoCCommands::TC_DOWNLINK_PWR_ON:
|
|
|
|
case PlocMpSoCCommands::TC_DOWNLINK_PWR_OFF:
|
|
|
|
case PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE:
|
|
|
|
case PlocMpSoCCommands::TC_MODE_REPLAY:
|
|
|
|
case PlocMpSoCCommands::TC_MODE_IDLE:
|
2022-03-22 11:35:44 +01:00
|
|
|
enabledReplies = 2;
|
|
|
|
break;
|
2022-07-27 22:03:41 +02:00
|
|
|
case PlocMpSoCCommands::TC_MEM_READ: {
|
2022-03-22 11:35:44 +01:00
|
|
|
enabledReplies = 3;
|
2022-07-27 22:03:41 +02:00
|
|
|
result = DeviceHandlerBase::enableReplyInReplyMap(
|
|
|
|
command, enabledReplies, true,
|
|
|
|
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT));
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
|
2022-07-27 22:03:41 +02:00
|
|
|
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT)
|
|
|
|
<< " not in replyMap" << std::endl;
|
2022-04-20 21:33:39 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case PlocMpSoCCommands::TC_CAM_CMD_SEND: {
|
2022-04-20 21:33:39 +02:00
|
|
|
enabledReplies = 3;
|
2022-07-27 22:03:41 +02:00
|
|
|
result = DeviceHandlerBase::enableReplyInReplyMap(
|
|
|
|
command, enabledReplies, true,
|
|
|
|
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT));
|
2022-04-20 21:33:39 +02:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
|
2022-07-27 22:03:41 +02:00
|
|
|
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT)
|
|
|
|
<< " not in replyMap" << std::endl;
|
2022-04-20 21:33:39 +02:00
|
|
|
return result;
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case PlocMpSoCCommands::OBSW_RESET_SEQ_COUNT:
|
2022-03-25 09:08:01 +01:00
|
|
|
break;
|
2021-04-22 17:32:39 +02:00
|
|
|
default:
|
2022-03-22 11:35:44 +01:00
|
|
|
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
/**
|
|
|
|
* Every command causes at least one acknowledgment and one execution report. Therefore both
|
|
|
|
* replies will be enabled here.
|
|
|
|
*/
|
2022-07-27 22:03:41 +02:00
|
|
|
result = DeviceHandlerBase::enableReplyInReplyMap(
|
|
|
|
command, enabledReplies, true, static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT));
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != RETURN_OK) {
|
2022-07-27 22:03:41 +02:00
|
|
|
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
|
|
|
|
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT)
|
2022-03-22 11:35:44 +01:00
|
|
|
<< " not in replyMap" << std::endl;
|
|
|
|
}
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
result = DeviceHandlerBase::enableReplyInReplyMap(
|
|
|
|
command, enabledReplies, true, static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
|
2022-03-22 11:35:44 +01:00
|
|
|
if (result != RETURN_OK) {
|
2022-07-27 22:03:41 +02:00
|
|
|
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
|
|
|
|
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT)
|
2022-03-22 11:35:44 +01:00
|
|
|
<< " not in replyMap" << std::endl;
|
|
|
|
}
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
switch (enumCommand) {
|
|
|
|
case PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE: {
|
|
|
|
DeviceReplyIter iter =
|
|
|
|
deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
|
2022-03-26 20:47:25 +01:00
|
|
|
// Overwrite delay cycles because replay write sequence command can required up to
|
|
|
|
// 30 seconds for execution
|
|
|
|
iter->second.delayCycles = mpsoc::TC_WRITE_SEQ_EXECUTION_DELAY;
|
|
|
|
break;
|
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case PlocMpSoCCommands::TC_DOWNLINK_PWR_ON: {
|
|
|
|
DeviceReplyIter iter =
|
|
|
|
deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
|
2022-03-26 20:47:25 +01:00
|
|
|
//
|
2022-07-27 22:03:41 +02:00
|
|
|
iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON_EXECUTION_DELAY;
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
2022-03-21 16:21:51 +01:00
|
|
|
}
|
|
|
|
default:
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
|
|
|
}
|
2022-03-21 16:21:51 +01:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
return RETURN_OK;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
void PlocMPSoCHandler::setNextReplyId() {
|
2022-07-27 22:03:41 +02:00
|
|
|
switch (PlocMpSoCCommands(getPendingCommand())) {
|
|
|
|
case PlocMpSoCCommands::TC_MEM_READ:
|
|
|
|
nextReplyId = PlocMpSoCCommands::TM_MEMORY_READ_REPORT;
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
2021-04-22 17:32:39 +02:00
|
|
|
default:
|
2022-03-22 11:35:44 +01:00
|
|
|
/* If no telemetry is expected the next reply is always the execution report */
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::EXE_REPORT;
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
|
|
|
}
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
|
|
|
|
size_t replyLen = 0;
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
if (nextReplyId == PlocMpSoCCommands::NONE) {
|
2022-03-22 11:35:44 +01:00
|
|
|
return replyLen;
|
|
|
|
}
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
DeviceReplyIter iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(nextReplyId));
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
if (iter != deviceReplyMap.end()) {
|
|
|
|
if (iter->second.delayCycles == 0) {
|
|
|
|
/* Reply inactive */
|
|
|
|
return replyLen;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
switch (nextReplyId) {
|
2022-07-27 22:03:41 +02:00
|
|
|
case PlocMpSoCCommands::TM_MEMORY_READ_REPORT: {
|
2022-03-22 11:35:44 +01:00
|
|
|
replyLen = tmMemReadReport.rememberRequestedSize;
|
|
|
|
break;
|
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case PlocMpSoCCommands::TM_CAM_CMD_RPT:
|
2022-04-21 09:31:52 +02:00
|
|
|
// Read acknowledgment, camera and execution report in one go because length of camera
|
|
|
|
// report is not fixed
|
2022-04-20 21:33:39 +02:00
|
|
|
replyLen = SpacePacket::PACKET_MAX_SIZE;
|
|
|
|
break;
|
2022-03-22 11:35:44 +01:00
|
|
|
default: {
|
|
|
|
replyLen = iter->second.replyLen;
|
|
|
|
break;
|
|
|
|
}
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
} else {
|
|
|
|
sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id "
|
2022-07-27 22:03:41 +02:00
|
|
|
<< std::hex << static_cast<DeviceCommandId_t>(nextReplyId) << " in deviceReplyMap"
|
|
|
|
<< std::endl;
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
return replyLen;
|
2021-04-11 12:04:13 +02:00
|
|
|
}
|
|
|
|
|
2022-05-02 09:56:15 +02:00
|
|
|
ReturnValue_t PlocMPSoCHandler::doSendReadHook() {
|
|
|
|
// Prevent DHB from polling UART during commands executed by the mpsoc helper task
|
|
|
|
if (plocMPSoCHelperExecuting) {
|
|
|
|
return RETURN_FAILED;
|
|
|
|
}
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
2022-04-04 13:40:45 +02:00
|
|
|
MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() { return commandActionHelperQueue; }
|
2022-03-30 09:19:30 +02:00
|
|
|
|
2022-04-04 13:40:45 +02:00
|
|
|
void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; }
|
2022-03-30 09:19:30 +02:00
|
|
|
|
|
|
|
void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
2022-04-04 13:40:45 +02:00
|
|
|
ReturnValue_t returnCode) {
|
|
|
|
switch (actionId) {
|
2022-05-03 14:59:23 +02:00
|
|
|
case supv::START_MPSOC: {
|
2022-04-04 13:40:45 +02:00
|
|
|
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC" << std::endl;
|
2022-05-03 14:59:23 +02:00
|
|
|
// This usually happens when the supervisor handler is in off mode
|
2022-04-04 13:40:45 +02:00
|
|
|
powerState = PowerState::OFF;
|
2022-05-03 14:59:23 +02:00
|
|
|
setMode(MODE_OFF);
|
2022-04-04 13:40:45 +02:00
|
|
|
break;
|
2022-05-03 14:59:23 +02:00
|
|
|
}
|
|
|
|
case supv::SHUTDOWN_MPSOC: {
|
2022-04-04 13:40:45 +02:00
|
|
|
triggerEvent(MPSOC_SHUTDOWN_FAILED);
|
|
|
|
sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC" << std::endl;
|
2022-05-02 09:56:15 +02:00
|
|
|
powerState = PowerState::OFF;
|
2022-04-04 13:40:45 +02:00
|
|
|
break;
|
2022-05-03 14:59:23 +02:00
|
|
|
}
|
2022-04-04 13:40:45 +02:00
|
|
|
default:
|
|
|
|
sif::debug << "PlocMPSoCHandler::stepFailedReceived: Received unexpected action reply"
|
|
|
|
<< std::endl;
|
|
|
|
break;
|
|
|
|
}
|
2022-03-30 09:19:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
2022-04-04 13:40:45 +02:00
|
|
|
return;
|
2022-03-30 09:19:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) {
|
2022-04-04 13:40:45 +02:00
|
|
|
if (actionId != supv::EXE_REPORT) {
|
|
|
|
sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action "
|
|
|
|
<< "ID" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (powerState) {
|
2022-03-31 11:50:33 +02:00
|
|
|
case PowerState::BOOTING: {
|
2022-04-04 13:40:45 +02:00
|
|
|
powerState = PowerState::ON;
|
|
|
|
break;
|
2022-03-30 09:19:30 +02:00
|
|
|
}
|
2022-03-31 11:50:33 +02:00
|
|
|
case PowerState::SHUTDOWN: {
|
2022-04-04 13:40:45 +02:00
|
|
|
powerState = PowerState::OFF;
|
|
|
|
break;
|
2022-03-31 11:50:33 +02:00
|
|
|
}
|
|
|
|
default: {
|
2022-03-30 09:19:30 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-04-04 13:40:45 +02:00
|
|
|
}
|
2022-03-30 09:19:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
2022-04-04 13:40:45 +02:00
|
|
|
handleActionCommandFailure(actionId);
|
2022-03-30 09:19:30 +02:00
|
|
|
}
|
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
|
|
|
|
DeviceCommandId_t replyId) {
|
|
|
|
ReturnValue_t result = RETURN_OK;
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
if (wiretappingMode == RAW) {
|
|
|
|
/* Data already sent in doGetRead() */
|
|
|
|
return;
|
|
|
|
}
|
2021-04-25 15:54:48 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
|
|
|
|
if (iter == deviceReplyMap.end()) {
|
|
|
|
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
if (queueId == NO_COMMANDER) {
|
|
|
|
return;
|
|
|
|
}
|
2021-04-11 12:04:13 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
result = actionHelper.reportData(queueId, replyId, data, dataSize);
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl;
|
|
|
|
}
|
2021-03-29 14:37:52 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
void PlocMPSoCHandler::disableAllReplies() {
|
2022-03-22 11:35:44 +01:00
|
|
|
DeviceReplyMap::iterator iter;
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
/* Disable ack reply */
|
2022-07-27 22:03:41 +02:00
|
|
|
iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT));
|
2022-03-22 11:35:44 +01:00
|
|
|
DeviceReplyInfo* info = &(iter->second);
|
|
|
|
info->delayCycles = 0;
|
|
|
|
info->command = deviceCommandMap.end();
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
DeviceCommandId_t commandId = getPendingCommand();
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
PlocMpSoCCommands enumCommand = PlocMpSoCCommands(commandId);
|
|
|
|
|
2022-03-22 11:35:44 +01:00
|
|
|
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
|
2022-07-27 22:03:41 +02:00
|
|
|
switch (enumCommand) {
|
|
|
|
case PlocMpSoCCommands::TC_MEM_WRITE:
|
2022-03-22 11:35:44 +01:00
|
|
|
break;
|
2022-07-27 22:03:41 +02:00
|
|
|
case PlocMpSoCCommands::TC_MEM_READ: {
|
|
|
|
iter = deviceReplyMap.find(
|
|
|
|
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT));
|
2022-05-04 19:08:37 +02:00
|
|
|
info = &(iter->second);
|
|
|
|
info->delayCycles = 0;
|
|
|
|
info->active = false;
|
|
|
|
info->command = deviceCommandMap.end();
|
|
|
|
break;
|
|
|
|
}
|
2022-07-27 22:03:41 +02:00
|
|
|
case PlocMpSoCCommands::TC_CAM_CMD_SEND: {
|
|
|
|
iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT));
|
2022-03-22 11:35:44 +01:00
|
|
|
info = &(iter->second);
|
|
|
|
info->delayCycles = 0;
|
2022-05-04 19:08:37 +02:00
|
|
|
info->active = false;
|
2022-03-22 11:35:44 +01:00
|
|
|
info->command = deviceCommandMap.end();
|
|
|
|
break;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
|
|
|
default: {
|
2022-05-04 19:08:37 +02:00
|
|
|
sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id: " << commandId
|
2022-03-22 11:35:44 +01:00
|
|
|
<< std::endl;
|
|
|
|
break;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-03-22 11:35:44 +01:00
|
|
|
}
|
2021-04-22 17:32:39 +02:00
|
|
|
|
2022-03-31 11:50:33 +02:00
|
|
|
/* We always need to disable the execution report reply here */
|
2022-03-22 11:35:44 +01:00
|
|
|
disableExeReportReply();
|
2022-07-27 22:03:41 +02:00
|
|
|
nextReplyId = PlocMpSoCCommands::NONE;
|
2021-03-29 14:37:52 +02:00
|
|
|
}
|
|
|
|
|
2022-07-27 22:03:41 +02:00
|
|
|
void PlocMPSoCHandler::sendFailureReport(PlocMpSoCCommands replyId, ReturnValue_t status) {
|
|
|
|
DeviceReplyIter iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(replyId));
|
2022-03-22 11:35:44 +01:00
|
|
|
if (iter == deviceReplyMap.end()) {
|
|
|
|
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DeviceCommandInfo* info = &(iter->second.command->second);
|
|
|
|
if (info == nullptr) {
|
|
|
|
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (info->sendReplyTo != NO_COMMANDER) {
|
|
|
|
actionHelper.finish(false, info->sendReplyTo, iter->first, status);
|
|
|
|
}
|
|
|
|
info->isExecuting = false;
|
2021-03-29 14:37:52 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 08:32:14 +02:00
|
|
|
void PlocMPSoCHandler::disableExeReportReply() {
|
2022-07-27 22:03:41 +02:00
|
|
|
DeviceReplyIter iter =
|
|
|
|
deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
|
2022-03-22 11:35:44 +01:00
|
|
|
DeviceReplyInfo* info = &(iter->second);
|
|
|
|
info->delayCycles = 0;
|
|
|
|
info->command = deviceCommandMap.end();
|
2022-03-26 20:47:25 +01:00
|
|
|
/* Expected replies is set to one here. The value will be set to 0 in replyToReply() */
|
2022-03-22 11:35:44 +01:00
|
|
|
info->command->second.expectedReplies = 0;
|
2021-04-22 17:32:39 +02:00
|
|
|
}
|
2022-03-24 17:39:50 +01:00
|
|
|
|
|
|
|
void PlocMPSoCHandler::printStatus(const uint8_t* data) {
|
2022-03-25 09:08:01 +01:00
|
|
|
uint16_t status = *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1);
|
2022-06-17 08:31:36 +02:00
|
|
|
sif::info << "Verification report status: " << getStatusString(status) << std::endl;
|
2022-03-24 17:39:50 +01:00
|
|
|
}
|
|
|
|
|
2022-03-25 09:40:43 +01:00
|
|
|
uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) {
|
2022-03-26 20:47:25 +01:00
|
|
|
return *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1);
|
2022-03-25 09:08:01 +01:00
|
|
|
}
|
2022-03-30 09:19:30 +02:00
|
|
|
|
|
|
|
void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
|
|
|
|
switch (actionId) {
|
2022-03-31 11:50:33 +02:00
|
|
|
case supv::ACK_REPORT:
|
|
|
|
case supv::EXE_REPORT:
|
2022-04-04 13:40:45 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect this action ID "
|
|
|
|
<< std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (powerState) {
|
|
|
|
case PowerState::BOOTING: {
|
2022-05-03 14:59:23 +02:00
|
|
|
sif::info << "PlocMPSoCHandler::handleActionCommandFailure: MPSoC boot command failed"
|
2022-05-06 19:53:33 +02:00
|
|
|
<< std::endl;
|
2022-05-03 14:59:23 +02:00
|
|
|
// This is commonly the case when the MPSoC is already operational. Thus the power state is
|
|
|
|
// set to on here
|
|
|
|
powerState = PowerState::ON;
|
2022-04-04 13:40:45 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PowerState::SHUTDOWN: {
|
2022-05-03 14:59:23 +02:00
|
|
|
// FDIR will intercept event and switch PLOC power off
|
|
|
|
triggerEvent(MPSOC_SHUTDOWN_FAILED);
|
2022-04-04 13:40:45 +02:00
|
|
|
sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC"
|
|
|
|
<< std::endl;
|
2022-05-03 14:59:23 +02:00
|
|
|
powerState = PowerState::OFF;
|
2022-04-04 13:40:45 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-03-30 09:19:30 +02:00
|
|
|
default:
|
2022-04-04 13:40:45 +02:00
|
|
|
break;
|
2022-03-30 09:19:30 +02:00
|
|
|
}
|
2022-03-31 11:50:33 +02:00
|
|
|
return;
|
2022-03-30 09:19:30 +02:00
|
|
|
}
|
2022-05-25 18:38:54 +02:00
|
|
|
|
|
|
|
std::string PlocMPSoCHandler::getStatusString(uint16_t status) {
|
2022-06-17 08:31:36 +02:00
|
|
|
switch (status) {
|
|
|
|
case (mpsoc::status_code::UNKNOWN_APID): {
|
|
|
|
return "Unknown APID";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::INCORRECT_LENGTH): {
|
|
|
|
return "Incorrect length";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::INCORRECT_CRC): {
|
|
|
|
return "Incorrect crc";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::INCORRECT_PKT_SEQ_CNT): {
|
|
|
|
return "Incorrect packet sequence count";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::TC_NOT_ALLOWED_IN_MODE): {
|
|
|
|
return "TC not allowed in this mode";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::TC_EXEUTION_DISABLED): {
|
|
|
|
return "TC execution disabled";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::FLASH_MOUNT_FAILED): {
|
|
|
|
return "Flash mount failed";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): {
|
|
|
|
return "Flash file already closed";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): {
|
|
|
|
return "Flash file not open";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::FLASH_UNMOUNT_FAILED): {
|
|
|
|
return "Flash unmount failed";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::HEAP_ALLOCATION_FAILED): {
|
|
|
|
return "Heap allocation failed";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::INVALID_PARAMETER): {
|
|
|
|
return "Invalid parameter";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::NOT_INITIALIZED): {
|
|
|
|
return "Not initialized";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::REBOOT_IMMINENT): {
|
|
|
|
return "Reboot imminent";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::CORRUPT_DATA): {
|
|
|
|
return "Corrupt data";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::FLASH_CORRECTABLE_MISMATCH): {
|
|
|
|
return "Flash correctable mismatch";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (mpsoc::status_code::FLASH_UNCORRECTABLE_MISMATCH): {
|
|
|
|
return "Flash uncorrectable mismatch";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return "";
|
2022-05-25 18:38:54 +02:00
|
|
|
}
|