From c8d38cf8528ec16a024b519dbc046d96294256f9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 20 Aug 2022 12:11:08 +0200 Subject: [PATCH] bugfixes --- .../devicedefinitions/PlocMPSoCDefinitions.h | 8 ++-- .../PlocSupervisorDefinitions.h | 38 +++++++++---------- linux/devices/ploc/PlocSupvHelper.cpp | 9 +++++ linux/devices/ploc/PlocSupvHelper.h | 4 +- mission/devices/IMTQHandler.cpp | 24 ++++++------ tmtc | 2 +- 6 files changed, 46 insertions(+), 39 deletions(-) diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index a293b1f7..6c72d1d9 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -370,8 +370,8 @@ class TcFlashWrite : public ploc::SpTcBase { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - size_t serializedSize = 0; - result = SerializeAdapter::serialize(&writeLen, payloadStart, &serializedSize, sizeof(writeLen), + size_t serializedSize = ccsds::HEADER_LEN; + result = SerializeAdapter::serialize(&writeLen, payloadStart, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -663,8 +663,8 @@ class TcCamcmdSend : public TcBase { if (res != HasReturnvaluesIF::RETURN_OK) { return res; } - size_t size = sizeof(dataLen); - SerializeAdapter::serialize(&dataLen, payloadStart, &size, sizeof(dataLen), + size_t size = ccsds::HEADER_LEN; + SerializeAdapter::serialize(&dataLen, payloadStart, &size, spParams.maxSize, SerializeIF::Endianness::BIG); std::memcpy(payloadStart + sizeof(dataLen), commandData, commandDataLen); *(payloadStart + sizeof(dataLen) + commandDataLen) = CARRIAGE_RETURN; diff --git a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h index 8f4e2154..5aa97e0d 100644 --- a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -721,11 +721,11 @@ class SetAdcWindowAndStride : public ploc::SpTcBase { static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; void initPacket(uint16_t windowSize, uint16_t stridingStepSize) { - size_t serializedSize = 0; + size_t serializedSize = 6; uint8_t* data = payloadStart; - SerializeAdapter::serialize(&windowSize, &data, &serializedSize, sizeof(windowSize), + SerializeAdapter::serialize(&windowSize, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); - SerializeAdapter::serialize(&stridingStepSize, &data, &serializedSize, sizeof(stridingStepSize), + SerializeAdapter::serialize(&stridingStepSize, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); } }; @@ -1066,13 +1066,13 @@ class CheckMemory : public ploc::SpTcBase { void initPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) { uint8_t* data = payloadStart; - size_t serLen = 0; - SerializeAdapter::serialize(&memoryId, &data, &serLen, sizeof(memoryId), + size_t serLen = 6; + SerializeAdapter::serialize(&memoryId, &data, &serLen, spParams.maxSize, SerializeIF::Endianness::BIG); - SerializeAdapter::serialize(&n, &data, &serLen, sizeof(n), SerializeIF::Endianness::BIG); - SerializeAdapter::serialize(&startAddress, &data, &serLen, sizeof(startAddress), + SerializeAdapter::serialize(&n, &data, &serLen, spParams.maxSize, SerializeIF::Endianness::BIG); + SerializeAdapter::serialize(&startAddress, &data, &serLen, spParams.maxSize, SerializeIF::Endianness::BIG); - SerializeAdapter::serialize(&length, &data, &serLen, sizeof(length), + SerializeAdapter::serialize(&length, &data, &serLen, spParams.maxSize, SerializeIF::Endianness::BIG); } }; @@ -1119,7 +1119,6 @@ class WriteMemory : public ploc::SpTcBase { ReturnValue_t initPacket(uint8_t memoryId, uint32_t startAddr, uint16_t updateDataLen, uint8_t* updateData) { - size_t serializedSize = 0; uint8_t* data = payloadStart; if (updateDataLen % 2 != 0) { spParams.setPayloadLen(META_DATA_LENGTH + updateDataLen + 1); @@ -1131,13 +1130,14 @@ class WriteMemory : public ploc::SpTcBase { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - SerializeAdapter::serialize(&memoryId, &data, &serializedSize, sizeof(memoryId), + size_t serializedSize = 6; + SerializeAdapter::serialize(&memoryId, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); - SerializeAdapter::serialize(&n, &data, &serializedSize, sizeof(n), + SerializeAdapter::serialize(&n, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); - SerializeAdapter::serialize(&startAddr, &data, &serializedSize, sizeof(startAddr), + SerializeAdapter::serialize(&startAddr, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); - SerializeAdapter::serialize(&updateDataLen, &data, &serializedSize, sizeof(updateDataLen), + SerializeAdapter::serialize(&updateDataLen, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); std::memcpy(data, updateData, updateDataLen); if (updateDataLen % 2 != 0) { @@ -1178,17 +1178,15 @@ class EraseMemory : public ploc::SpTcBase { uint32_t length = 0; void initPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) { - size_t serializedSize = 0; uint8_t* data = payloadStart; - SerializeAdapter::serialize(&memoryId, &data, &serializedSize, sizeof(memoryId), + size_t serializedSize = 6; + SerializeAdapter::serialize(&memoryId, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); - SerializeAdapter::serialize(&n, &data, &serializedSize, sizeof(n), + SerializeAdapter::serialize(&n, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&startAddress, &data, &serializedSize, sizeof(startAddress), + SerializeAdapter::serialize(&startAddress, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); - serializedSize = 0; - SerializeAdapter::serialize(&length, &data, &serializedSize, sizeof(length), + SerializeAdapter::serialize(&length, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); } }; diff --git a/linux/devices/ploc/PlocSupvHelper.cpp b/linux/devices/ploc/PlocSupvHelper.cpp index 25566b11..de1fae0f 100644 --- a/linux/devices/ploc/PlocSupvHelper.cpp +++ b/linux/devices/ploc/PlocSupvHelper.cpp @@ -161,26 +161,32 @@ void PlocSupvHelper::stopProcess() { terminate = true; } ReturnValue_t PlocSupvHelper::performUpdate() { ReturnValue_t result = RETURN_OK; + sif::info << "PlocSupvHelper::performUpdate: Calculating Image CRC" << std::endl; result = calcImageCrc(); if (result != RETURN_OK) { return result; } + sif::info << "PlocSupvHelper::performUpdate: Selecting Memory" << std::endl; result = selectMemory(); if (result != RETURN_OK) { return result; } + sif::info << "PlocSupvHelper::performUpdate: Preparing Update" << std::endl; result = prepareUpdate(); if (result != RETURN_OK) { return result; } + sif::info << "PlocSupvHelper::performUpdate: Erasing Memory" << std::endl; result = eraseMemory(); if (result != RETURN_OK) { return result; } + sif::info << "PlocSupvHelper::performUpdate: Writing Update Packets" << std::endl; result = writeUpdatePackets(); if (result != RETURN_OK) { return result; } + sif::info << "PlocSupvHelper::performUpdate: Memory Check" << std::endl; result = handleCheckMemoryCommand(); if (result != RETURN_OK) { return result; @@ -317,6 +323,9 @@ ReturnValue_t PlocSupvHelper::prepareUpdate() { resetSpParams(); supv::ApidOnlyPacket packet(spParams, supv::APID_PREPARE_UPDATE); result = packet.buildPacket(); + if (result != RETURN_OK) { + return result; + } result = handlePacketTransmission(packet, PREPARE_UPDATE_EXECUTION_REPORT); if (result != RETURN_OK) { return result; diff --git a/linux/devices/ploc/PlocSupvHelper.h b/linux/devices/ploc/PlocSupvHelper.h index c17521d9..66b5d00a 100644 --- a/linux/devices/ploc/PlocSupvHelper.h +++ b/linux/devices/ploc/PlocSupvHelper.h @@ -178,11 +178,11 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha #ifdef XIPHOS_Q7S SdCardManager* sdcMan = nullptr; #endif - uint8_t commandBuffer[supv::MAX_COMMAND_SIZE]; + uint8_t commandBuffer[supv::MAX_COMMAND_SIZE]{}; SpacePacketCreator creator; ploc::SpTcParams spParams = ploc::SpTcParams(creator); - std::array tmBuf; + std::array tmBuf{}; bool terminate = false; diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index b01e64ed..0d1f72db 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -785,30 +785,30 @@ void IMTQHandler::fillRawMtmDataset(const uint8_t* packet) { int32_t yRaw = 0; int32_t zRaw = 0; uint32_t coilActStatus = 0; - auto res = SerializeAdapter::deSerialize(&xRaw, &dataStart, &deSerLen, - SerializeIF::Endianness::LITTLE); - if(res != HasReturnvaluesIF::RETURN_OK) { + auto res = + SerializeAdapter::deSerialize(&xRaw, &dataStart, &deSerLen, SerializeIF::Endianness::LITTLE); + if (res != HasReturnvaluesIF::RETURN_OK) { return; } - res = SerializeAdapter::deSerialize(&yRaw, &dataStart, &deSerLen, - SerializeIF::Endianness::LITTLE); - if(res != HasReturnvaluesIF::RETURN_OK) { + res = + SerializeAdapter::deSerialize(&yRaw, &dataStart, &deSerLen, SerializeIF::Endianness::LITTLE); + if (res != HasReturnvaluesIF::RETURN_OK) { return; } - res = SerializeAdapter::deSerialize(&zRaw, &dataStart, &deSerLen, - SerializeIF::Endianness::LITTLE); - if(res != HasReturnvaluesIF::RETURN_OK) { + res = + SerializeAdapter::deSerialize(&zRaw, &dataStart, &deSerLen, SerializeIF::Endianness::LITTLE); + if (res != HasReturnvaluesIF::RETURN_OK) { return; } res = SerializeAdapter::deSerialize(&coilActStatus, &dataStart, &deSerLen, - SerializeIF::Endianness::LITTLE); - if(res != HasReturnvaluesIF::RETURN_OK) { + SerializeIF::Endianness::LITTLE); + if (res != HasReturnvaluesIF::RETURN_OK) { return; } rawMtmMeasurementSet.mtmRawNt[0] = xRaw * 7.5; rawMtmMeasurementSet.mtmRawNt[1] = yRaw * 7.5; rawMtmMeasurementSet.mtmRawNt[2] = zRaw * 7.5; - rawMtmMeasurementSet.coilActuationStatus = static_cast(coilActStatus); + rawMtmMeasurementSet.coilActuationStatus = static_cast(coilActStatus); rawMtmMeasurementSet.setValidity(true, true); if (debugMode) { #if OBSW_VERBOSE_LEVEL >= 1 diff --git a/tmtc b/tmtc index 00e99292..1b39bb2a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 00e99292cc158a347f485507537fa5b63262243b +Subproject commit 1b39bb2ad2421db89487b4ea352edbd4d420b9b1