more defensive buffer handling
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2022-08-15 18:53:25 +02:00
parent 458929957d
commit 232372fd96
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
6 changed files with 19 additions and 14 deletions

View File

@ -159,13 +159,6 @@ static const size_t MAX_PACKET_SIZE = 1024;
static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6;
// enum class SequenceFlags : uint8_t {
// CONTINUED_PKT = 0b00,
// FIRST_PKT = 0b01,
// LAST_PKT = 0b10,
// STANDALONE_PKT = 0b11
// };
enum PoolIds : lp_id_t {
NUM_TMS,
TEMP_PS,

View File

@ -19,6 +19,8 @@ PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
commandActionHelperQueue =
QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
spParams.maxSize = sizeof(commandBuffer);
spParams.buf = commandBuffer;
}
PlocMPSoCHandler::~PlocMPSoCHandler() {}
@ -207,8 +209,6 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device
const uint8_t* commandData,
size_t commandDataLen) {
spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer);
ReturnValue_t result = RETURN_OK;
switch (deviceCommand) {
case (mpsoc::TC_MEM_WRITE): {

View File

@ -104,6 +104,7 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string
ReturnValue_t PlocMPSoCHelper::resetHelper() {
ReturnValue_t result = RETURN_OK;
semaphore.release();
spParams.buf = commandBuffer;
terminate = false;
result = uartComIF->flushUartRxBuffer(comCookie);
return result;
@ -162,6 +163,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
ReturnValue_t PlocMPSoCHelper::flashfopen() {
ReturnValue_t result = RETURN_OK;
spParams.buf = commandBuffer;
(*sequenceCount)++;
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
@ -177,6 +179,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() {
ReturnValue_t PlocMPSoCHelper::flashfclose() {
ReturnValue_t result = RETURN_OK;
spParams.buf = commandBuffer;
(*sequenceCount)++;
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
result = flashFclose.createPacket(flashWrite.mpsocFile);

View File

@ -201,7 +201,6 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
using namespace supv;
ReturnValue_t result = RETURN_FAILED;
spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer);
switch (deviceCommand) {
case GET_HK_REPORT: {
prepareEmptyCmd(APID_GET_HK_REPORT);

View File

@ -17,8 +17,8 @@
#include "mission/utility/Timestamp.h"
PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId) {
spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer);
resetSpParams();
}
PlocSupvHelper::~PlocSupvHelper() {}
@ -244,6 +244,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
} else {
seqFlags = ccsds::SequenceFlags::CONTINUATION;
}
resetSpParams();
supv::WriteMemory packet(spParams);
result = packet.buildPacket(seqFlags, update.sequenceCount++, update.memoryId,
update.startAddress + update.bytesWritten, dataLength, tempData);
@ -271,6 +272,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
using namespace supv;
ReturnValue_t result = RETURN_OK;
resetSpParams();
RequestLoggingData packet(spParams);
result = packet.buildPacket(RequestLoggingData::Sa::REQUEST_EVENT_BUFFERS);
if (result != RETURN_OK) {
@ -297,6 +299,7 @@ ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
ReturnValue_t PlocSupvHelper::selectMemory() {
ReturnValue_t result = RETURN_OK;
resetSpParams();
supv::MPSoCBootSelect packet(spParams);
result = packet.buildPacket(update.memoryId);
if (result != RETURN_OK) {
@ -311,6 +314,7 @@ ReturnValue_t PlocSupvHelper::selectMemory() {
ReturnValue_t PlocSupvHelper::prepareUpdate() {
ReturnValue_t result = RETURN_OK;
resetSpParams();
supv::ApidOnlyPacket packet(spParams, supv::APID_PREPARE_UPDATE);
result = packet.buildPacket();
result = handlePacketTransmission(packet, PREPARE_UPDATE_EXECUTION_REPORT);
@ -322,6 +326,7 @@ ReturnValue_t PlocSupvHelper::prepareUpdate() {
ReturnValue_t PlocSupvHelper::eraseMemory() {
ReturnValue_t result = RETURN_OK;
resetSpParams();
supv::EraseMemory eraseMemory(spParams);
result = eraseMemory.buildPacket(update.memoryId, update.startAddress, update.length);
if (result != RETURN_OK) {
@ -516,6 +521,7 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() {
ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
ReturnValue_t result = RETURN_OK;
resetSpParams();
// Verification of update write procedure
supv::CheckMemory packet(spParams);
result = packet.buildPacket(update.memoryId, update.startAddress, update.length);
@ -613,3 +619,5 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
}
return result;
}
void PlocSupvHelper::resetSpParams() { spParams.buf = commandBuffer; }

View File

@ -244,6 +244,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
*/
uint32_t getFileSize(std::string filename);
ReturnValue_t handleEventBufferReception();
void resetSpParams();
};
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */