bugfixes and improvements
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
This commit is contained in:
parent
37211e2c5f
commit
cc863503ac
@ -359,7 +359,7 @@ void FreshMpsocHandler::handleTransitionToOn() {
|
||||
void FreshMpsocHandler::handleTransitionToOff() {
|
||||
if (handleHwShutdown()) {
|
||||
hkReport.setReportingEnabled(false);
|
||||
setMode(MODE_OFF);
|
||||
setMode(MODE_OFF, 0);
|
||||
transitionState = TransitionState::NONE;
|
||||
activeCmdInfo.reset();
|
||||
powerState = PowerState::IDLE;
|
||||
@ -476,6 +476,23 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
|
||||
result = commandTcMemRead(commandData, commandDataLen);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_FLASHFOPEN): {
|
||||
mpsoc::TcFlashFopen cmd(spParams, commandSequenceCount);
|
||||
// C string constructor.
|
||||
std::string filename = std::string(reinterpret_cast<const char*>(commandData));
|
||||
if (filename.size() > mpsoc::MAX_FILENAME_SIZE) {
|
||||
return mpsoc::NAME_TOO_LONG;
|
||||
}
|
||||
uint8_t mode = commandData[filename.size() + 2];
|
||||
cmd.setPayload(filename, mode);
|
||||
result = finishAndSendTc(actionId, cmd);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_FLASHFCLOSE): {
|
||||
mpsoc::TcFlashFclose cmd(spParams, commandSequenceCount);
|
||||
result = finishAndSendTc(actionId, cmd);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_FLASHDELETE): {
|
||||
result = commandTcFlashDelete(commandData, commandDataLen);
|
||||
break;
|
||||
@ -518,6 +535,7 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
|
||||
}
|
||||
mpsoc::TcFlashMkfs cmd(spParams, commandSequenceCount,
|
||||
static_cast<mpsoc::FlashId>(commandData[0]));
|
||||
sif::info << "PLOC MPSoC: Formatting Flash " << (int)commandData[0] << std::endl;
|
||||
result = finishAndSendTc(actionId, cmd, mpsoc::CMD_TIMEOUT_MKFS);
|
||||
break;
|
||||
}
|
||||
@ -541,6 +559,10 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
|
||||
result = commandTcSimplexStreamFile(commandData, commandDataLen);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_SIMPLEX_STORE_FILE): {
|
||||
result = commandTcSimplexStoreFile(commandData, commandDataLen);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::TC_DOWNLINK_DATA_MODULATE): {
|
||||
result = commandTcDownlinkDataModulate(commandData, commandDataLen);
|
||||
break;
|
||||
@ -590,7 +612,7 @@ ReturnValue_t FreshMpsocHandler::commandTcMemRead(const uint8_t* commandData,
|
||||
|
||||
ReturnValue_t FreshMpsocHandler::commandTcFlashDelete(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
if (commandDataLen > mpsoc::FILENAME_FIELD_SIZE) {
|
||||
return mpsoc::NAME_TOO_LONG;
|
||||
}
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
@ -224,7 +224,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) {
|
||||
spParams.buf = commandBuffer;
|
||||
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
|
||||
mpsoc::TcFlashFopen flashFopen(spParams, *sequenceCount);
|
||||
ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -243,7 +243,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) {
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() {
|
||||
spParams.buf = commandBuffer;
|
||||
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
|
||||
mpsoc::TcFlashFclose flashFclose(spParams, *sequenceCount);
|
||||
ReturnValue_t result = flashFclose.finishPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||
#include <mission/payload/plocSpBase.h>
|
||||
|
||||
#include "eive/definitions.h"
|
||||
#include "eive/eventSubsystemIds.h"
|
||||
#include "eive/resultClassIds.h"
|
||||
#include "fsfw/action/HasActionsIF.h"
|
||||
@ -245,7 +244,9 @@ static constexpr size_t CRC_SIZE = 2;
|
||||
*/
|
||||
static const uint8_t SIZE_MEM_READ_RPT_FIX = 6;
|
||||
|
||||
static const size_t MAX_FILENAME_SIZE = 256;
|
||||
static const size_t FILENAME_FIELD_SIZE = 256;
|
||||
// Subtract size of NULL terminator.
|
||||
static const size_t MAX_FILENAME_SIZE = FILENAME_FIELD_SIZE - 1;
|
||||
|
||||
/**
|
||||
* PLOC space packet length for fixed size packets. This is the size of the whole packet data
|
||||
@ -448,23 +449,21 @@ class TcMemWrite : public TcBase {
|
||||
/**
|
||||
* @brief Class to help creation of flash fopen command.
|
||||
*/
|
||||
class FlashFopen : public TcBase {
|
||||
class TcFlashFopen : public TcBase {
|
||||
public:
|
||||
FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
TcFlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
|
||||
|
||||
ReturnValue_t setPayload(std::string filename, uint8_t mode) {
|
||||
accessMode = mode;
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + CRC_SIZE);
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
std::memset(payloadStart, 0, FILENAME_FIELD_SIZE);
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
// payloadStart[nameSize] = NULL_TERMINATOR;
|
||||
std::memset(payloadStart + nameSize, 0, 256 - nameSize);
|
||||
// payloadStart[255] = NULL_TERMINATOR;
|
||||
payloadStart[256] = accessMode;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
@ -476,9 +475,9 @@ class FlashFopen : public TcBase {
|
||||
/**
|
||||
* @brief Class to help creation of flash fclose command.
|
||||
*/
|
||||
class FlashFclose : public TcBase {
|
||||
class TcFlashFclose : public TcBase {
|
||||
public:
|
||||
FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
TcFlashFclose(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {
|
||||
spParams.setFullPayloadLen(CRC_SIZE);
|
||||
}
|
||||
@ -506,7 +505,13 @@ class TcFlashMkfs : public TcBase {
|
||||
TcFlashMkfs(ploc::SpTcParams params, uint16_t sequenceCount, FlashId flashId)
|
||||
: TcBase(params, apid::TC_FLASH_MKFS, sequenceCount) {
|
||||
spParams.setFullPayloadLen(1 + CRC_SIZE);
|
||||
payloadStart[0] = flashId;
|
||||
const char* flashIdStr = "0:/";
|
||||
if (flashId == FlashId::FLASH_1) {
|
||||
flashIdStr = "1:/";
|
||||
}
|
||||
std::memcpy(payloadStart, flashIdStr, 3);
|
||||
// Null terminator
|
||||
payloadStart[3] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
@ -595,20 +600,14 @@ class TcFlashDelete : public TcBase {
|
||||
|
||||
ReturnValue_t setPayload(std::string filename) {
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + CRC_SIZE);
|
||||
auto res = checkPayloadLen();
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
*(payloadStart + nameSize) = NULL_TERMINATOR;
|
||||
|
||||
updateSpFields();
|
||||
res = checkSizeAndSerializeHeader();
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcAndSetCrc();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
};
|
||||
|
||||
@ -760,8 +759,9 @@ class TcGetDirContent : public TcBase {
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
std::memset(payloadStart, 0, 256);
|
||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
||||
payloadStart[255] = '\0';
|
||||
payloadStart[255] = 0;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
@ -802,7 +802,7 @@ class TcReplayWriteSeq : public TcBase {
|
||||
static const size_t USE_DECODING_LENGTH = 1;
|
||||
|
||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||
if (commandDataLen > USE_DECODING_LENGTH + MAX_FILENAME_SIZE or
|
||||
if (commandDataLen > USE_DECODING_LENGTH + FILENAME_FIELD_SIZE or
|
||||
checkPayloadLen() != returnvalue::OK) {
|
||||
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen
|
||||
<< std::endl;
|
||||
@ -821,18 +821,18 @@ class FlashBasePusCmd {
|
||||
virtual ~FlashBasePusCmd() = default;
|
||||
|
||||
virtual ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) {
|
||||
if (commandDataLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE + MAX_FILENAME_SIZE)) {
|
||||
if (commandDataLen > FILENAME_FIELD_SIZE) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
size_t fileLen = strnlen(reinterpret_cast<const char*>(commandData), commandDataLen);
|
||||
if (fileLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) {
|
||||
if (fileLen > MAX_FILENAME_SIZE) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
obcFile = std::string(reinterpret_cast<const char*>(commandData), fileLen);
|
||||
fileLen =
|
||||
strnlen(reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR),
|
||||
commandDataLen - obcFile.size() - 1);
|
||||
if (fileLen > MAX_FILENAME_SIZE) {
|
||||
if (fileLen > FILENAME_FIELD_SIZE) {
|
||||
return MPSOC_FILENAME_TOO_LONG;
|
||||
}
|
||||
mpsocFile = std::string(
|
||||
@ -921,15 +921,15 @@ class TcCamTakePic : public TcBase {
|
||||
size_t deserLen = commandDataLen;
|
||||
size_t serLen = 0;
|
||||
fileName = reinterpret_cast<const char*>(commandData);
|
||||
if (fileName.size() + sizeof(NULL_TERMINATOR) > FILENAME_LEN) {
|
||||
if (fileName.size() > MAX_FILENAME_SIZE) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
deserLen -= FILENAME_LEN;
|
||||
*dataPtr += FILENAME_LEN;
|
||||
deserLen -= fileName.length() + 1;
|
||||
*dataPtr += fileName.length() + 1;
|
||||
uint8_t** payloadPtr = &payloadStart;
|
||||
memcpy(payloadStart, fileName.data(), fileName.size());
|
||||
*payloadStart += FILENAME_LEN;
|
||||
serLen += FILENAME_LEN;
|
||||
*payloadPtr += FILENAME_FIELD_SIZE;
|
||||
serLen += FILENAME_FIELD_SIZE;
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&encoderSettingY, dataPtr, &deserLen,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
if (result != returnvalue::OK) {
|
||||
@ -1022,8 +1022,7 @@ class TcCamTakePic : public TcBase {
|
||||
|
||||
private:
|
||||
static const size_t PARAMETER_SIZE = 28;
|
||||
static constexpr size_t FILENAME_LEN = 64;
|
||||
static constexpr size_t FULL_PAYLOAD_SIZE = FILENAME_LEN + PARAMETER_SIZE;
|
||||
static constexpr size_t FULL_PAYLOAD_SIZE = FILENAME_FIELD_SIZE + PARAMETER_SIZE;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1039,7 +1038,7 @@ class TcSimplexStreamFile : public TcBase {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
std::string fileName(reinterpret_cast<const char*>(commandData));
|
||||
if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
|
||||
if (fileName.size() > MAX_FILENAME_SIZE) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
|
||||
@ -1080,7 +1079,7 @@ class TcSimplexStoreFile : public TcBase {
|
||||
return INVALID_PARAMETER;
|
||||
}
|
||||
std::string fileName(reinterpret_cast<const char*>(*dataPtr));
|
||||
if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
|
||||
if (fileName.size() + sizeof(NULL_TERMINATOR) > FILENAME_FIELD_SIZE) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
size_t currentCopyIdx = 0;
|
||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
||||
Subproject commit dfa45dbdba16d2190616eca6ba1dc13e94692b63
|
||||
Subproject commit a59aceda751bd1594b91c632fe0ae85b844707df
|
Loading…
x
Reference in New Issue
Block a user