eive-obsw/bsp_q7s/devices/ploc/PlocMPSoCHandler.cpp

547 lines
17 KiB
C++
Raw Normal View History

2022-01-05 11:26:01 +01:00
#include "../../bsp_q7s/devices/ploc/PlocMPSoCHandler.h"
2021-05-17 16:37:29 +02:00
#include "OBSWConfig.h"
2021-03-29 14:37:52 +02:00
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/datapool/PoolReadGuard.h>
2022-01-03 08:01:55 +01:00
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
CookieIF * comCookie) :
DeviceHandlerBase(objectId, uartComIFid, comCookie) {
2021-03-29 14:37:52 +02:00
if (comCookie == NULL) {
sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl;
2021-03-29 14:37:52 +02:00
}
}
PlocMPSoCHandler::~PlocMPSoCHandler() {
2021-03-29 14:37:52 +02:00
}
2022-01-03 08:01:55 +01:00
ReturnValue_t PlocMPSoCHandler::initialize() {
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;
}
return result;
}
2021-03-29 14:37:52 +02:00
void PlocMPSoCHandler::doStartUp(){
2022-01-03 08:01:55 +01:00
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
setMode(MODE_NORMAL);
#else
setMode(_MODE_TO_ON);
#endif
2021-03-29 14:37:52 +02:00
}
void PlocMPSoCHandler::doShutDown(){
setMode(_MODE_POWER_DOWN);
2021-03-29 14:37:52 +02:00
}
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(
2021-03-29 14:37:52 +02:00
DeviceCommandId_t * id) {
2022-01-03 08:01:55 +01:00
return NOTHING_TO_SEND;
2021-03-29 14:37:52 +02:00
}
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(
2021-03-29 14:37:52 +02:00
DeviceCommandId_t * id){
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(
2021-03-29 14:37:52 +02:00
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
size_t commandDataLen) {
2022-01-03 08:01:55 +01:00
ReturnValue_t result = RETURN_OK;
2021-03-29 14:37:52 +02:00
switch(deviceCommand) {
2022-01-05 11:26:01 +01:00
case(mpsoc::TC_MEM_WRITE): {
2022-01-03 08:01:55 +01:00
result = prepareTcMemWriteCommand(commandData, commandDataLen);
break;
2021-03-29 14:37:52 +02:00
}
2022-01-05 11:26:01 +01:00
case(mpsoc::TC_MEM_READ): {
2022-01-03 08:01:55 +01:00
result = prepareTcMemReadCommand(commandData, commandDataLen);
break;
2021-03-29 14:37:52 +02:00
}
2022-01-05 11:26:01 +01:00
case(mpsoc::TC_FLASHFOPEN): {
result = prepareFlashFopenCmd(commandData, commandDataLen);
break;
}
2022-01-06 10:12:08 +01:00
case(mpsoc::TC_FLASHFCLOSE): {
result = prepareFlashFcloseCmd(commandData, commandDataLen);
break;
}
2021-03-29 14:37:52 +02:00
default:
sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl;
2022-01-03 08:01:55 +01:00
result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
break;
2021-03-29 14:37:52 +02:00
}
2022-01-03 08:01:55 +01:00
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;
2021-03-29 14:37:52 +02:00
}
void PlocMPSoCHandler::fillCommandAndReplyMap() {
2022-01-05 11:26:01 +01:00
this->insertInCommandMap(mpsoc::TC_MEM_WRITE);
this->insertInCommandMap(mpsoc::TC_MEM_READ);
this->insertInCommandMap(mpsoc::TC_FLASHFOPEN);
2022-01-06 10:12:08 +01:00
this->insertInCommandMap(mpsoc::TC_FLASHFCLOSE);
2022-01-05 11:26:01 +01:00
this->insertInReplyMap(mpsoc::ACK_REPORT, 1, nullptr, mpsoc::SIZE_ACK_REPORT);
this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT);
this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
}
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start,
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
ReturnValue_t result = RETURN_OK;
uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK;
switch(apid) {
2022-01-05 11:26:01 +01:00
case(mpsoc::apid::ACK_SUCCESS):
*foundLen = mpsoc::SIZE_ACK_REPORT;
*foundId = mpsoc::ACK_REPORT;
break;
2022-01-05 11:26:01 +01:00
case(mpsoc::apid::ACK_FAILURE):
*foundLen = mpsoc::SIZE_ACK_REPORT;
*foundId = mpsoc::ACK_REPORT;
break;
2022-01-05 11:26:01 +01:00
case(mpsoc::apid::TM_MEMORY_READ_REPORT):
*foundLen = mpsoc::SIZE_TM_MEM_READ_REPORT;
*foundId = mpsoc::TM_MEMORY_READ_REPORT;
break;
2022-01-05 11:26:01 +01:00
case(mpsoc::apid::EXE_SUCCESS):
*foundLen = mpsoc::SIZE_EXE_REPORT;
*foundId = mpsoc::EXE_REPORT;
break;
2022-01-05 11:26:01 +01:00
case(mpsoc::apid::EXE_FAILURE):
*foundLen = mpsoc::SIZE_EXE_REPORT;
*foundId = mpsoc::EXE_REPORT;
break;
default: {
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl;
*foundLen = remainingSize;
return INVALID_APID;
}
}
result = checkPacketSequenceCount(start);
return result;
}
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
ReturnValue_t result = RETURN_OK;
switch (id) {
2022-01-05 11:26:01 +01:00
case mpsoc::ACK_REPORT: {
result = handleAckReport(packet);
break;
}
2022-01-05 11:26:01 +01:00
case (mpsoc::TM_MEMORY_READ_REPORT): {
result = handleMemoryReadReport(packet);
break;
}
2022-01-05 11:26:01 +01:00
case (mpsoc::EXE_REPORT): {
result = handleExecutionReport(packet);
break;
}
default: {
sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl;
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
}
return result;
}
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid(){
}
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
return 500;
}
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
return HasReturnvaluesIF::RETURN_OK;
}
void PlocMPSoCHandler::setModeNormal() {
mode = MODE_NORMAL;
}
ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * commandData,
2021-04-15 13:17:15 +02:00
size_t commandDataLen) {
2022-01-06 10:12:08 +01:00
ReturnValue_t result = RETURN_OK;
2021-04-27 17:34:50 +02:00
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
2022-01-06 10:12:08 +01:00
mpsoc::TcMemWrite tcMemWrite(packetSequenceCount);
result = tcMemWrite.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
return result;
2021-04-15 13:17:15 +02:00
}
2022-01-06 10:12:08 +01:00
copyToCommandBuffer(&tcMemWrite);
2021-04-15 13:17:15 +02:00
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t * commandData,
2021-04-15 13:17:15 +02:00
size_t commandDataLen) {
2022-01-06 10:12:08 +01:00
ReturnValue_t result = RETURN_OK;
2021-04-27 17:34:50 +02:00
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
2022-01-06 10:12:08 +01:00
mpsoc::TcMemRead tcMemRead(packetSequenceCount);
result = tcMemRead.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
return result;
2021-04-15 13:17:15 +02:00
}
2022-01-06 10:12:08 +01:00
copyToCommandBuffer(&tcMemRead);
2021-04-15 13:17:15 +02:00
return RETURN_OK;
}
2022-01-05 11:26:01 +01:00
ReturnValue_t PlocMPSoCHandler::prepareFlashFopenCmd(const uint8_t * commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
mpsoc::FlashFopen flashFopen(packetSequenceCount);
result = flashFopen.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
return result;
}
copyToCommandBuffer(&flashFopen);
return RETURN_OK;
}
2022-01-06 10:12:08 +01:00
ReturnValue_t PlocMPSoCHandler::prepareFlashFcloseCmd(const uint8_t * commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK;
mpsoc::FlashFclose flashFclose(packetSequenceCount);
result = flashFclose.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
return result;
}
copyToCommandBuffer(&flashFclose);
return RETURN_OK;
}
2022-01-05 11:26:01 +01:00
void PlocMPSoCHandler::copyToCommandBuffer(mpsoc::TcBase* tc) {
if (tc == nullptr) {
sif::debug << "PlocMPSoCHandler::copyToCommandBuffer: Invalid TC" << std::endl;
}
memcpy(commandBuffer, tc->getWholeData(), tc->getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tc->getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
}
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
2021-04-15 13:17:15 +02:00
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
2021-04-26 11:28:19 +02:00
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
2021-04-15 13:17:15 +02:00
if (receivedCrc != recalculatedCrc) {
2021-04-11 12:04:13 +02:00
return CRC_FAILURE;
}
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
2021-04-15 13:17:15 +02:00
ReturnValue_t result = RETURN_OK;
2021-04-15 13:17:15 +02:00
2022-01-05 11:26:01 +01:00
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
if(result == CRC_FAILURE) {
sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
2022-01-05 11:26:01 +01:00
nextReplyId = mpsoc::NONE;
replyRawReplyIfnotWiretapped(data, mpsoc::SIZE_ACK_REPORT);
triggerEvent(CRC_FAILURE_EVENT);
2022-01-05 11:26:01 +01:00
sendFailureReport(mpsoc::ACK_REPORT, CRC_FAILURE);
disableAllReplies();
return IGNORE_REPLY_DATA;
2021-04-15 13:17:15 +02:00
}
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
switch(apid) {
2022-01-05 11:26:01 +01:00
case mpsoc::apid::ACK_FAILURE: {
//TODO: Interpretation of status field in acknowledgment report
sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl;
DeviceCommandId_t commandId = getPendingCommand();
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(ACK_FAILURE, commandId);
}
2022-01-05 11:26:01 +01:00
sendFailureReport(mpsoc::ACK_REPORT, RECEIVED_ACK_FAILURE);
disableAllReplies();
2022-01-05 11:26:01 +01:00
nextReplyId = mpsoc::NONE;
result = IGNORE_REPLY_DATA;
break;
}
2022-01-05 11:26:01 +01:00
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
return result;
2021-03-29 14:37:52 +02:00
}
ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
2021-04-15 13:17:15 +02:00
ReturnValue_t result = RETURN_OK;
2022-01-05 11:26:01 +01:00
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
if(result == CRC_FAILURE) {
sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
2022-01-05 11:26:01 +01:00
nextReplyId = mpsoc::NONE;
2021-04-15 13:17:15 +02:00
return result;
2021-04-11 12:04:13 +02:00
}
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
2021-04-11 12:04:13 +02:00
switch (apid) {
2022-01-05 11:26:01 +01:00
case (mpsoc::apid::EXE_SUCCESS): {
break;
2021-04-11 12:04:13 +02:00
}
2022-01-05 11:26:01 +01:00
case (mpsoc::apid::EXE_FAILURE): {
2021-04-11 12:04:13 +02:00
//TODO: Interpretation of status field in execution report
sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report"
2021-04-11 12:04:13 +02:00
<< std::endl;
DeviceCommandId_t commandId = getPendingCommand();
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(EXE_FAILURE, commandId);
}
else {
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
}
2022-01-05 11:26:01 +01:00
sendFailureReport(mpsoc::EXE_REPORT, RECEIVED_EXE_FAILURE);
disableExeReportReply();
result = IGNORE_REPLY_DATA;
break;
2021-04-11 12:04:13 +02:00
}
default: {
sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl;
result = RETURN_FAILED;
break;
2021-04-11 12:04:13 +02:00
}
}
2022-01-05 11:26:01 +01:00
nextReplyId = mpsoc::NONE;
return result;
2021-04-11 12:04:13 +02:00
}
ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
ReturnValue_t result = RETURN_OK;
2022-01-05 11:26:01 +01:00
result = verifyPacket(data, mpsoc::SIZE_TM_MEM_READ_REPORT);
if(result == CRC_FAILURE) {
sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc"
2021-04-11 12:04:13 +02:00
<< std::endl;
}
/** Send data to commanding queue */
2022-01-05 11:26:01 +01:00
handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_REPORT_DATA,
mpsoc::TM_MEMORY_READ_REPORT);
nextReplyId = mpsoc::EXE_REPORT;
return result;
}
ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies, bool useAlternateId,
DeviceCommandId_t alternateReplyID) {
ReturnValue_t result = RETURN_OK;
uint8_t enabledReplies = 0;
switch (command->first) {
2022-01-05 11:26:01 +01:00
case mpsoc::TC_MEM_WRITE:
case mpsoc::TC_FLASHFOPEN:
2022-01-06 10:12:08 +01:00
case mpsoc::TC_FLASHFCLOSE:
enabledReplies = 2;
break;
2022-01-05 11:26:01 +01:00
case mpsoc::TC_MEM_READ: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
2022-01-05 11:26:01 +01:00
mpsoc::TM_MEMORY_READ_REPORT);
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
2022-01-05 11:26:01 +01:00
<< mpsoc::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl;
}
break;
}
default:
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl;
break;
}
/**
* Every command causes at least one acknowledgment and one execution report. Therefore both
* replies will be enabled here.
*/
result = DeviceHandlerBase::enableReplyInReplyMap(command,
2022-01-05 11:26:01 +01:00
enabledReplies, true, mpsoc::ACK_REPORT);
2021-04-11 12:04:13 +02:00
if (result != RETURN_OK) {
2022-01-05 11:26:01 +01:00
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::ACK_REPORT
<< " not in replyMap" << std::endl;
2021-04-11 12:04:13 +02:00
}
result = DeviceHandlerBase::enableReplyInReplyMap(command,
2022-01-05 11:26:01 +01:00
enabledReplies, true, mpsoc::EXE_REPORT);
if (result != RETURN_OK) {
2022-01-05 11:26:01 +01:00
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::EXE_REPORT
<< " not in replyMap" << std::endl;
2021-04-11 12:04:13 +02:00
}
return RETURN_OK;
}
void PlocMPSoCHandler::setNextReplyId() {
switch(getPendingCommand()) {
2022-01-05 11:26:01 +01:00
case mpsoc::TC_MEM_READ:
nextReplyId = mpsoc::TM_MEMORY_READ_REPORT;
break;
default:
/* If no telemetry is expected the next reply is always the execution report */
2022-01-05 11:26:01 +01:00
nextReplyId = mpsoc::EXE_REPORT;
break;
}
}
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){
size_t replyLen = 0;
2022-01-05 11:26:01 +01:00
if (nextReplyId == mpsoc::NONE) {
return replyLen;
2021-04-11 12:04:13 +02:00
}
DeviceReplyIter iter = deviceReplyMap.find(nextReplyId);
if (iter != deviceReplyMap.end()) {
if (iter->second.delayCycles == 0) {
/* Reply inactive */
return replyLen;
}
replyLen = iter->second.replyLen;
}
else {
sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id "
<< std::hex << nextReplyId << " in deviceReplyMap" << std::endl;
}
2021-04-11 12:04:13 +02:00
return replyLen;
2021-04-11 12:04:13 +02:00
}
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) {
2021-04-11 12:04:13 +02:00
ReturnValue_t result = RETURN_OK;
if (wiretappingMode == RAW) {
/* Data already sent in doGetRead() */
2021-04-26 17:50:36 +02:00
return;
}
2021-04-11 12:04:13 +02:00
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) {
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl;
2021-04-11 12:04:13 +02:00
return;
}
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
if (queueId == NO_COMMANDER) {
return;
}
2021-04-12 10:16:59 +02:00
result = actionHelper.reportData(queueId, replyId, data, dataSize);
2021-04-11 12:04:13 +02:00
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl;
2021-04-11 12:04:13 +02:00
}
2021-03-29 14:37:52 +02:00
}
void PlocMPSoCHandler::disableAllReplies() {
2021-03-29 14:37:52 +02:00
DeviceReplyMap::iterator iter;
2021-03-29 14:37:52 +02:00
/* Disable ack reply */
2022-01-05 11:26:01 +01:00
iter = deviceReplyMap.find(mpsoc::ACK_REPORT);
DeviceReplyInfo *info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
2021-03-29 14:37:52 +02:00
DeviceCommandId_t commandId = getPendingCommand();
2021-03-29 14:37:52 +02:00
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
switch (commandId) {
2022-01-05 11:26:01 +01:00
case mpsoc::TC_MEM_WRITE:
case mpsoc::TC_FLASHFOPEN:
break;
2022-01-05 11:26:01 +01:00
case mpsoc::TC_MEM_READ: {
iter = deviceReplyMap.find(mpsoc::TM_MEMORY_READ_REPORT);
info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
break;
}
default: {
sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId
<< std::endl;
break;
}
}
/* We must always disable the execution report reply here */
disableExeReportReply();
2021-03-29 14:37:52 +02:00
}
void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
DeviceReplyIter iter = deviceReplyMap.find(replyId);
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
}
void PlocMPSoCHandler::disableExeReportReply() {
2022-01-05 11:26:01 +01:00
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
DeviceReplyInfo *info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
/* Expected replies is set to one here. The value will set to 0 in replyToReply() */
info->command->second.expectedReplies = 0;
}
ReturnValue_t PlocMPSoCHandler::checkPacketSequenceCount(const uint8_t* data) {
2022-01-03 08:01:55 +01:00
uint16_t receivedSeqCnt = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK;
uint16_t expectedSeqCnt = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK);
if (receivedSeqCnt != expectedSeqCnt) {
sif::warning << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count "
"mismatch. Received: " << receivedSeqCnt << ", Expected: "
<< expectedSeqCnt << std::endl;
triggerEvent(SEQ_CNT_MISMATCH, expectedSeqCnt, receivedSeqCnt);
}
packetSequenceCount = receivedSeqCnt;
return RETURN_OK;
}