Skip to content

Commit

Permalink
Merge branch 'devel' into sm-test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch committed Sep 18, 2024
2 parents fa3db99 + 3f8830b commit 2543824
Show file tree
Hide file tree
Showing 47 changed files with 957 additions and 219 deletions.
3 changes: 3 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ CMDPACKET
CMDREG
cmds
CMDSEQ
cmdsequencer
cnt
cntx
cobj
Expand Down Expand Up @@ -548,6 +549,7 @@ lammertbies
LASTLOG
LBLOCK
LCHILD
leisher
lemstarch
lestarch
levelname
Expand Down Expand Up @@ -1212,4 +1214,5 @@ xsh
xsltproc
xxxx
yacgen
zimri
zmq

Check warning on line 1218 in .github/actions/spelling/expect.txt

View workflow job for this annotation

GitHub Actions / Spell checking

No newline at eof. (no-newline-at-eof)
61 changes: 48 additions & 13 deletions CFDP/Checksum/Checksum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,38 @@
namespace CFDP {

//! \class Checksum
//! \brief Class representing a CFDP checksum
//! \brief Class representing a 32-bit checksum as mandated by the CCSDS File
//! Delivery Protocol.
//!
//! This checksum is calculated by update of an existing 32-bit value
//! with the "next" 32-bit string drawn from the file data. Beginning
//! at the start of the file, a 4-byte window moves up the file by four
//! bytes per update. The update itself replaces the existing checksum
//! with the byte-wise sum of the existing checksum and the file data
//! contained in the window. Overflows in the addition are permitted
//! and the carry discarded.
//!
//! If an update is to be made beginning at an offset into the file
//! which is not aligned to a 4-byte boundary, the window is treated
//! as beginning at the last 4-byte boundary, but is left-zero-padded.
//! Similarly, where the file data for an update ends on an unaligned
//! byte, the window extends up to the next boundary and is
//! right-zero-padded.
//!
//! ## Example
//!
//! For buffer 0xDE 0xAD 0xBE 0xEF 0xCA 0xFE and initial zero checksum:
//!
//! ------------------------------------ Update 1
//! Window 0xDE 0xAD 0xBE 0xEF
//! Checksum 0xDEADBEEF
//!
//! ------------------------------------ Update 2
//! Window 0xCA 0xFE
//! Checksum 0xDEADBEEF+
//! 0xCAFE0000
//! ----------
//! 0xA8ABBEEF <- Final value
class Checksum {

public:
Expand All @@ -34,16 +64,16 @@ namespace CFDP {
// Construction and destruction
// ----------------------------------------------------------------------

//! Construct a fresh Checksum object
//! Construct a fresh Checksum object.
Checksum();

//! Construct a Checksum object and initialize it with a value
//! Construct a Checksum object and initialize it with a value.
Checksum(const U32 value);

//! Copy a Checksum object
//! Copy a Checksum object.
Checksum(const Checksum &original);

//! Destroy a Checksum object
//! Destroy a Checksum object.
~Checksum();

public:
Expand All @@ -52,20 +82,25 @@ namespace CFDP {
// Public instance methods
// ----------------------------------------------------------------------

//! Assign checksum to this
//! Assign checksum to this.
Checksum& operator=(const Checksum& checksum);

//! Compare checksum and this for equality
//! Compare checksum and this for equality.
bool operator==(const Checksum& checksum) const;

//! Compare checksum and this for inequality
//! Compare checksum and this for inequality.
bool operator!=(const Checksum& checksum) const;

//! Update the checksum value by accumulating the words in the data
void update(
const U8 *const data, //!< The data
const U32 offset, //!< The offset of the start of the data, relative to the start of the file
const U32 length //!< The length of the data in bytes
//! Update the checksum value by accumulating words in the given data.
//!
//! \important The data and data-length passed to this method are specifically
//! those over which the update is made, rather than the entire
//! file. Typically, therefore, `data` will be a pointer to the
//! byte given by the offset, e.g. `&file_buffer[offset]`.
//!
void update(const U8* const data, //!< Beginning of the data over which to update.
const U32 offset, //!< Offset into the file at which the data begins.
const U32 length //!< Length of the update data in bytes.
);

//! Get the checksum value
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Contributors to the [fprime](https://github.com/nasa/fprime) repository should u
F´ follows a standard git flow development model. Developers should start with a
[fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) of one of the F´ repositories and then develop
according to [git flow](https://docs.github.com/en/get-started/quickstart/github-flow). Remember to add an
upstream remote to your fork such that you may fetch the latest changes.
[upstream remote](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) to your fork such that you may fetch the latest changes.

For each contribution, developers should first fetch the latest changes from upstream. Then create a new branch off
`devel` and submit back to F´ using a pull request as described above.
Expand Down
6 changes: 3 additions & 3 deletions Os/Posix/test/ut/PosixFileTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ bool check_permissions(const char* path, int permission) {
//!
std::shared_ptr<std::string> get_test_filename(bool random) {
const char* filename = TEST_FILE;
char full_buffer[PATH_MAX];
char buffer[PATH_MAX - sizeof(BASE_PATH)];
char full_buffer[_POSIX_PATH_MAX];
char buffer[_POSIX_PATH_MAX - sizeof(BASE_PATH)];
// When random, select random characters
if (random) {
filename = buffer;
Expand All @@ -47,7 +47,7 @@ std::shared_ptr<std::string> get_test_filename(bool random) {
}
buffer[i] = 0; // Terminate random string
}
(void) snprintf(full_buffer, PATH_MAX, "%s/%s", BASE_PATH, filename);
(void) snprintf(full_buffer, _POSIX_PATH_MAX, "%s/%s", BASE_PATH, filename);
// Create a shared pointer wrapping our filename buffer
std::shared_ptr<std::string> pointer(new std::string(full_buffer), std::default_delete<std::string>());
return pointer;
Expand Down
4 changes: 2 additions & 2 deletions Os/test/ut/file/FileRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void Os::Test::File::Tester::assert_file_seek(const FwSignedSizeType original_po
ASSERT_EQ(this->m_shadow.position(shadow_position), Os::File::Status::OP_OK);

const FwSignedSizeType expected_offset = (absolute) ? seek_desired : (original_position + seek_desired);
if (expected_offset > 0) {
if (expected_offset >= 0) {
ASSERT_EQ(new_position, expected_offset);
} else {
ASSERT_EQ(new_position, original_position);
Expand Down Expand Up @@ -497,7 +497,7 @@ void Os::Test::File::Tester::Preallocate::action(
state.assert_file_consistent();
FileState original_file_state = state.current_file_state();
FwSignedSizeType offset = static_cast<FwSignedSizeType>(STest::Pick::lowerUpper(0, FILE_DATA_MAXIMUM));
FwSignedSizeType length = static_cast<FwSignedSizeType>(STest::Pick::lowerUpper(0, FILE_DATA_MAXIMUM));
FwSignedSizeType length = static_cast<FwSignedSizeType>(STest::Pick::lowerUpper(1, FILE_DATA_MAXIMUM));
Os::File::Status status = state.m_file.preallocate(offset, length);
ASSERT_EQ(Os::File::Status::OP_OK, status);
state.shadow_preallocate(offset, length);
Expand Down
2 changes: 1 addition & 1 deletion Os/test/ut/file/SyntheticFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Os::File::Status SyntheticFile::seek(const FwSignedSizeType offset, const SeekTy
status = Os::File::Status::NOT_OPENED;
} else {
FwSignedSizeType new_offset = (absolute) ? offset : (offset + this->m_data->m_pointer);
if (new_offset > 0) {
if (new_offset >= 0) {
this->m_data->m_pointer = new_offset;
} else {
status = Os::File::Status::INVALID_ARGUMENT;
Expand Down
7 changes: 1 addition & 6 deletions Ref/Top/RefPackets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,7 @@
<channel name="systemResources.NON_VOLATILE_FREE"/>
</packet>

<packet name="SystemRes2" id="6" level="2">
<channel name="systemResources.FRAMEWORK_VERSION"/>
<channel name="systemResources.PROJECT_VERSION"/>
</packet>

<packet name="SystemRes3" id="7" level="2">
<packet name="SystemRes3" id="6" level="2">
<channel name="systemResources.CPU"/>
<channel name="systemResources.CPU_00"/>
<channel name="systemResources.CPU_01"/>
Expand Down
1 change: 1 addition & 0 deletions Svc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PassiveRateGroup")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PolyDb/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PrmDb/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/RateGroupDriver/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SeqDispatcher/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/StaticMemory/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TlmChan/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/TlmPacketizer/")
Expand Down
3 changes: 3 additions & 0 deletions Svc/CmdSequencer/CmdSequencer.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ module Svc {
@ Schedule in port
async input port schedIn: Svc.Sched

@ Notifies that a sequence has started running
output port seqStartOut: Svc.CmdSeqIn

# ----------------------------------------------------------------------
# Commands
# ----------------------------------------------------------------------
Expand Down
11 changes: 10 additions & 1 deletion Svc/CmdSequencer/CmdSequencerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ namespace Svc {
// Check the step mode. If it is auto, start the sequence
if (AUTO == this->m_stepMode) {
this->m_runMode = RUNNING;
if(this->isConnected_seqStartOut_OutputPort(0)) {
this->seqStartOut_out(0, this->m_sequence->getStringFileName());
}
this->performCmd_Step();
}

Expand Down Expand Up @@ -159,7 +162,7 @@ namespace Svc {
//! Handler for input port seqRunIn
void CmdSequencerComponentImpl::seqRunIn_handler(
NATIVE_INT_TYPE portNum,
Fw::String &filename
const Fw::StringBase& filename
) {

if (!this->requireRunMode(STOPPED)) {
Expand Down Expand Up @@ -190,6 +193,9 @@ namespace Svc {
// Check the step mode. If it is auto, start the sequence
if (AUTO == this->m_stepMode) {
this->m_runMode = RUNNING;
if(this->isConnected_seqStartOut_OutputPort(0)) {
this->seqStartOut_out(0, this->m_sequence->getStringFileName());
}
this->performCmd_Step();
}

Expand Down Expand Up @@ -359,6 +365,9 @@ namespace Svc {
this->m_runMode = RUNNING;
this->performCmd_Step();
this->log_ACTIVITY_HI_CS_CmdStarted(this->m_sequence->getLogFileName());
if(this->isConnected_seqStartOut_OutputPort(0)) {
this->seqStartOut_out(0, this->m_sequence->getStringFileName());
}
this->cmdResponse_out(opcode, cmdSeq, Fw::CmdResponse::OK);
}

Expand Down
9 changes: 8 additions & 1 deletion Svc/CmdSequencer/CmdSequencerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ namespace Svc {
//! \return The log file name
Fw::LogStringArg& getLogFileName();

//! Get the normal string file name
//! \return The normal string file name
Fw::String& getStringFileName();

//! Get the sequence header
const Header& getHeader() const;

Expand Down Expand Up @@ -277,6 +281,9 @@ namespace Svc {
//! Copy of file name for events
Fw::LogStringArg m_logFileName;

//! Copy of file name for ports
Fw::String m_stringFileName;

//! Serialize buffer to hold the binary sequence data
Fw::ExternalSerializeBuffer m_buffer;

Expand Down Expand Up @@ -582,7 +589,7 @@ namespace Svc {
//! Handler for input port seqRunIn
void seqRunIn_handler(
NATIVE_INT_TYPE portNum, //!< The port number
Fw::String &filename //!< The sequence file
const Fw::StringBase& filename //!< The sequence file
);

//! Handler for ping port
Expand Down
7 changes: 7 additions & 0 deletions Svc/CmdSequencer/Sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ namespace Svc {
{
this->m_fileName = fileName;
this->m_logFileName = fileName;
this->m_stringFileName = fileName;
}

Fw::CmdStringArg& CmdSequencerComponentImpl::Sequence ::
Expand All @@ -126,5 +127,11 @@ namespace Svc {
return this->m_logFileName;
}

Fw::String& CmdSequencerComponentImpl::Sequence ::
getStringFileName()
{
return this->m_stringFileName;
}

}

2 changes: 2 additions & 0 deletions Svc/ComQueue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ set(UT_SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/test/ut/ComQueueTestMain.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/ComQueueTester.cpp"
)

set(UT_AUTO_HELPERS ON)
register_fprime_ut()
32 changes: 26 additions & 6 deletions Svc/ComQueue/ComQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,19 @@ void ComQueue::configure(QueueConfigurationTable queueConfig,
void ComQueue::comQueueIn_handler(const NATIVE_INT_TYPE portNum, Fw::ComBuffer& data, U32 context) {
// Ensure that the port number of comQueueIn is consistent with the expectation
FW_ASSERT(portNum >= 0 && portNum < COM_PORT_COUNT, portNum);
this->enqueue(portNum, QueueType::COM_QUEUE, reinterpret_cast<const U8*>(&data), sizeof(Fw::ComBuffer));
(void)this->enqueue(portNum, QueueType::COM_QUEUE, reinterpret_cast<const U8*>(&data), sizeof(Fw::ComBuffer));
}

void ComQueue::buffQueueIn_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer) {
const NATIVE_INT_TYPE queueNum = portNum + COM_PORT_COUNT;
// Ensure that the port number of buffQueueIn is consistent with the expectation
FW_ASSERT(portNum >= 0 && portNum < BUFFER_PORT_COUNT, portNum);
FW_ASSERT(queueNum < TOTAL_PORT_COUNT);
this->enqueue(queueNum, QueueType::BUFFER_QUEUE, reinterpret_cast<const U8*>(&fwBuffer), sizeof(Fw::Buffer));
bool status =
this->enqueue(queueNum, QueueType::BUFFER_QUEUE, reinterpret_cast<const U8*>(&fwBuffer), sizeof(Fw::Buffer));
if (!status) {
this->deallocate_out(portNum, fwBuffer);
}
}

void ComQueue::comStatusIn_handler(const NATIVE_INT_TYPE portNum, Fw::Success& condition) {
Expand Down Expand Up @@ -181,29 +185,45 @@ void ComQueue::run_handler(const NATIVE_INT_TYPE portNum, U32 context) {
this->tlmWrite_buffQueueDepth(buffQueueDepth);
}

// ----------------------------------------------------------------------
// Hook implementations for typed async input ports
// ----------------------------------------------------------------------

void ComQueue::buffQueueIn_overflowHook(FwIndexType portNum, Fw::Buffer& fwBuffer) {
FW_ASSERT(portNum >= 0 && portNum < BUFFER_PORT_COUNT, portNum);
this->deallocate_out(portNum, fwBuffer);
}

// ----------------------------------------------------------------------
// Private helper methods
// ----------------------------------------------------------------------

void ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) {
bool ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) {
// Enqueue the given message onto the matching queue. When no space is available then emit the queue overflow event,
// set the appropriate throttle, and move on. Will assert if passed a message for a depth 0 queue.
const FwSizeType expectedSize = (queueType == QueueType::COM_QUEUE) ? sizeof(Fw::ComBuffer) : sizeof(Fw::Buffer);
const FwIndexType portNum = queueNum - ((queueType == QueueType::COM_QUEUE) ? 0 : COM_PORT_COUNT);
bool rvStatus = true;
FW_ASSERT(
expectedSize == size,
static_cast<FwAssertArgType>(size),
static_cast<FwAssertArgType>(expectedSize));
FW_ASSERT(portNum >= 0, portNum);
Fw::SerializeStatus status = this->m_queues[queueNum].enqueue(data, size);
if (status == Fw::FW_SERIALIZE_NO_ROOM_LEFT && !this->m_throttle[queueNum]) {
this->log_WARNING_HI_QueueOverflow(queueType, static_cast<U32>(portNum));
this->m_throttle[queueNum] = true;
if (status == Fw::FW_SERIALIZE_NO_ROOM_LEFT) {
if (!this->m_throttle[queueNum]) {
this->log_WARNING_HI_QueueOverflow(queueType, static_cast<U32>(portNum));
this->m_throttle[queueNum] = true;
}

rvStatus = false;
}
// When the component is already in READY state process the queue to send out the next available message immediately
if (this->m_state == READY) {
this->processQueue();
}

return rvStatus;
}

void ComQueue::sendComBuffer(Fw::ComBuffer& comBuffer) {
Expand Down
Loading

0 comments on commit 2543824

Please sign in to comment.