restructured flash write command
This commit is contained in:
parent
05b43d4d72
commit
78b3f28188
@ -13,8 +13,6 @@ enum commonClassIds: uint8_t {
|
|||||||
IMTQ_HANDLER, //IMTQ
|
IMTQ_HANDLER, //IMTQ
|
||||||
RW_HANDLER, //RWHA
|
RW_HANDLER, //RWHA
|
||||||
STR_HANDLER, //STRH
|
STR_HANDLER, //STRH
|
||||||
PLOC_MPSOC_HANDLER, //PLMP
|
|
||||||
MPSOC_CMD, //MPCMD
|
|
||||||
DWLPWRON_CMD, //DWLPWRON
|
DWLPWRON_CMD, //DWLPWRON
|
||||||
MPSOC_TM, //MPTM
|
MPSOC_TM, //MPTM
|
||||||
PLOC_SUPERVISOR_HANDLER, //PLSV
|
PLOC_SUPERVISOR_HANDLER, //PLSV
|
||||||
@ -33,6 +31,7 @@ enum commonClassIds: uint8_t {
|
|||||||
FILE_SYSTEM_HELPER, //FSHLP
|
FILE_SYSTEM_HELPER, //FSHLP
|
||||||
PLOC_MPSOC_HELPER, // PLMPHLP
|
PLOC_MPSOC_HELPER, // PLMPHLP
|
||||||
SA_DEPL_HANDLER, //SADPL
|
SA_DEPL_HANDLER, //SADPL
|
||||||
|
MPSOC_RETURN_VALUES_IF, //MPSOCRTVIF
|
||||||
COMMON_CLASS_ID_END // [EXPORT] : [END]
|
COMMON_CLASS_ID_END // [EXPORT] : [END]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
30
linux/devices/devicedefinitions/MPSoCReturnValuesIF.h
Normal file
30
linux/devices/devicedefinitions/MPSoCReturnValuesIF.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef MPSOC_RETURN_VALUES_IF_H_
|
||||||
|
#define MPSOC_RETURN_VALUES_IF_H_
|
||||||
|
|
||||||
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
|
class MPSoCReturnValuesIF {
|
||||||
|
public:
|
||||||
|
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_RETURN_VALUES_IF;
|
||||||
|
|
||||||
|
//! [EXPORT] : [COMMENT] Space Packet received from PLOC has invalid CRC
|
||||||
|
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
|
||||||
|
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC
|
||||||
|
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1);
|
||||||
|
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC
|
||||||
|
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2);
|
||||||
|
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC
|
||||||
|
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
|
||||||
|
//! [EXPORT] : [COMMENT] Received command with invalid length
|
||||||
|
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xA4);
|
||||||
|
//! [EXPORT] : [COMMENT] Filename of file in OBC filesystem is too long
|
||||||
|
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA5);
|
||||||
|
//! [EXPORT] : [COMMENT] MPSoC helper is currently executing a command
|
||||||
|
static const ReturnValue_t MPSOC_HELPER_EXECUTING = MAKE_RETURN_CODE(0xA6);
|
||||||
|
//! [EXPORT] : [COMMENT] Filename of MPSoC file is to long (max. 256 bytes)
|
||||||
|
static const ReturnValue_t MPSOC_FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA7);
|
||||||
|
//! [EXPORT] : [COMMENT] Command has invalid parameter
|
||||||
|
static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xA8);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* MPSOC_RETURN_VALUES_IF_H_ */
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
||||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
|
||||||
|
|
||||||
|
#include "OBSWConfig.h"
|
||||||
|
#include "MPSoCReturnValuesIF.h"
|
||||||
#include <fsfw/tmtcpacket/SpacePacket.h>
|
#include <fsfw/tmtcpacket/SpacePacket.h>
|
||||||
#include <fsfw/globalfunctions/CRC.h>
|
#include <fsfw/globalfunctions/CRC.h>
|
||||||
#include <fsfw/serialize/SerializeAdapter.h>
|
#include <fsfw/serialize/SerializeAdapter.h>
|
||||||
@ -81,19 +83,12 @@ static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 60;
|
|||||||
/**
|
/**
|
||||||
* @brief Abstract base class for TC space packet of MPSoC.
|
* @brief Abstract base class for TC space packet of MPSoC.
|
||||||
*/
|
*/
|
||||||
class TcBase : public SpacePacket, public HasReturnvaluesIF {
|
class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Initial length field of space packet. Will always be updated when packet is created.
|
// Initial length field of space packet. Will always be updated when packet is created.
|
||||||
static const uint16_t INIT_LENGTH = 1;
|
static const uint16_t INIT_LENGTH = 1;
|
||||||
|
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_CMD;
|
|
||||||
|
|
||||||
//! [EXPORT] : [COMMENT] Received command with invalid length
|
|
||||||
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xC0);
|
|
||||||
//! [EXPORT] : [COMMENT] Command has invalid parameter
|
|
||||||
static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xC1);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
*
|
*
|
||||||
@ -113,13 +108,13 @@ public:
|
|||||||
* @return RETURN_OK if packet creation was successful, otherwise error return value
|
* @return RETURN_OK if packet creation was successful, otherwise error return value
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t createPacket(const uint8_t* commandData, size_t commandDataLen) {
|
virtual ReturnValue_t createPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
result = initPacket(commandData, commandDataLen);
|
result = initPacket(commandData, commandDataLen);
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = addCrc();
|
result = addCrc();
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -133,21 +128,21 @@ protected:
|
|||||||
* @param commandDataLen Length of received command data
|
* @param commandDataLen Length of received command data
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calculates and adds the CRC
|
* @brief Calculates and adds the CRC
|
||||||
*/
|
*/
|
||||||
ReturnValue_t addCrc() {
|
ReturnValue_t addCrc() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
size_t serializedSize = 0;
|
size_t serializedSize = 0;
|
||||||
uint32_t full_size = getFullSize();
|
uint32_t full_size = getFullSize();
|
||||||
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
||||||
result = SerializeAdapter::serialize<uint16_t>(&crc,
|
result = SerializeAdapter::serialize<uint16_t>(&crc,
|
||||||
this->localData.byteStream + full_size - CRC_SIZE, &serializedSize, sizeof(crc),
|
this->localData.byteStream + full_size - CRC_SIZE, &serializedSize, sizeof(crc),
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl;
|
sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -157,13 +152,9 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* @brief Class for handling tm replies of the PLOC MPSoC.
|
* @brief Class for handling tm replies of the PLOC MPSoC.
|
||||||
*/
|
*/
|
||||||
class TmPacket : public SpacePacket, public HasReturnvaluesIF {
|
class TmPacket : public SpacePacket, public MPSoCReturnValuesIF {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_CMD;
|
|
||||||
|
|
||||||
//! [EXPORT] : [COMMENT] CRC check of received packet failed
|
|
||||||
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor creates idle packet and sets length field to maximum allowed size.
|
* @brief Constructor creates idle packet and sets length field to maximum allowed size.
|
||||||
*/
|
*/
|
||||||
@ -177,7 +168,7 @@ public:
|
|||||||
if (recalculatedCrc != receivedCrc) {
|
if (recalculatedCrc != receivedCrc) {
|
||||||
return CRC_FAILURE;
|
return CRC_FAILURE;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -202,9 +193,9 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
|
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
|
||||||
@ -214,7 +205,7 @@ protected:
|
|||||||
const uint8_t* memLenPtr = commandData + MEM_ADDRESS_SIZE;
|
const uint8_t* memLenPtr = commandData + MEM_ADDRESS_SIZE;
|
||||||
result = SerializeAdapter::deSerialize(&memLen, &memLenPtr, &size,
|
result = SerializeAdapter::deSerialize(&memLen, &memLenPtr, &size,
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
if(result != RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -233,7 +224,7 @@ private:
|
|||||||
if (commandDataLen != COMMAND_LENGTH){
|
if (commandDataLen != COMMAND_LENGTH){
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -252,9 +243,9 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||||
@ -276,7 +267,7 @@ private:
|
|||||||
sif::warning << "TcMemWrite: Command has invalid length " << commandDataLen << std::endl;
|
sif::warning << "TcMemWrite: Command has invalid length " << commandDataLen << std::endl;
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -295,17 +286,17 @@ public:
|
|||||||
static const char READ = 'r';
|
static const char READ = 'r';
|
||||||
|
|
||||||
ReturnValue_t createPacket(std::string filename, char accessMode) {
|
ReturnValue_t createPacket(std::string filename, char accessMode) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
size_t nameSize = filename.size();
|
size_t nameSize = filename.size();
|
||||||
std::memcpy(this->getPacketData(), filename.c_str(),
|
std::memcpy(this->getPacketData(), filename.c_str(),
|
||||||
nameSize);
|
nameSize);
|
||||||
std::memcpy(this->getPacketData() + nameSize, &accessMode,
|
std::memcpy(this->getPacketData() + nameSize, &accessMode,
|
||||||
sizeof(accessMode));
|
sizeof(accessMode));
|
||||||
|
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
|
||||||
result = addCrc();
|
result = addCrc();
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -321,14 +312,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t createPacket(std::string filename) {
|
ReturnValue_t createPacket(std::string filename) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
size_t nameSize = filename.size();
|
size_t nameSize = filename.size();
|
||||||
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
||||||
|
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
|
||||||
result = addCrc();
|
result = addCrc();
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -346,12 +337,16 @@ public:
|
|||||||
ReturnValue_t createPacket(uint8_t* writeData, uint32_t writeLen) {
|
ReturnValue_t createPacket(uint8_t* writeData, uint32_t writeLen) {
|
||||||
if (writeLen > MAX_DATA_SIZE) {
|
if (writeLen > MAX_DATA_SIZE) {
|
||||||
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
|
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
|
||||||
return RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
std::memcpy(this->getPacketData(), writeData, writeLen);
|
std::memcpy(this->getPacketData(), &writeLen, sizeof(writeLen));
|
||||||
addCrc();
|
std::memcpy(this->getPacketData() + sizeof(writeLen), writeData, writeLen);
|
||||||
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
|
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
|
||||||
return RETURN_OK;
|
ReturnValue_t result = addCrc();
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -366,12 +361,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t createPacket(std::string filename) {
|
ReturnValue_t createPacket(std::string filename) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
size_t nameSize = filename.size();
|
size_t nameSize = filename.size();
|
||||||
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
|
||||||
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
|
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
|
||||||
result = addCrc();
|
result = addCrc();
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -389,13 +384,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t createPacket() {
|
ReturnValue_t createPacket() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
result = addCrc();
|
result = addCrc();
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -413,13 +408,13 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = checkData(*commandData);
|
result = checkData(*commandData);
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||||
@ -438,7 +433,7 @@ private:
|
|||||||
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
|
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t checkData(uint8_t replay) {
|
ReturnValue_t checkData(uint8_t replay) {
|
||||||
@ -446,7 +441,7 @@ private:
|
|||||||
sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl;
|
sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl;
|
||||||
return INVALID_PARAMETER;
|
return INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -464,17 +459,17 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = modeCheck(*commandData);
|
result = modeCheck(*commandData);
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = laneRateCheck(*(commandData + 1));
|
result = laneRateCheck(*(commandData + 1));
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||||
@ -503,7 +498,7 @@ private:
|
|||||||
sif::warning << "TcDownlinkPwrOn: Command has invalid length " << commandDataLen << std::endl;
|
sif::warning << "TcDownlinkPwrOn: Command has invalid length " << commandDataLen << std::endl;
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t modeCheck(uint8_t mode) {
|
ReturnValue_t modeCheck(uint8_t mode) {
|
||||||
@ -511,7 +506,7 @@ private:
|
|||||||
sif::warning << "TcDwonlinkPwrOn::modeCheck: Invalid JESD mode" << std::endl;
|
sif::warning << "TcDwonlinkPwrOn::modeCheck: Invalid JESD mode" << std::endl;
|
||||||
return INVALID_MODE;
|
return INVALID_MODE;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t laneRateCheck(uint8_t laneRate) {
|
ReturnValue_t laneRateCheck(uint8_t laneRate) {
|
||||||
@ -519,7 +514,7 @@ private:
|
|||||||
sif::warning << "TcReplayStart::laneRateCheck: Invalid lane rate" << std::endl;
|
sif::warning << "TcReplayStart::laneRateCheck: Invalid lane rate" << std::endl;
|
||||||
return INVALID_LANE_RATE;
|
return INVALID_LANE_RATE;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -534,13 +529,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t createPacket() {
|
ReturnValue_t createPacket() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
result = addCrc();
|
result = addCrc();
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -558,9 +553,9 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
result = lengthCheck(commandDataLen);
|
result = lengthCheck(commandDataLen);
|
||||||
if (result != RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
|
||||||
@ -577,10 +572,42 @@ private:
|
|||||||
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen << std::endl;
|
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen << std::endl;
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FlashWritePusCmd : public MPSoCReturnValuesIF {
|
||||||
|
public:
|
||||||
|
FlashWritePusCmd(){};
|
||||||
|
|
||||||
|
ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
|
if (commandDataLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE + MAX_FILENAME_SIZE)) {
|
||||||
|
return INVALID_LENGTH;
|
||||||
|
}
|
||||||
|
obcFile = std::string(reinterpret_cast<const char*>(commandData));
|
||||||
|
if (obcFile.size() > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) {
|
||||||
|
return FILENAME_TOO_LONG;
|
||||||
|
}
|
||||||
|
mpsocFile = std::string(reinterpret_cast<const char*>(commandData + obcFile.size()));
|
||||||
|
if (mpsocFile.size() > MAX_FILENAME_SIZE) {
|
||||||
|
return MPSOC_FILENAME_TOO_LONG;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getObcFile() {
|
||||||
|
return obcFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getMPSoCFile() {
|
||||||
|
return mpsocFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::string obcFile = "";
|
||||||
|
std::string mpsocFile = "";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
#include "OBSWConfig.h"
|
|
||||||
#include "PlocMPSoCHandler.h"
|
#include "PlocMPSoCHandler.h"
|
||||||
#include "fsfw/globalfunctions/CRC.h"
|
|
||||||
|
#include "OBSWConfig.h"
|
||||||
#include "fsfw/datapool/PoolReadGuard.h"
|
#include "fsfw/datapool/PoolReadGuard.h"
|
||||||
|
#include "fsfw/globalfunctions/CRC.h"
|
||||||
|
|
||||||
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
|
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
|
||||||
CookieIF * comCookie, PlocMPSoCHelper* plocMPSoCHelper) :
|
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper)
|
||||||
DeviceHandlerBase(objectId, uartComIFid, comCookie), plocMPSoCHelper(plocMPSoCHelper) {
|
: DeviceHandlerBase(objectId, uartComIFid, comCookie), plocMPSoCHelper(plocMPSoCHelper) {
|
||||||
if (comCookie == NULL) {
|
if (comCookie == NULL) {
|
||||||
sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl;
|
sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl;
|
||||||
}
|
}
|
||||||
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlocMPSoCHandler::~PlocMPSoCHandler() {
|
PlocMPSoCHandler::~PlocMPSoCHandler() {}
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::initialize() {
|
ReturnValue_t PlocMPSoCHandler::initialize() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
@ -27,25 +27,26 @@ ReturnValue_t PlocMPSoCHandler::initialize() {
|
|||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(
|
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||||
objects::EVENT_MANAGER);
|
|
||||||
if (manager == nullptr) {
|
if (manager == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "PlocMPSoCHandler::initialize: Invalid event manager" << std::endl;
|
sif::error << "PlocMPSoCHandler::initialize: Invalid event manager" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
;
|
||||||
}
|
}
|
||||||
result = manager->registerListener(eventQueue->getId());
|
result = manager->registerListener(eventQueue->getId());
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = manager->subscribeToEventRange(eventQueue->getId(),
|
result = manager->subscribeToEventRange(
|
||||||
event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_FAILED),
|
eventQueue->getId(), event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_FAILED),
|
||||||
event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_SUCCESSFUL));
|
event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_SUCCESSFUL));
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from "
|
sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from "
|
||||||
" ploc mpsoc helper" << std::endl;
|
" ploc mpsoc helper"
|
||||||
|
<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
@ -61,8 +62,8 @@ ReturnValue_t PlocMPSoCHandler::initialize() {
|
|||||||
|
|
||||||
void PlocMPSoCHandler::performOperationHook() {
|
void PlocMPSoCHandler::performOperationHook() {
|
||||||
EventMessage event;
|
EventMessage event;
|
||||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event);
|
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK;
|
||||||
result == RETURN_OK; result = eventQueue->receiveMessage(&event)) {
|
result = eventQueue->receiveMessage(&event)) {
|
||||||
switch (event.getMessageId()) {
|
switch (event.getMessageId()) {
|
||||||
case EventMessage::EVENT_MESSAGE:
|
case EventMessage::EVENT_MESSAGE:
|
||||||
handleEvent(&event);
|
handleEvent(&event);
|
||||||
@ -80,16 +81,17 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
|
|||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
|
||||||
if (plocMPSoCHelperExecuting) {
|
if (plocMPSoCHelperExecuting) {
|
||||||
return MPSOC_HELPER_EXECUTING;
|
return MPSoCReturnValuesIF::MPSOC_HELPER_EXECUTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(actionId) {
|
switch (actionId) {
|
||||||
case mpsoc::TC_FLASHWRITE: {
|
case mpsoc::TC_FLASHWRITE: {
|
||||||
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||||
return FILENAME_TOO_LONG;
|
return MPSoCReturnValuesIF::FILENAME_TOO_LONG;
|
||||||
}
|
}
|
||||||
result = plocMPSoCHelper->startFlashWrite(
|
mpsoc::FlashWritePusCmd flashWritePusCmd;
|
||||||
std::string(reinterpret_cast<const char*>(data), size));
|
result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
|
||||||
|
flashWritePusCmd.getMPSoCFile());
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -102,8 +104,7 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
|
|||||||
return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size);
|
return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlocMPSoCHandler::doStartUp() {
|
||||||
void PlocMPSoCHandler::doStartUp(){
|
|
||||||
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
|
#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1
|
||||||
setMode(MODE_NORMAL);
|
setMode(MODE_NORMAL);
|
||||||
#else
|
#else
|
||||||
@ -111,59 +112,56 @@ void PlocMPSoCHandler::doStartUp(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocMPSoCHandler::doShutDown(){
|
void PlocMPSoCHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
|
||||||
setMode(_MODE_POWER_DOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(
|
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||||
DeviceCommandId_t * id) {
|
|
||||||
return NOTHING_TO_SEND;
|
return NOTHING_TO_SEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(
|
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||||
DeviceCommandId_t * id){
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(
|
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||||
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
|
const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
switch(deviceCommand) {
|
switch (deviceCommand) {
|
||||||
case(mpsoc::TC_MEM_WRITE): {
|
case (mpsoc::TC_MEM_WRITE): {
|
||||||
result = prepareTcMemWrite(commandData, commandDataLen);
|
result = prepareTcMemWrite(commandData, commandDataLen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(mpsoc::TC_MEM_READ): {
|
case (mpsoc::TC_MEM_READ): {
|
||||||
result = prepareTcMemRead(commandData, commandDataLen);
|
result = prepareTcMemRead(commandData, commandDataLen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(mpsoc::TC_FLASHDELETE): {
|
case (mpsoc::TC_FLASHDELETE): {
|
||||||
result = prepareTcFlashDelete(commandData, commandDataLen);
|
result = prepareTcFlashDelete(commandData, commandDataLen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(mpsoc::TC_REPLAY_START): {
|
case (mpsoc::TC_REPLAY_START): {
|
||||||
result = prepareTcReplayStart(commandData, commandDataLen);
|
result = prepareTcReplayStart(commandData, commandDataLen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(mpsoc::TC_REPLAY_STOP): {
|
case (mpsoc::TC_REPLAY_STOP): {
|
||||||
result = prepareTcReplayStop();
|
result = prepareTcReplayStop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(mpsoc::TC_DOWNLINK_PWR_ON): {
|
case (mpsoc::TC_DOWNLINK_PWR_ON): {
|
||||||
result = prepareTcDownlinkPwrOn(commandData, commandDataLen);
|
result = prepareTcDownlinkPwrOn(commandData, commandDataLen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(mpsoc::TC_DOWNLINK_PWR_OFF): {
|
case (mpsoc::TC_DOWNLINK_PWR_OFF): {
|
||||||
result = prepareTcDownlinkPwrOff();
|
result = prepareTcDownlinkPwrOff();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(mpsoc::TC_REPLAY_WRITE_SEQUENCE): {
|
case (mpsoc::TC_REPLAY_WRITE_SEQUENCE): {
|
||||||
result = prepareTcReplayWriteSequence(commandData, commandDataLen);
|
result = prepareTcReplayWriteSequence(commandData, commandDataLen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl;
|
sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented"
|
||||||
|
<< std::endl;
|
||||||
result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -192,38 +190,37 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() {
|
|||||||
this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
|
this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start,
|
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||||
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
|
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||||
|
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
|
||||||
uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK;
|
uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK;
|
||||||
|
|
||||||
switch(apid) {
|
switch (apid) {
|
||||||
case(mpsoc::apid::ACK_SUCCESS):
|
case (mpsoc::apid::ACK_SUCCESS):
|
||||||
*foundLen = mpsoc::SIZE_ACK_REPORT;
|
*foundLen = mpsoc::SIZE_ACK_REPORT;
|
||||||
*foundId = mpsoc::ACK_REPORT;
|
*foundId = mpsoc::ACK_REPORT;
|
||||||
break;
|
break;
|
||||||
case(mpsoc::apid::ACK_FAILURE):
|
case (mpsoc::apid::ACK_FAILURE):
|
||||||
*foundLen = mpsoc::SIZE_ACK_REPORT;
|
*foundLen = mpsoc::SIZE_ACK_REPORT;
|
||||||
*foundId = mpsoc::ACK_REPORT;
|
*foundId = mpsoc::ACK_REPORT;
|
||||||
break;
|
break;
|
||||||
case(mpsoc::apid::TM_MEMORY_READ_REPORT):
|
case (mpsoc::apid::TM_MEMORY_READ_REPORT):
|
||||||
*foundLen = tmMemReadReport.rememberRequestedSize;
|
*foundLen = tmMemReadReport.rememberRequestedSize;
|
||||||
*foundId = mpsoc::TM_MEMORY_READ_REPORT;
|
*foundId = mpsoc::TM_MEMORY_READ_REPORT;
|
||||||
break;
|
break;
|
||||||
case(mpsoc::apid::EXE_SUCCESS):
|
case (mpsoc::apid::EXE_SUCCESS):
|
||||||
*foundLen = mpsoc::SIZE_EXE_REPORT;
|
*foundLen = mpsoc::SIZE_EXE_REPORT;
|
||||||
*foundId = mpsoc::EXE_REPORT;
|
*foundId = mpsoc::EXE_REPORT;
|
||||||
break;
|
break;
|
||||||
case(mpsoc::apid::EXE_FAILURE):
|
case (mpsoc::apid::EXE_FAILURE):
|
||||||
*foundLen = mpsoc::SIZE_EXE_REPORT;
|
*foundLen = mpsoc::SIZE_EXE_REPORT;
|
||||||
*foundId = mpsoc::EXE_REPORT;
|
*foundId = mpsoc::EXE_REPORT;
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl;
|
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl;
|
||||||
*foundLen = remainingSize;
|
*foundLen = remainingSize;
|
||||||
return INVALID_APID;
|
return MPSoCReturnValuesIF::INVALID_APID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sequenceCount++;
|
sequenceCount++;
|
||||||
@ -235,9 +232,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id,
|
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
||||||
const uint8_t *packet) {
|
|
||||||
|
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
@ -262,35 +257,29 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid(){
|
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {}
|
||||||
|
|
||||||
}
|
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
|
||||||
|
|
||||||
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){
|
|
||||||
return 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
LocalDataPoolManager& poolManager) {
|
LocalDataPoolManager& poolManager) {
|
||||||
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
|
void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
|
||||||
object_id_t objectId = eventMessage->getReporter();
|
object_id_t objectId = eventMessage->getReporter();
|
||||||
switch(objectId){
|
switch (objectId) {
|
||||||
case objects::PLOC_MPSOC_HELPER: {
|
case objects::PLOC_MPSOC_HELPER: {
|
||||||
plocMPSoCHelperExecuting = false;
|
plocMPSoCHelperExecuting = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
sif::debug << "PlocMPSoCHandler::handleEvent: Did not subscribe to this event"
|
sif::debug << "PlocMPSoCHandler::handleEvent: Did not subscribe to this event" << std::endl;
|
||||||
<< std::endl;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t * commandData,
|
ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
sequenceCount++;
|
sequenceCount++;
|
||||||
@ -304,7 +293,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t * commandData,
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t * commandData,
|
ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
sequenceCount++;
|
sequenceCount++;
|
||||||
@ -319,7 +308,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t * commandData,
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t * commandData,
|
ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||||
return NAME_TOO_LONG;
|
return NAME_TOO_LONG;
|
||||||
@ -337,8 +326,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t * commandData
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(
|
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
|
||||||
const uint8_t * commandData, size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
sequenceCount++;
|
sequenceCount++;
|
||||||
mpsoc::TcReplayStart tcReplayStart(sequenceCount);
|
mpsoc::TcReplayStart tcReplayStart(sequenceCount);
|
||||||
@ -364,8 +353,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(
|
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData,
|
||||||
const uint8_t * commandData, size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
sequenceCount++;
|
sequenceCount++;
|
||||||
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(sequenceCount);
|
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(sequenceCount);
|
||||||
@ -419,37 +408,36 @@ ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundL
|
|||||||
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
|
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1);
|
||||||
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
|
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
|
||||||
if (receivedCrc != recalculatedCrc) {
|
if (receivedCrc != recalculatedCrc) {
|
||||||
return CRC_FAILURE;
|
return MPSoCReturnValuesIF::CRC_FAILURE;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
|
ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
|
||||||
|
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
|
||||||
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
|
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
|
||||||
if(result == CRC_FAILURE) {
|
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||||
sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
|
sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
|
||||||
nextReplyId = mpsoc::NONE;
|
nextReplyId = mpsoc::NONE;
|
||||||
replyRawReplyIfnotWiretapped(data, mpsoc::SIZE_ACK_REPORT);
|
replyRawReplyIfnotWiretapped(data, mpsoc::SIZE_ACK_REPORT);
|
||||||
triggerEvent(MPSOC_HANDLER_CRC_FAILURE);
|
triggerEvent(MPSOC_HANDLER_CRC_FAILURE);
|
||||||
sendFailureReport(mpsoc::ACK_REPORT, CRC_FAILURE);
|
sendFailureReport(mpsoc::ACK_REPORT, MPSoCReturnValuesIF::CRC_FAILURE);
|
||||||
disableAllReplies();
|
disableAllReplies();
|
||||||
return IGNORE_REPLY_DATA;
|
return IGNORE_REPLY_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
||||||
|
|
||||||
switch(apid) {
|
switch (apid) {
|
||||||
case mpsoc::apid::ACK_FAILURE: {
|
case mpsoc::apid::ACK_FAILURE: {
|
||||||
//TODO: Interpretation of status field in acknowledgment report
|
// TODO: Interpretation of status field in acknowledgment report
|
||||||
sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl;
|
sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl;
|
||||||
DeviceCommandId_t commandId = getPendingCommand();
|
DeviceCommandId_t commandId = getPendingCommand();
|
||||||
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||||
triggerEvent(ACK_FAILURE, commandId);
|
triggerEvent(ACK_FAILURE, commandId);
|
||||||
}
|
}
|
||||||
sendFailureReport(mpsoc::ACK_REPORT, RECEIVED_ACK_FAILURE);
|
sendFailureReport(mpsoc::ACK_REPORT, MPSoCReturnValuesIF::RECEIVED_ACK_FAILURE);
|
||||||
disableAllReplies();
|
disableAllReplies();
|
||||||
nextReplyId = mpsoc::NONE;
|
nextReplyId = mpsoc::NONE;
|
||||||
result = IGNORE_REPLY_DATA;
|
result = IGNORE_REPLY_DATA;
|
||||||
@ -473,7 +461,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
|
|||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
|
||||||
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
|
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
|
||||||
if(result == CRC_FAILURE) {
|
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||||
sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
|
sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
|
||||||
nextReplyId = mpsoc::NONE;
|
nextReplyId = mpsoc::NONE;
|
||||||
return result;
|
return result;
|
||||||
@ -486,17 +474,16 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (mpsoc::apid::EXE_FAILURE): {
|
case (mpsoc::apid::EXE_FAILURE): {
|
||||||
//TODO: Interpretation of status field in execution report
|
// TODO: Interpretation of status field in execution report
|
||||||
sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report"
|
sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
DeviceCommandId_t commandId = getPendingCommand();
|
DeviceCommandId_t commandId = getPendingCommand();
|
||||||
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||||
triggerEvent(EXE_FAILURE, commandId);
|
triggerEvent(EXE_FAILURE, commandId);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
|
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
|
||||||
}
|
}
|
||||||
sendFailureReport(mpsoc::EXE_REPORT, RECEIVED_EXE_FAILURE);
|
sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
|
||||||
disableExeReportReply();
|
disableExeReportReply();
|
||||||
result = IGNORE_REPLY_DATA;
|
result = IGNORE_REPLY_DATA;
|
||||||
break;
|
break;
|
||||||
@ -514,12 +501,12 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
|
|||||||
ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
|
ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
result = verifyPacket(data, tmMemReadReport.rememberRequestedSize);
|
result = verifyPacket(data, tmMemReadReport.rememberRequestedSize);
|
||||||
if(result == CRC_FAILURE) {
|
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||||
sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc"
|
sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
uint16_t memLen = *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8
|
uint16_t memLen =
|
||||||
| *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1);
|
*(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8 | *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1);
|
||||||
/** Send data to commanding queue */
|
/** Send data to commanding queue */
|
||||||
handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4,
|
handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4,
|
||||||
mpsoc::TM_MEMORY_READ_REPORT);
|
mpsoc::TM_MEMORY_READ_REPORT);
|
||||||
@ -530,7 +517,6 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
|
|||||||
ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||||
uint8_t expectedReplies, bool useAlternateId,
|
uint8_t expectedReplies, bool useAlternateId,
|
||||||
DeviceCommandId_t alternateReplyID) {
|
DeviceCommandId_t alternateReplyID) {
|
||||||
|
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
|
||||||
uint8_t enabledReplies = 0;
|
uint8_t enabledReplies = 0;
|
||||||
@ -564,29 +550,28 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
|
|||||||
* Every command causes at least one acknowledgment and one execution report. Therefore both
|
* Every command causes at least one acknowledgment and one execution report. Therefore both
|
||||||
* replies will be enabled here.
|
* replies will be enabled here.
|
||||||
*/
|
*/
|
||||||
result = DeviceHandlerBase::enableReplyInReplyMap(command,
|
result =
|
||||||
enabledReplies, true, mpsoc::ACK_REPORT);
|
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, mpsoc::ACK_REPORT);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::ACK_REPORT
|
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::ACK_REPORT
|
||||||
<< " not in replyMap" << std::endl;
|
<< " not in replyMap" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = DeviceHandlerBase::enableReplyInReplyMap(command,
|
result =
|
||||||
enabledReplies, true, mpsoc::EXE_REPORT);
|
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, mpsoc::EXE_REPORT);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::EXE_REPORT
|
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::EXE_REPORT
|
||||||
<< " not in replyMap" << std::endl;
|
<< " not in replyMap" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(command->first) {
|
switch (command->first) {
|
||||||
case mpsoc::TC_REPLAY_WRITE_SEQUENCE: {
|
case mpsoc::TC_REPLAY_WRITE_SEQUENCE: {
|
||||||
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
|
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
|
||||||
if (iter != deviceReplyMap.end()) {
|
if (iter != deviceReplyMap.end()) {
|
||||||
// Overwrite delay cycles because replay write sequence command can required up to
|
// Overwrite delay cycles because replay write sequence command can required up to
|
||||||
// 30 seconds for execution
|
// 30 seconds for execution
|
||||||
iter->second.delayCycles = mpsoc::TC_WRITE_SEQ_EXECUTION_DELAY;
|
iter->second.delayCycles = mpsoc::TC_WRITE_SEQ_EXECUTION_DELAY;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown reply id" << std::endl;
|
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown reply id" << std::endl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -599,7 +584,7 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlocMPSoCHandler::setNextReplyId() {
|
void PlocMPSoCHandler::setNextReplyId() {
|
||||||
switch(getPendingCommand()) {
|
switch (getPendingCommand()) {
|
||||||
case mpsoc::TC_MEM_READ:
|
case mpsoc::TC_MEM_READ:
|
||||||
nextReplyId = mpsoc::TM_MEMORY_READ_REPORT;
|
nextReplyId = mpsoc::TM_MEMORY_READ_REPORT;
|
||||||
break;
|
break;
|
||||||
@ -609,8 +594,7 @@ void PlocMPSoCHandler::setNextReplyId() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){
|
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
|
||||||
|
|
||||||
size_t replyLen = 0;
|
size_t replyLen = 0;
|
||||||
|
|
||||||
if (nextReplyId == mpsoc::NONE) {
|
if (nextReplyId == mpsoc::NONE) {
|
||||||
@ -624,7 +608,7 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){
|
|||||||
/* Reply inactive */
|
/* Reply inactive */
|
||||||
return replyLen;
|
return replyLen;
|
||||||
}
|
}
|
||||||
switch(nextReplyId) {
|
switch (nextReplyId) {
|
||||||
case mpsoc::TM_MEMORY_READ_REPORT: {
|
case mpsoc::TM_MEMORY_READ_REPORT: {
|
||||||
replyLen = tmMemReadReport.rememberRequestedSize;
|
replyLen = tmMemReadReport.rememberRequestedSize;
|
||||||
break;
|
break;
|
||||||
@ -634,8 +618,7 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id "
|
sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id "
|
||||||
<< std::hex << nextReplyId << " in deviceReplyMap" << std::endl;
|
<< std::hex << nextReplyId << " in deviceReplyMap" << std::endl;
|
||||||
}
|
}
|
||||||
@ -643,8 +626,8 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){
|
|||||||
return replyLen;
|
return replyLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) {
|
void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
|
||||||
|
DeviceCommandId_t replyId) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
|
||||||
if (wiretappingMode == RAW) {
|
if (wiretappingMode == RAW) {
|
||||||
@ -670,12 +653,11 @@ void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, Devi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlocMPSoCHandler::disableAllReplies() {
|
void PlocMPSoCHandler::disableAllReplies() {
|
||||||
|
|
||||||
DeviceReplyMap::iterator iter;
|
DeviceReplyMap::iterator iter;
|
||||||
|
|
||||||
/* Disable ack reply */
|
/* Disable ack reply */
|
||||||
iter = deviceReplyMap.find(mpsoc::ACK_REPORT);
|
iter = deviceReplyMap.find(mpsoc::ACK_REPORT);
|
||||||
DeviceReplyInfo *info = &(iter->second);
|
DeviceReplyInfo* info = &(iter->second);
|
||||||
info->delayCycles = 0;
|
info->delayCycles = 0;
|
||||||
info->command = deviceCommandMap.end();
|
info->command = deviceCommandMap.end();
|
||||||
|
|
||||||
@ -722,7 +704,7 @@ void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_
|
|||||||
|
|
||||||
void PlocMPSoCHandler::disableExeReportReply() {
|
void PlocMPSoCHandler::disableExeReportReply() {
|
||||||
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
|
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
|
||||||
DeviceReplyInfo *info = &(iter->second);
|
DeviceReplyInfo* info = &(iter->second);
|
||||||
info->delayCycles = 0;
|
info->delayCycles = 0;
|
||||||
info->command = deviceCommandMap.end();
|
info->command = deviceCommandMap.end();
|
||||||
/* Expected replies is set to one here. The value will set to 0 in replyToReply() */
|
/* Expected replies is set to one here. The value will set to 0 in replyToReply() */
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
|
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
|
||||||
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
|
||||||
#include "PlocMPSoCHelper.h"
|
#include "PlocMPSoCHelper.h"
|
||||||
|
#include "linux/devices/devicedefinitions/MPSoCReturnValuesIF.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is the device handler for the MPSoC of the payload computer.
|
* @brief This is the device handler for the MPSoC of the payload computer.
|
||||||
@ -25,23 +26,6 @@
|
|||||||
class PlocMPSoCHandler: public DeviceHandlerBase {
|
class PlocMPSoCHandler: public DeviceHandlerBase {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER;
|
|
||||||
|
|
||||||
//! [EXPORT] : [COMMENT] Space Packet received from PLOC has invalid CRC
|
|
||||||
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
|
|
||||||
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC
|
|
||||||
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1);
|
|
||||||
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC
|
|
||||||
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2);
|
|
||||||
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC
|
|
||||||
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
|
|
||||||
//! [EXPORT] : [COMMENT] Received command with invalid length
|
|
||||||
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xA4);
|
|
||||||
//! [EXPORT] : [COMMENT] Received command with invalid filename
|
|
||||||
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA5);
|
|
||||||
//! [EXPORT] : [COMMENT] MPSoC helper is currently executing a command
|
|
||||||
static const ReturnValue_t MPSOC_HELPER_EXECUTING = MAKE_RETURN_CODE(0xA6);
|
|
||||||
|
|
||||||
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie,
|
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie,
|
||||||
PlocMPSoCHelper* plocMPSoCHelper);
|
PlocMPSoCHelper* plocMPSoCHelper);
|
||||||
virtual ~PlocMPSoCHandler();
|
virtual ~PlocMPSoCHandler();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "OBSWConfig.h"
|
||||||
#ifdef XIPHOS_Q7S
|
#ifdef XIPHOS_Q7S
|
||||||
#include "bsp_q7s/memory/FileSystemHelper.h"
|
#include "bsp_q7s/memory/FileSystemHelper.h"
|
||||||
#endif
|
#endif
|
||||||
@ -65,7 +66,7 @@ void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
|
|||||||
sequenceCount = sequenceCount_;
|
sequenceCount = sequenceCount_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string file) {
|
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) {
|
||||||
#ifdef XIPHOS_Q7S
|
#ifdef XIPHOS_Q7S
|
||||||
ReturnValue_t result = FilesystemHelper::checkPath(file);
|
ReturnValue_t result = FilesystemHelper::checkPath(file);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
@ -76,7 +77,16 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string file) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
flashWrite.file = file;
|
#ifdef TE0720_1CFA
|
||||||
|
if (not std::filesystem::exists(obcFile)) {
|
||||||
|
sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist"
|
||||||
|
<< std::endl;
|
||||||
|
return RETURN_FAILED;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
flashWrite.obcFile = obcFile;
|
||||||
|
flashWrite.mpsocFile = mpsocFile;
|
||||||
internalState = InternalState::FLASH_WRITE;
|
internalState = InternalState::FLASH_WRITE;
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
terminate = false;
|
terminate = false;
|
||||||
@ -92,7 +102,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
uint8_t tempData[mpsoc::MAX_DATA_SIZE];
|
uint8_t tempData[mpsoc::MAX_DATA_SIZE];
|
||||||
std::ifstream file(flashWrite.file, std::ifstream::binary);
|
std::ifstream file(flashWrite.obcFile, std::ifstream::binary);
|
||||||
// Set position of next character to end of file input stream
|
// Set position of next character to end of file input stream
|
||||||
file.seekg(0, file.end);
|
file.seekg(0, file.end);
|
||||||
// tellg returns position of character in input stream
|
// tellg returns position of character in input stream
|
||||||
@ -135,7 +145,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() {
|
|||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
(*sequenceCount)++;
|
(*sequenceCount)++;
|
||||||
mpsoc::FlashFopen flashFopen(*sequenceCount);
|
mpsoc::FlashFopen flashFopen(*sequenceCount);
|
||||||
result = flashFopen.createPacket(flashWrite.file, mpsoc::FlashFopen::APPEND);
|
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -150,7 +160,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() {
|
|||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
(*sequenceCount)++;
|
(*sequenceCount)++;
|
||||||
mpsoc::FlashFclose flashFclose(*sequenceCount);
|
mpsoc::FlashFclose flashFclose(*sequenceCount);
|
||||||
result = flashFclose.createPacket(flashWrite.file);
|
result = flashFclose.createPacket(flashWrite.mpsocFile);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -79,11 +79,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Starts flash write sequence
|
* @brief Starts flash write sequence
|
||||||
*
|
*
|
||||||
* @param file File with data to write
|
* @param obcFile File where to read from the data
|
||||||
|
* @param mpsocFile The file of the MPSoC where should be written to
|
||||||
*
|
*
|
||||||
* @return RETURN_OK if successful, otherwise error return value
|
* @return RETURN_OK if successful, otherwise error return value
|
||||||
*/
|
*/
|
||||||
ReturnValue_t startFlashWrite(std::string file);
|
ReturnValue_t startFlashWrite(std::string obcFile, std::string mpsocFile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Can be used to interrupt a running data transfer.
|
* @brief Can be used to interrupt a running data transfer.
|
||||||
@ -104,7 +105,8 @@ private:
|
|||||||
static const int RETRIES = 3;
|
static const int RETRIES = 3;
|
||||||
|
|
||||||
struct FlashWrite {
|
struct FlashWrite {
|
||||||
std::string file;
|
std::string obcFile;
|
||||||
|
std::string mpsocFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FlashWrite flashWrite;
|
struct FlashWrite flashWrite;
|
||||||
|
Loading…
Reference in New Issue
Block a user