diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..7ad9489e25 --- /dev/null +++ b/.clang-format @@ -0,0 +1,5 @@ +--- +BasedOnStyle: Chromium +IndentWidth: 4 +ColumnLimit: 120 +AccessModifierOffset: -2 \ No newline at end of file diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 03d61a73de..9a7fa3a1e2 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -211,6 +211,7 @@ COMQUEUE COMQUEUEIN COMSPLITTER COMSTUB +COMXBEE Concat config configparser @@ -1597,6 +1598,7 @@ wxgui Xabcdefx xapian xargs +XBee xcode xdf xdffe diff --git a/Drv/TcpClient/TcpClientComponentImpl.cpp b/Drv/TcpClient/TcpClientComponentImpl.cpp index 05aec9270b..7da685df0c 100644 --- a/Drv/TcpClient/TcpClientComponentImpl.cpp +++ b/Drv/TcpClient/TcpClientComponentImpl.cpp @@ -68,13 +68,14 @@ void TcpClientComponentImpl::connected() { Drv::SendStatus TcpClientComponentImpl::send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer) { Drv::SocketIpStatus status = m_socket.send(fwBuffer.getData(), fwBuffer.getSize()); - // Always return the buffer - deallocate_out(0, fwBuffer); - if ((status == SOCK_DISCONNECTED) || (status == SOCK_INTERRUPTED_TRY_AGAIN)) { + // Only deallocate buffer when the caller is not asked to retry + if (status == SOCK_INTERRUPTED_TRY_AGAIN) { return SendStatus::SEND_RETRY; } else if (status != SOCK_SUCCESS) { + deallocate_out(0, fwBuffer); return SendStatus::SEND_ERROR; } + deallocate_out(0, fwBuffer); return SendStatus::SEND_OK; } diff --git a/Drv/TcpServer/TcpServerComponentImpl.cpp b/Drv/TcpServer/TcpServerComponentImpl.cpp index 86f65abd70..773abd2f1c 100644 --- a/Drv/TcpServer/TcpServerComponentImpl.cpp +++ b/Drv/TcpServer/TcpServerComponentImpl.cpp @@ -75,13 +75,14 @@ void TcpServerComponentImpl::connected() { Drv::SendStatus TcpServerComponentImpl::send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer) { Drv::SocketIpStatus status = m_socket.send(fwBuffer.getData(), fwBuffer.getSize()); - // Always return the buffer - deallocate_out(0, fwBuffer); - if ((status == SOCK_DISCONNECTED) || (status == SOCK_INTERRUPTED_TRY_AGAIN)) { + // Only deallocate buffer when the caller is not asked to retry + if (status == SOCK_INTERRUPTED_TRY_AGAIN) { return SendStatus::SEND_RETRY; } else if (status != SOCK_SUCCESS) { + deallocate_out(0, fwBuffer); return SendStatus::SEND_ERROR; } + deallocate_out(0, fwBuffer); return SendStatus::SEND_OK; } diff --git a/Fw/Types/MemAllocator.hpp b/Fw/Types/MemAllocator.hpp index 521300f3a5..d352a4a073 100644 --- a/Fw/Types/MemAllocator.hpp +++ b/Fw/Types/MemAllocator.hpp @@ -27,7 +27,9 @@ * appropriate. * * The identifier can be used to look up a pre-allocated buffer by ID in an - * embedded system. + * embedded system. Identifiers may be used only in a single call to an invocation. + * Some implementations of MemAllocator discard the identifier but components using + * the MemAllocator interface should not depend on the identifier to be discarded. * * The size is the requested size of the memory. If the allocator cannot return the * requested amount, it should return the actual amount and users should check. @@ -45,7 +47,7 @@ namespace Fw { public: //! Allocate memory /*! - * \param identifier the memory segment identifier (if needed) + * \param identifier the memory segment identifier, each identifier is to be used in once single allocation * \param size the requested size - changed to actual if different * \param recoverable - flag to indicate the memory could be recoverable * \return the pointer to memory. Zero if unable to allocate @@ -56,7 +58,7 @@ namespace Fw { bool& recoverable)=0; //! Deallocate memory /*! - * \param identifier the memory segment identifier (if needed) + * \param identifier the memory segment identifier, each identifier is to be used in once single allocation * \param ptr the pointer to memory returned by allocate() */ virtual void deallocate( diff --git a/docs/Design/communication-adapter-interface.md b/docs/Design/communication-adapter-interface.md index b4cf46f2e1..d26971aa62 100644 --- a/docs/Design/communication-adapter-interface.md +++ b/docs/Design/communication-adapter-interface.md @@ -85,7 +85,7 @@ transmissions. This is done with the `comStatus` port. A communication status is | Fw::Success::SUCCESS | *Communication adapter* transmission succeeded and is ready for more data. | | Fw::Success::FAILURE | Last transmission failed; *communication adapter* is unable to receive more data. | -> * Fw::Success::SUCCESS may also indicate a connection/reconnection success when data flow must be initiated. +* Fw::Success::SUCCESS may also indicate a connection/reconnection success when data flow must be initiated. A *Communication Adapter* shall emit either Fw::Success::SUCCESS or Fw::Success::FAILURE via the `comStatus` port once for each call received on `comDataIn`. Additionally, a *Communication Adapter* shall emit Fw::Success::SUCCESS once at