diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index 56112520..7c04e9f5 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 314 translations. * @details - * Generated on: 2023-10-13 09:44:05 + * Generated on: 2023-10-13 15:23:30 */ #include "translateEvents.h" diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index 7916bfeb..5cb8e295 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 174 translations. - * Generated on: 2023-10-13 09:44:05 + * Generated on: 2023-10-13 15:23:30 */ #include "translateObjects.h" diff --git a/generators/bsp_hosted_returnvalues.csv b/generators/bsp_hosted_returnvalues.csv index e8d79402..1964e00e 100644 --- a/generators/bsp_hosted_returnvalues.csv +++ b/generators/bsp_hosted_returnvalues.csv @@ -521,5 +521,5 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x6e01;PTM_BusyDumping;No description;1;PERSISTENT_TM_STORE;mission/tmtc/PersistentTmStore.h 0x6f00;TMS_IsBusy;No description;0;TM_SINK;mission/tmtc/DirectTmSinkIF.h 0x6f01;TMS_PartiallyWritten;No description;1;TM_SINK;mission/tmtc/DirectTmSinkIF.h -0x6f02;TMS_IncompletePartialWrite;No description;2;TM_SINK;mission/tmtc/DirectTmSinkIF.h +0x6f02;TMS_NoWriteActive;No description;2;TM_SINK;mission/tmtc/DirectTmSinkIF.h 0x7000;VCS_ChannelDoesNotExist;No description;0;VIRTUAL_CHANNEL;mission/com/VirtualChannel.h diff --git a/generators/bsp_q7s_returnvalues.csv b/generators/bsp_q7s_returnvalues.csv index 0d08c2b7..9aa12b12 100644 --- a/generators/bsp_q7s_returnvalues.csv +++ b/generators/bsp_q7s_returnvalues.csv @@ -616,6 +616,6 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x6e01;PTM_BusyDumping;No description;1;PERSISTENT_TM_STORE;mission/tmtc/PersistentTmStore.h 0x6f00;TMS_IsBusy;No description;0;TM_SINK;mission/tmtc/DirectTmSinkIF.h 0x6f01;TMS_PartiallyWritten;No description;1;TM_SINK;mission/tmtc/DirectTmSinkIF.h -0x6f02;TMS_IncompletePartialWrite;No description;2;TM_SINK;mission/tmtc/DirectTmSinkIF.h +0x6f02;TMS_NoWriteActive;No description;2;TM_SINK;mission/tmtc/DirectTmSinkIF.h 0x7000;VCS_ChannelDoesNotExist;No description;0;VIRTUAL_CHANNEL;mission/com/VirtualChannel.h 0x7200;SCBU_KeyNotFound;No description;0;SCRATCH_BUFFER;bsp_q7s/memory/scratchApi.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 56112520..7c04e9f5 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 314 translations. * @details - * Generated on: 2023-10-13 09:44:05 + * Generated on: 2023-10-13 15:23:30 */ #include "translateEvents.h" diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 96e07335..5b99d6f0 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 178 translations. - * Generated on: 2023-10-13 09:44:05 + * Generated on: 2023-10-13 15:23:30 */ #include "translateObjects.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 56112520..7c04e9f5 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 314 translations. * @details - * Generated on: 2023-10-13 09:44:05 + * Generated on: 2023-10-13 15:23:30 */ #include "translateEvents.h" diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 96e07335..5b99d6f0 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 178 translations. - * Generated on: 2023-10-13 09:44:05 + * Generated on: 2023-10-13 15:23:30 */ #include "translateObjects.h" diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index d5207c0b..239ed091 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -32,8 +32,8 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size, size_t& w if (size < 4) { return returnvalue::FAILED; } - // The user must call finishWrite before starting a new packet transfer. - if (writeActive) { + // The user must call advance until completion before starting a new packet transfer. + if (writeActiveStatus) { return IS_BUSY; } if (size > packetBuf.capacity()) { @@ -60,11 +60,6 @@ void PapbVcInterface::startPacketTransfer(ByteWidthCfg initWidth) { *vcBaseReg = CONFIG_DATA_INPUT | initWidth; } -void PapbVcInterface::completePacketTransfer() { - *vcBaseReg = CONFIG_END; - writeActive = false; -} - bool PapbVcInterface::pollReadyForPacket() const { // Check if PAPB interface is ready to receive data. Use the configuration register for this. // Bit 5, see PTME ptme_001_01-0-7-r2 Table 31. @@ -73,6 +68,9 @@ bool PapbVcInterface::pollReadyForPacket() const { } ReturnValue_t PapbVcInterface::advanceWrite(size_t& writtenSize) { + if (!writeActiveStatus) { + return NO_WRITE_ACTIVE; + } if (not pollReadyForPacket()) { return IS_BUSY; } @@ -95,6 +93,8 @@ ReturnValue_t PapbVcInterface::advanceWrite(size_t& writtenSize) { return returnvalue::OK; } +bool PapbVcInterface::writeActive() const { return writeActiveStatus; } + bool PapbVcInterface::isVcInterfaceBufferEmpty() { ReturnValue_t result = returnvalue::OK; gpio::Levels papbEmptyState = gpio::Levels::HIGH; @@ -131,4 +131,16 @@ inline bool PapbVcInterface::pollReadyForOctet(uint32_t maxCycles) const { return false; } -void PapbVcInterface::abortPacketTransfer() { *vcBaseReg = CONFIG_ABORT; } +void PapbVcInterface::abortPacketTransfer() { + *vcBaseReg = CONFIG_ABORT; + writeActiveStatus = false; + currentPacketIndex = 0; + currentPacketSize = 0; +} + +void PapbVcInterface::completePacketTransfer() { + *vcBaseReg = CONFIG_END; + writeActiveStatus = false; + currentPacketIndex = 0; + currentPacketSize = 0; +} diff --git a/linux/ipcore/PapbVcInterface.h b/linux/ipcore/PapbVcInterface.h index eb707b62..bcda5709 100644 --- a/linux/ipcore/PapbVcInterface.h +++ b/linux/ipcore/PapbVcInterface.h @@ -50,6 +50,8 @@ class PapbVcInterface : public VirtualChannelIF { void cancelTransfer() override; + bool writeActive() const override; + ReturnValue_t initialize() override; private: @@ -95,12 +97,11 @@ class PapbVcInterface : public VirtualChannelIF { std::vector packetBuf; std::string uioFile; int mapNum = 0; - bool writeActive = false; + bool writeActiveStatus = false; size_t currentPacketIndex = 0; size_t currentPacketSize = 0; mutable struct timespec nextDelay = {.tv_sec = 0, .tv_nsec = 0}; const struct timespec BETWEEN_POLL_DELAY = {.tv_sec = 0, .tv_nsec = 10}; - mutable struct timespec remDelay; volatile uint32_t* vcBaseReg = nullptr; diff --git a/mission/com/VirtualChannel.cpp b/mission/com/VirtualChannel.cpp index d6d792f4..93c83eeb 100644 --- a/mission/com/VirtualChannel.cpp +++ b/mission/com/VirtualChannel.cpp @@ -28,6 +28,13 @@ ReturnValue_t VirtualChannel::advanceWrite(size_t& writtenSize) { return ptme.getVirtChannel(vcId)->advanceWrite(writtenSize); } +bool VirtualChannel::writeActive() const { + if (!ptme.containsVc(vcId)) { + return CHANNEL_DOES_NOT_EXIST; + } + return ptme.getVirtChannel(vcId)->writeActive(); +} + const char* VirtualChannel::getName() const { return vcName.c_str(); } bool VirtualChannel::isBusy() const { diff --git a/mission/com/VirtualChannel.h b/mission/com/VirtualChannel.h index d8ac0228..84cdafb3 100644 --- a/mission/com/VirtualChannel.h +++ b/mission/com/VirtualChannel.h @@ -35,6 +35,7 @@ class VirtualChannel : public SystemObject, public VirtualChannelIF { ReturnValue_t advanceWrite(size_t& writtenSize) override; ReturnValue_t handleWriteCompletionSynchronously(size_t& writtenSize, unsigned maxCompletionTimeMs); + bool writeActive() const override; void cancelTransfer() override; uint8_t getVcid() const; bool isTxOn() const; diff --git a/mission/tmtc/DirectTmSinkIF.h b/mission/tmtc/DirectTmSinkIF.h index f5b43039..6ac182d2 100644 --- a/mission/tmtc/DirectTmSinkIF.h +++ b/mission/tmtc/DirectTmSinkIF.h @@ -14,21 +14,38 @@ class DirectTmSinkIF { static constexpr ReturnValue_t IS_BUSY = returnvalue::makeCode(CLASS_ID, 0); static constexpr ReturnValue_t PARTIALLY_WRITTEN = returnvalue::makeCode(CLASS_ID, 1); + static constexpr ReturnValue_t NO_WRITE_ACTIVE = returnvalue::makeCode(CLASS_ID, 2); /** - * @brief Implements the functionality to write to a TM sink directly + * @brief Implements the functionality to write to a TM sink directly. + * + * The write might not be completed immediately! If PARTIALLY_WRITTEN is returned, the user + * should poll the ready for packet status bit and call @advanceWrite continuously until + * the transfer is completed. * * @param data Pointer to buffer holding the data to write * @param size Number of bytes to write - * @return returnvalue::OK on success, returnvalue::FAILED on failure, IS_BUSY - * if the TM sink is busy, PARTIALLY_WRITTEN if only a portion of the bytes could be - * written. + * @param writtenSize Size written during write call. + * @return returnvalue::OK on full write success, IS_BUSY if a previous write transfer has not + * been completed yet or the PAPB interface is not ready for a packet, PARTIALLY_WRITTEN + * if some bytes were written, but the transfer has not been completed yet. */ virtual ReturnValue_t write(const uint8_t* data, size_t size, size_t& writtenSize) = 0; + /** + * Advances a active file transfer. + * @param writtenSize + * @return returnvalue::OK if the packet write process is complete, PARTIALLY_WRITTEN if + * some bytes were written but the transfer is not complete yet. + */ virtual ReturnValue_t advanceWrite(size_t& writtenSize) = 0; virtual bool isBusy() const = 0; + /** + * The PAPB interface is currently busy writing a packet and a new packet can not be written yet. + * @return + */ + virtual bool writeActive() const = 0; }; #endif /* MISSION_TMTC_DIRECTTMSINKIF_H_ */ diff --git a/tmtc b/tmtc index 10e163be..60f7ae54 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 10e163be752a6a259b6d3dabea825acc9c9725f8 +Subproject commit 60f7ae5453b387ee5ebcf6a338c34284004dbce7