From b9ad396fb478dcc155efc42521686ea2b9efd66a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 26 Apr 2024 16:23:28 +0200 Subject: [PATCH] some important bugfixes --- linux/payload/plocMpsocHelpers.h | 32 ++++++++++++++------------------ tmtc | 2 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index f2b4c48d..b3a1f23d 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -17,7 +17,7 @@ namespace mpsoc { static constexpr uint32_t DEFAULT_CMD_TIMEOUT_MS = 5000; static constexpr uint32_t CMD_TIMEOUT_MKFS = 15000; -enum FlashId : uint8_t { FLASH_0 = 0, FLASH_1 = 0 }; +enum FlashId : uint8_t { FLASH_0 = 0, FLASH_1 = 1 }; static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_RETURN_VALUES_IF; @@ -504,14 +504,14 @@ class TcFlashMkfs : public TcBase { public: TcFlashMkfs(ploc::SpTcParams params, uint16_t sequenceCount, FlashId flashId) : TcBase(params, apid::TC_FLASH_MKFS, sequenceCount) { - spParams.setFullPayloadLen(1 + CRC_SIZE); - const char* flashIdStr = "0:/"; + const char* flashIdStr = "0:\\"; if (flashId == FlashId::FLASH_1) { - flashIdStr = "1:/"; + flashIdStr = "1:\\"; } std::memcpy(payloadStart, flashIdStr, 3); // Null terminator payloadStart[3] = 0; + spParams.setFullPayloadLen(4 + CRC_SIZE); } }; @@ -1079,29 +1079,25 @@ class TcSimplexStoreFile : public TcBase { return INVALID_PARAMETER; } std::string fileName(reinterpret_cast(*dataPtr)); - if (fileName.size() + sizeof(NULL_TERMINATOR) > FILENAME_FIELD_SIZE) { + if (fileName.size() > MAX_FILENAME_SIZE) { return FILENAME_TOO_LONG; } - size_t currentCopyIdx = 0; - size_t payloadLen = fileName.length() + sizeof(NULL_TERMINATOR) + CRC_SIZE; - if (chunkParameter > 1) { - char divStr[16]{}; - sprintf(divStr, "DIV%03u", chunkParameter); - std::memcpy(payloadStart, divStr, DIV_STR_LEN); - payloadLen += DIV_STR_LEN; - currentCopyIdx += DIV_STR_LEN; - } - - std::memcpy(payloadStart + currentCopyIdx, *dataPtr, fileName.length()); - spParams.setFullPayloadLen(payloadLen); + sif::debug << "file name: " << fileName << std::endl; + char divStr[16]{}; + sprintf(divStr, "DIV%03u", chunkParameter); + sif::debug << "div str: " << divStr << std::endl; + std::memcpy(payloadStart, divStr, DIV_STR_LEN); + std::memset(payloadStart + DIV_STR_LEN, 0, FILENAME_FIELD_SIZE); + std::memcpy(payloadStart + DIV_STR_LEN, fileName.data(), fileName.length()); + spParams.setFullPayloadLen(DIV_STR_LEN + FILENAME_FIELD_SIZE + CRC_SIZE); return returnvalue::OK; } private: uint32_t chunkParameter = 0; - static constexpr size_t MAX_DATA_LENGTH = 256; static constexpr size_t MIN_DATA_LENGTH = 4; static constexpr size_t DIV_STR_LEN = 6; + static constexpr size_t MAX_DATA_LENGTH = DIV_STR_LEN + FILENAME_FIELD_SIZE; }; /** diff --git a/tmtc b/tmtc index a59aceda..f9041f21 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a59aceda751bd1594b91c632fe0ae85b844707df +Subproject commit f9041f215aa39df2df314b6353c098853ac64426