more defensive buffer handling
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
parent
458929957d
commit
232372fd96
@ -159,13 +159,6 @@ static const size_t MAX_PACKET_SIZE = 1024;
|
|||||||
|
|
||||||
static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6;
|
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 {
|
enum PoolIds : lp_id_t {
|
||||||
NUM_TMS,
|
NUM_TMS,
|
||||||
TEMP_PS,
|
TEMP_PS,
|
||||||
|
@ -19,6 +19,8 @@ PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid
|
|||||||
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||||
commandActionHelperQueue =
|
commandActionHelperQueue =
|
||||||
QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
|
||||||
|
spParams.maxSize = sizeof(commandBuffer);
|
||||||
|
spParams.buf = commandBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlocMPSoCHandler::~PlocMPSoCHandler() {}
|
PlocMPSoCHandler::~PlocMPSoCHandler() {}
|
||||||
@ -207,8 +209,6 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device
|
|||||||
const uint8_t* commandData,
|
const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
spParams.buf = commandBuffer;
|
spParams.buf = commandBuffer;
|
||||||
spParams.maxSize = sizeof(commandBuffer);
|
|
||||||
|
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
switch (deviceCommand) {
|
switch (deviceCommand) {
|
||||||
case (mpsoc::TC_MEM_WRITE): {
|
case (mpsoc::TC_MEM_WRITE): {
|
||||||
|
@ -104,6 +104,7 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string
|
|||||||
ReturnValue_t PlocMPSoCHelper::resetHelper() {
|
ReturnValue_t PlocMPSoCHelper::resetHelper() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
|
spParams.buf = commandBuffer;
|
||||||
terminate = false;
|
terminate = false;
|
||||||
result = uartComIF->flushUartRxBuffer(comCookie);
|
result = uartComIF->flushUartRxBuffer(comCookie);
|
||||||
return result;
|
return result;
|
||||||
@ -162,6 +163,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
|||||||
|
|
||||||
ReturnValue_t PlocMPSoCHelper::flashfopen() {
|
ReturnValue_t PlocMPSoCHelper::flashfopen() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
spParams.buf = commandBuffer;
|
||||||
(*sequenceCount)++;
|
(*sequenceCount)++;
|
||||||
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
|
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
|
||||||
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
|
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
|
||||||
@ -177,6 +179,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() {
|
|||||||
|
|
||||||
ReturnValue_t PlocMPSoCHelper::flashfclose() {
|
ReturnValue_t PlocMPSoCHelper::flashfclose() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
spParams.buf = commandBuffer;
|
||||||
(*sequenceCount)++;
|
(*sequenceCount)++;
|
||||||
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
|
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
|
||||||
result = flashFclose.createPacket(flashWrite.mpsocFile);
|
result = flashFclose.createPacket(flashWrite.mpsocFile);
|
||||||
|
@ -201,7 +201,6 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d
|
|||||||
using namespace supv;
|
using namespace supv;
|
||||||
ReturnValue_t result = RETURN_FAILED;
|
ReturnValue_t result = RETURN_FAILED;
|
||||||
spParams.buf = commandBuffer;
|
spParams.buf = commandBuffer;
|
||||||
spParams.maxSize = sizeof(commandBuffer);
|
|
||||||
switch (deviceCommand) {
|
switch (deviceCommand) {
|
||||||
case GET_HK_REPORT: {
|
case GET_HK_REPORT: {
|
||||||
prepareEmptyCmd(APID_GET_HK_REPORT);
|
prepareEmptyCmd(APID_GET_HK_REPORT);
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
#include "mission/utility/Timestamp.h"
|
#include "mission/utility/Timestamp.h"
|
||||||
|
|
||||||
PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId) {
|
PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId) {
|
||||||
spParams.buf = commandBuffer;
|
|
||||||
spParams.maxSize = sizeof(commandBuffer);
|
spParams.maxSize = sizeof(commandBuffer);
|
||||||
|
resetSpParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlocSupvHelper::~PlocSupvHelper() {}
|
PlocSupvHelper::~PlocSupvHelper() {}
|
||||||
@ -244,6 +244,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
|||||||
} else {
|
} else {
|
||||||
seqFlags = ccsds::SequenceFlags::CONTINUATION;
|
seqFlags = ccsds::SequenceFlags::CONTINUATION;
|
||||||
}
|
}
|
||||||
|
resetSpParams();
|
||||||
supv::WriteMemory packet(spParams);
|
supv::WriteMemory packet(spParams);
|
||||||
result = packet.buildPacket(seqFlags, update.sequenceCount++, update.memoryId,
|
result = packet.buildPacket(seqFlags, update.sequenceCount++, update.memoryId,
|
||||||
update.startAddress + update.bytesWritten, dataLength, tempData);
|
update.startAddress + update.bytesWritten, dataLength, tempData);
|
||||||
@ -271,6 +272,7 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
|||||||
ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
|
ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
|
||||||
using namespace supv;
|
using namespace supv;
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
resetSpParams();
|
||||||
RequestLoggingData packet(spParams);
|
RequestLoggingData packet(spParams);
|
||||||
result = packet.buildPacket(RequestLoggingData::Sa::REQUEST_EVENT_BUFFERS);
|
result = packet.buildPacket(RequestLoggingData::Sa::REQUEST_EVENT_BUFFERS);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
@ -297,6 +299,7 @@ ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
|
|||||||
|
|
||||||
ReturnValue_t PlocSupvHelper::selectMemory() {
|
ReturnValue_t PlocSupvHelper::selectMemory() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
resetSpParams();
|
||||||
supv::MPSoCBootSelect packet(spParams);
|
supv::MPSoCBootSelect packet(spParams);
|
||||||
result = packet.buildPacket(update.memoryId);
|
result = packet.buildPacket(update.memoryId);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
@ -311,6 +314,7 @@ ReturnValue_t PlocSupvHelper::selectMemory() {
|
|||||||
|
|
||||||
ReturnValue_t PlocSupvHelper::prepareUpdate() {
|
ReturnValue_t PlocSupvHelper::prepareUpdate() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
resetSpParams();
|
||||||
supv::ApidOnlyPacket packet(spParams, supv::APID_PREPARE_UPDATE);
|
supv::ApidOnlyPacket packet(spParams, supv::APID_PREPARE_UPDATE);
|
||||||
result = packet.buildPacket();
|
result = packet.buildPacket();
|
||||||
result = handlePacketTransmission(packet, PREPARE_UPDATE_EXECUTION_REPORT);
|
result = handlePacketTransmission(packet, PREPARE_UPDATE_EXECUTION_REPORT);
|
||||||
@ -322,6 +326,7 @@ ReturnValue_t PlocSupvHelper::prepareUpdate() {
|
|||||||
|
|
||||||
ReturnValue_t PlocSupvHelper::eraseMemory() {
|
ReturnValue_t PlocSupvHelper::eraseMemory() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
resetSpParams();
|
||||||
supv::EraseMemory eraseMemory(spParams);
|
supv::EraseMemory eraseMemory(spParams);
|
||||||
result = eraseMemory.buildPacket(update.memoryId, update.startAddress, update.length);
|
result = eraseMemory.buildPacket(update.memoryId, update.startAddress, update.length);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
@ -376,7 +381,7 @@ ReturnValue_t PlocSupvHelper::handleAck() {
|
|||||||
}
|
}
|
||||||
supv::AcknowledgmentReport ackReport(tmBuf.data(), tmBuf.size());
|
supv::AcknowledgmentReport ackReport(tmBuf.data(), tmBuf.size());
|
||||||
result = checkReceivedTm(ackReport);
|
result = checkReceivedTm(ackReport);
|
||||||
if(result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = ackReport.checkApid();
|
result = ackReport.checkApid();
|
||||||
@ -403,7 +408,7 @@ ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
|
|||||||
}
|
}
|
||||||
supv::ExecutionReport exeReport(tmBuf.data(), tmBuf.size());
|
supv::ExecutionReport exeReport(tmBuf.data(), tmBuf.size());
|
||||||
result = checkReceivedTm(exeReport);
|
result = checkReceivedTm(exeReport);
|
||||||
if(result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = exeReport.checkApid();
|
result = exeReport.checkApid();
|
||||||
@ -516,6 +521,7 @@ ReturnValue_t PlocSupvHelper::calcImageCrc() {
|
|||||||
|
|
||||||
ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
|
ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
resetSpParams();
|
||||||
// Verification of update write procedure
|
// Verification of update write procedure
|
||||||
supv::CheckMemory packet(spParams);
|
supv::CheckMemory packet(spParams);
|
||||||
result = packet.buildPacket(update.memoryId, update.startAddress, update.length);
|
result = packet.buildPacket(update.memoryId, update.startAddress, update.length);
|
||||||
@ -597,7 +603,7 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
ReturnValue_t result = tmReader.checkCrc();
|
ReturnValue_t result = tmReader.checkCrc();
|
||||||
if(result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
|
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -613,3 +619,5 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlocSupvHelper::resetSpParams() { spParams.buf = commandBuffer; }
|
||||||
|
@ -244,6 +244,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
|
|||||||
*/
|
*/
|
||||||
uint32_t getFileSize(std::string filename);
|
uint32_t getFileSize(std::string filename);
|
||||||
ReturnValue_t handleEventBufferReception();
|
ReturnValue_t handleEventBufferReception();
|
||||||
|
|
||||||
|
void resetSpParams();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */
|
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user