Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DpWriter #2593

Merged
merged 14 commits into from
Mar 28, 2024
10 changes: 10 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ BUFFERALLOCATIONFAILED
BUFFERGETOUT
BUFFERMANAGERCOMPONENTIMPLCFG
BUFFERMGR
BUFFERTOOSMALLFORPACKET
BUFFQUEUEIN
buffsize
BUGLIST
Expand Down Expand Up @@ -267,6 +268,7 @@ doxyindexer
doxyrules
doxysearch
Doxywizard
DPCFG
dpi
DPMANAGER
DPWRITER
Expand Down Expand Up @@ -330,6 +332,7 @@ fadvise
FAKELOGGER
fallocate
fbuild
fdp
fdset
FEEDNAME
ffff
Expand All @@ -338,8 +341,11 @@ filedown
FILEDOWNLINK
FILEDOWNLINKCFG
FILEID
FILENAMESTRING
fileopen
FILEOPENERROR
FILESTUBS
FILEWRITEERROR
fio
Firefox
FLDP
Expand Down Expand Up @@ -480,6 +486,9 @@ integertypename
interoperate
intlimits
inttype
INVALIDBUFFER
INVALIDHEADER
INVALIDHEADERHASH
invisi
ioc
ioctl
Expand Down Expand Up @@ -774,6 +783,7 @@ PRMDBIMPLTESTER
PRMDBLIMPLCFG
prmname
probs
PROCBUFFERSENDOUT
PRODUCTGETIN
PRODUCTREQUESTIN
PRODUCTRESPONSEOUT
Expand Down
1 change: 1 addition & 0 deletions Fw/Cfg/SerIds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace Fw {
FW_TYPEID_INTERNAL_INTERFACE_STRING = 51, //!< interface string Buffer type id
FW_TYPEID_FIXED_LENGTH_STRING = 52, //!< 256 char string Buffer type id
FW_TYPEID_OBJECT_NAME = 53, //!< ObjectName string Buffer type id
FW_TYPEID_FILE_NAME_STRING = 54, //!< FileName string Buffer type id
};
}

Expand Down
6 changes: 4 additions & 2 deletions Fw/Types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
# Note: using PROJECT_NAME as EXECUTABLE_NAME
####

set(SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/Types.fpp"
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/Assert.cpp"
"${CMAKE_CURRENT_LIST_DIR}/String.cpp"
"${CMAKE_CURRENT_LIST_DIR}/FileNameString.cpp"
"${CMAKE_CURRENT_LIST_DIR}/InternalInterfaceString.cpp"
"${CMAKE_CURRENT_LIST_DIR}/MallocAllocator.cpp"
"${CMAKE_CURRENT_LIST_DIR}/MemAllocator.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ObjectName.cpp"
"${CMAKE_CURRENT_LIST_DIR}/PolyType.cpp"
"${CMAKE_CURRENT_LIST_DIR}/SerialBuffer.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Serializable.cpp"
"${CMAKE_CURRENT_LIST_DIR}/String.cpp"
"${CMAKE_CURRENT_LIST_DIR}/StringType.cpp"
"${CMAKE_CURRENT_LIST_DIR}/StringUtils.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Types.fpp"
)
set(MOD_DEPS
Fw/Cfg
Expand Down
54 changes: 54 additions & 0 deletions Fw/Types/FileNameString.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "Fw/Types/FileNameString.hpp"
#include "Fw/Types/StringUtils.hpp"

namespace Fw {

FileNameString::FileNameString(const char* src) : StringBase() {
(void)Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.
}

FileNameString::FileNameString(const StringBase& src) : StringBase() {
(void)Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.
}

FileNameString::FileNameString(const FileNameString& src) : StringBase() {
(void)Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf));

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.
}

FileNameString::FileNameString() : StringBase() {
this->m_buf[0] = 0;
}

FileNameString& FileNameString::operator=(const FileNameString& other) {
if (this == &other) {
return *this;
}

(void)Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
return *this;
}

FileNameString& FileNameString::operator=(const StringBase& other) {
if (this == &other) {
return *this;
}

(void)Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf));
timcanham marked this conversation as resolved.
Show resolved Hide resolved
return *this;
}

FileNameString& FileNameString::operator=(const char* other) {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

other uses the basic integral type char rather than a typedef with size and signedness.
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter other has not been checked.

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
string_copy
is not checked.
return *this;
}

FileNameString::~FileNameString() {}
Dismissed Show dismissed Hide dismissed

const char* FileNameString::toChar() const {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

toChar uses the basic integral type char rather than a typedef with size and signedness.
return this->m_buf;
}

NATIVE_UINT_TYPE FileNameString::getCapacity() const {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

getCapacity uses the basic integral type unsigned int rather than a typedef with size and signedness.
return STRING_SIZE;
}
} // namespace Fw
37 changes: 37 additions & 0 deletions Fw/Types/FileNameString.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef FW_FILENAMESTRING_HPP
#define FW_FILENAMESTRING_HPP

#include <FpConfig.hpp>

#include "Fw/Cfg/SerIds.hpp"
#include "Fw/Types/StringType.hpp"
#include "config/FppConstantsAc.hpp"

namespace Fw {

class FileNameString : public Fw::StringBase {
public:
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_FILE_NAME_STRING, //!< typeid for string type
STRING_SIZE = FileNameStringSize, //!< Storage for string
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwBuffSizeType) //!< Serialized size is size of buffer + size field
};

explicit FileNameString(const char* src); //!< char* source constructor
explicit FileNameString(const StringBase& src); //!< other string constructor
explicit FileNameString(const FileNameString& src); //!< String string constructor
FileNameString(); //!< default constructor
FileNameString& operator=(const FileNameString& other); //!< assignment operator
FileNameString& operator=(const StringBase& other); //!< other string assignment operator
FileNameString& operator=(const char* other); //!< char* assignment operator
~FileNameString(); //!< destructor

const char* toChar() const; //!< gets char buffer
NATIVE_UINT_TYPE getCapacity() const; //!< return buffer size

private:
char m_buf[FileNameString::STRING_SIZE]; //!< storage for string data

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

#endif
25 changes: 16 additions & 9 deletions Os/Stub/test/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ namespace Test {
StaticData StaticData::data;

void StaticData::setNextStatus(Os::File::Status status) {
StaticData::data.nextStatus = status;
StaticData::data.openStatus = status;
StaticData::data.sizeStatus = status;
StaticData::data.positionStatus = status;
StaticData::data.preallocateStatus = status;
StaticData::data.seekStatus = status;
StaticData::data.flushStatus = status;
StaticData::data.readStatus = status;
StaticData::data.writeStatus = status;
}

void StaticData::setSizeResult(FwSignedSizeType size) {
Expand Down Expand Up @@ -52,7 +59,7 @@ FileInterface::Status TestFile::open(const char *filepath, Mode open_mode, Overw
StaticData::data.openOverwrite = overwrite;
StaticData::data.lastCalled = StaticData::OPEN_FN;
StaticData::data.pointer = 0;
return StaticData::data.nextStatus;
return StaticData::data.openStatus;
}

void TestFile::close() {
Expand All @@ -62,32 +69,32 @@ void TestFile::close() {
FileInterface::Status TestFile::size(FwSignedSizeType& size_result) {
StaticData::data.lastCalled = StaticData::SIZE_FN;
size_result = StaticData::data.sizeResult;
return StaticData::data.nextStatus;
return StaticData::data.sizeStatus;
}

FileInterface::Status TestFile::position(FwSignedSizeType& position_result) {
StaticData::data.lastCalled = StaticData::POSITION_FN;
position_result = StaticData::data.positionResult;
return StaticData::data.nextStatus;
return StaticData::data.positionStatus;
}

FileInterface::Status TestFile::preallocate(FwSignedSizeType offset, FwSignedSizeType length) {
StaticData::data.preallocateOffset = offset;
StaticData::data.preallocateLength = length;
StaticData::data.lastCalled = StaticData::PREALLOCATE_FN;
return StaticData::data.nextStatus;
return StaticData::data.preallocateStatus;
}

FileInterface::Status TestFile::seek(FwSignedSizeType offset, SeekType seekType) {
StaticData::data.seekOffset = offset;
StaticData::data.seekType = seekType;
StaticData::data.lastCalled = StaticData::SEEK_FN;
return StaticData::data.nextStatus;
return StaticData::data.seekStatus;
}

FileInterface::Status TestFile::flush() {
StaticData::data.lastCalled = StaticData::FLUSH_FN;
return StaticData::data.nextStatus;
return StaticData::data.flushStatus;
}

FileInterface::Status TestFile::read(U8 *buffer, FwSignedSizeType &size, WaitType wait) {
Expand All @@ -103,7 +110,7 @@ FileInterface::Status TestFile::read(U8 *buffer, FwSignedSizeType &size, WaitTyp
} else {
size = StaticData::data.readSizeResult;
}
return StaticData::data.nextStatus;
return StaticData::data.readStatus;
}

FileInterface::Status TestFile::write(const U8* buffer, FwSignedSizeType &size, WaitType wait) {
Expand All @@ -119,7 +126,7 @@ FileInterface::Status TestFile::write(const U8* buffer, FwSignedSizeType &size,
} else {
size = StaticData::data.writeSizeResult;
}
return StaticData::data.nextStatus;
return StaticData::data.writeStatus;
}

FileHandle* TestFile::getHandle() {
Expand Down
19 changes: 17 additions & 2 deletions Os/Stub/test/File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,23 @@ struct StaticData {
//! File pointer
FwSignedSizeType pointer = 0;

//! Next status to be returned
Os::File::Status nextStatus = Os::File::Status::OTHER_ERROR;
//! Status to return from open
Os::File::Status openStatus = Os::File::Status::OP_OK;
//! Status to return from size
Os::File::Status sizeStatus = Os::File::Status::OP_OK;
//! Status to return from position
Os::File::Status positionStatus = Os::File::Status::OP_OK;
//! Status to return from preallocate
Os::File::Status preallocateStatus = Os::File::Status::OP_OK;
//! Status to return from seek
Os::File::Status seekStatus = Os::File::Status::OP_OK;
//! Status to return from flush
Os::File::Status flushStatus = Os::File::Status::OP_OK;
//! Status to return from read
Os::File::Status readStatus = Os::File::Status::OP_OK;
//! Status to return from write
Os::File::Status writeStatus = Os::File::Status::OP_OK;

//! Return of next size call
FwSignedSizeType sizeResult = -1;
//! Return of next position call
Expand Down
2 changes: 1 addition & 1 deletion Os/test/ut/file/SyntheticFileSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// \title Os/test/ut/file/SyntheticFileSystem.hpp
// \brief standard template library driven synthetic file system definitions
// ======================================================================
#include "config/FpConfig.h"
#include <FpConfig.h>
#include "Os/File.hpp"
#include <map>
#include <memory>
Expand Down
2 changes: 2 additions & 0 deletions Svc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/CmdSequencer/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/CmdSplitter/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Deframer/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DpManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DpPorts/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DpWriter/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FileDownlinkPorts/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FileDownlink/")
Expand Down
3 changes: 2 additions & 1 deletion Svc/Deframer/Deframer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
#ifndef Svc_Deframer_HPP
#define Svc_Deframer_HPP

#include <DeframerCfg.hpp>

#include "Svc/Deframer/DeframerComponentAc.hpp"
#include "Svc/FramingProtocol/DeframingProtocol.hpp"
#include "Svc/FramingProtocol/DeframingProtocolInterface.hpp"
#include "Utils/Types/CircularBuffer.hpp"
#include "config/DeframerCfg.hpp"

namespace Svc {

Expand Down
2 changes: 1 addition & 1 deletion Svc/DpManager/DpManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
this->productSendOut_out(portNum, sendBuffer);
}

void DpManager::schedIn_handler(const NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) {
void DpManager::schedIn_handler(const NATIVE_INT_TYPE portNum, U32 context) {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

portNum uses the basic integral type int rather than a typedef with size and signedness.
// Emit telemetry
this->tlmWrite_NumSuccessfulAllocations(this->numSuccessfulAllocations);
this->tlmWrite_NumFailedAllocations(this->numFailedAllocations);
Expand Down
2 changes: 1 addition & 1 deletion Svc/DpManager/DpManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DpManager : public DpManagerComponentBase {

//! Handler implementation for schedIn
void schedIn_handler(const NATIVE_INT_TYPE portNum, //!< The port number
NATIVE_UINT_TYPE context //!< The call order
U32 context //!< The call order
) final;

PRIVATE:
Expand Down
5 changes: 2 additions & 3 deletions Svc/DpManager/test/ut/AbstractState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
//
// \copyright
// Copyright (C) 2023 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged. Any commercial use must be negotiated with the Office
// of Technology Transfer at the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government sponsorship
// acknowledged.
// ======================================================================

#ifndef Svc_AbstractState_HPP
Expand Down
4 changes: 3 additions & 1 deletion Svc/DpManager/test/ut/DpManagerTestMain.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// ======================================================================
// TestMain.cpp
// \title DpWriterTestMain.cpp
// \author bocchino
// \brief cpp file for DpWriter component test main function
// ======================================================================

#include "Fw/Test/UnitTest.hpp"
Expand Down
3 changes: 3 additions & 0 deletions Svc/DpManager/test/ut/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ This rule sends the `CLEAR_EVENT_THROTTLE` command.
1. Apply rule `CLEAR_EVENT_THROTTLE::OK`.
1. Apply rule `ProductRequestIn::BufferInvalid`

**Requirements tested:**
`SVC-DPMANAGER-006`

## 3. Implementation

### 3.1. DpManagerTester and TestState
Expand Down
5 changes: 2 additions & 3 deletions Svc/DpManager/test/ut/Rules/BufferGetStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
//
// \copyright
// Copyright (C) 2023 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged. Any commercial use must be negotiated with the Office
// of Technology Transfer at the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government sponsorship
// acknowledged.
// ======================================================================

#include "Svc/DpManager/test/ut/Rules/BufferGetStatus.hpp"
Expand Down
5 changes: 2 additions & 3 deletions Svc/DpManager/test/ut/Rules/BufferGetStatus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
//
// \copyright
// Copyright (C) 2023 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged. Any commercial use must be negotiated with the Office
// of Technology Transfer at the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government sponsorship
// acknowledged.
// ======================================================================

#ifndef Svc_BufferGetStatus_HPP
Expand Down
Loading
Loading