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

Issue 2457 #2502

Merged
merged 44 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7778cac
Os::File refactor: open w/ basic stub, posix UTs
LeStarch Dec 22, 2023
57b2574
Refactoring Os::File for all methods, less UTs
LeStarch Jan 6, 2024
a45d3bf
Adding rules-based common tests
LeStarch Jan 11, 2024
5fb8bb6
Fixing posix file for common UTs
LeStarch Jan 11, 2024
7050e03
Adding WriteRead and WriteReadSeek tests
LeStarch Jan 17, 2024
194afa8
Working random tests
LeStarch Jan 18, 2024
9d0ba81
Working randomized tests and stub testing
LeStarch Jan 23, 2024
f6f6c20
Fixing PrmDb unit tests
LeStarch Jan 24, 2024
0f6668a
Updating files to used FwSignedSizeType
LeStarch Jan 24, 2024
3a9f842
Factoring out the synthetic file system
LeStarch Jan 25, 2024
4434946
Initial work on CmdSequencer UTs
LeStarch Jan 25, 2024
e7740f8
Fixing linux implementation
LeStarch Jan 25, 2024
0f3c3b1
Newlines at end of file
LeStarch Jan 25, 2024
8d8bdd7
sp
LeStarch Jan 25, 2024
c2d19e2
Static analysis checks
LeStarch Jan 25, 2024
abdea47
Changing API to use enums
LeStarch Jan 25, 2024
65c093c
Refactoring for proper class tree
LeStarch Jan 31, 2024
94caa43
CmdSequencer UTs - WIP
LeStarch Feb 1, 2024
758cd81
CmdSequencer UTs work
LeStarch Feb 2, 2024
eed64c7
Adding copy constructor functionality
LeStarch Feb 2, 2024
cc448d0
Spelling and static analysis fixes
LeStarch Feb 2, 2024
f36c968
Copy constructor/assignment operator UTs and fixes
LeStarch Feb 2, 2024
3b66c84
Initial CRC work
LeStarch Feb 4, 2024
0135d84
Working CRC and FPP models
LeStarch Feb 5, 2024
aa8a735
Minor UT fixes
LeStarch Feb 5, 2024
b15e15f
Correcting CMake choices implementation
LeStarch Feb 6, 2024
9734c3b
MAking implementation choices real dependencies
LeStarch Feb 8, 2024
4738c07
Fixing implementation to use source files
LeStarch Feb 8, 2024
11b3899
Fixing posix file read/write permissions
LeStarch Feb 8, 2024
57b1352
Allowing None implementations
LeStarch Feb 8, 2024
b5fbffc
Fixed CI breakages
LeStarch Feb 8, 2024
2325eb7
Fixing MyRules.hpp formatting
LeStarch Feb 8, 2024
af417fc
Minor CRC unit test fix
LeStarch Feb 8, 2024
86bb30b
Removing direct write support
LeStarch Feb 9, 2024
fa19e9f
Changing get delegate to static method of interface
LeStarch Feb 13, 2024
aebeaa2
Replacing old comments with new comments
LeStarch Feb 14, 2024
23e6b3c
Fixing friend regression
LeStarch Feb 14, 2024
91d9bc3
Review fixes
LeStarch Feb 15, 2024
70bdb94
Fixing serialization method usages
LeStarch Feb 27, 2024
3ff666d
Review fixes
LeStarch Feb 27, 2024
6891e65
Fixing RPI build
LeStarch Feb 27, 2024
15a950e
Fixing FwBuffSizeType overflow
LeStarch Feb 28, 2024
fdd538f
Fixing review comment
LeStarch Feb 28, 2024
6e38fc2
Renaming FwExternalSize -> FwSizeStoreType
LeStarch Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Fw/Dp/DpContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ Fw::SerializeStatus DpContainer::deserializeHeader() {
}
// Deserialize the user data
if (status == Fw::FW_SERIALIZE_OK) {
const bool omitLength = true;
const FwSizeType requestedSize = sizeof this->m_userData;
FwSizeType receivedSize = requestedSize;
status = serializeRepr.deserialize(this->m_userData, receivedSize, omitLength);
status = serializeRepr.deserialize(this->m_userData, receivedSize, Fw::Serialization::OMIT_LENGTH);
if (receivedSize != requestedSize) {
status = Fw::FW_DESERIALIZE_SIZE_MISMATCH;
}
Expand Down Expand Up @@ -111,8 +110,7 @@ void DpContainer::serializeHeader() {
status = serializeRepr.serialize(this->m_procTypes);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
// Serialize the user data
const bool omitLength = true;
status = serializeRepr.serialize(this->m_userData, sizeof this->m_userData, omitLength);
status = serializeRepr.serialize(this->m_userData, sizeof this->m_userData, Fw::Serialization::OMIT_LENGTH);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
// Serialize the data product state
status = serializeRepr.serialize(this->m_dpState);
Expand Down
17 changes: 14 additions & 3 deletions Fw/Types/Serializable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,13 @@ namespace Fw {
}

SerializeStatus SerializeBufferBase::serialize(const U8* buff, NATIVE_UINT_TYPE length, bool noLength) {
return this->serialize(buff, static_cast<FwSizeType>(length), noLength ? Serialization::OMIT_LENGTH : Serialization::INCLUDE_LENGTH);
}

SerializeStatus SerializeBufferBase::serialize(const U8* buff, FwSizeType length, Fw::Serialization::t mode) {
// First serialize length
SerializeStatus stat;
if (not noLength) {
if (mode == Serialization::INCLUDE_LENGTH) {
stat = this->serialize(static_cast<FwBuffSizeType>(length));
if (stat != FW_SERIALIZE_OK) {
return stat;
Expand Down Expand Up @@ -500,10 +504,17 @@ namespace Fw {
}

SerializeStatus SerializeBufferBase::deserialize(U8* buff, NATIVE_UINT_TYPE& length, bool noLength) {
FwSizeType length_in_out = length;
SerializeStatus status = this->deserialize(buff, length_in_out, noLength ? Serialization::OMIT_LENGTH : Serialization::INCLUDE_LENGTH);
length = length_in_out;
return status;
}

SerializeStatus SerializeBufferBase::deserialize(U8* buff, FwSizeType& length, Serialization::t mode) {

FW_ASSERT(this->getBuffAddr());

if (not noLength) {
if (mode == Serialization::INCLUDE_LENGTH) {
FwBuffSizeType storedLength;

SerializeStatus stat = this->deserialize(storedLength);
Expand All @@ -519,7 +530,7 @@ namespace Fw {

(void) memcpy(buff, &this->getBuffAddr()[this->m_deserLoc], storedLength);

length = static_cast<NATIVE_UINT_TYPE>(storedLength);
length = static_cast<FwSizeType>(storedLength);

} else {
// make sure enough is left
Expand Down
32 changes: 31 additions & 1 deletion Fw/Types/Serializable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ namespace Fw {
virtual ~Serializable(); //!< destructor
};

class Serialization {
public:
enum t {
INCLUDE_LENGTH, //!< Include length as first token in serialization
OMIT_LENGTH //!< Omit length from serialization
};
};

class SerializeBufferBase {
public:

Expand Down Expand Up @@ -72,6 +80,17 @@ namespace Fw {

SerializeStatus serialize(const U8* buff, NATIVE_UINT_TYPE length, bool noLength = false); //!< serialize data buffer

//! \brief serialize a byte buffer of a given length
//!
//! Serialize bytes from `buff` up to `length`. If `serializationMode` is set to `INCLUDE_LENGTH` then the
//! length is included as the first token. Length may be omitted with `OMIT_LENGTH`.
//!
//! \param buff: buffer to serialize
//! \param length: length of data to serialize
//! \param mode: serialization type
//! \return status of serialization
SerializeStatus serialize(const U8* buff, FwSizeType length, Serialization::t mode);

SerializeStatus serialize(const SerializeBufferBase& val); //!< serialize a serialized buffer

SerializeStatus serialize(const Serializable &val); //!< serialize an object derived from serializable base class
Expand Down Expand Up @@ -105,8 +124,19 @@ namespace Fw {
// length should be set to max, returned value is actual size stored. If noLength
// is true, use the length variable as the actual number of bytes to deserialize
SerializeStatus deserialize(U8* buff, NATIVE_UINT_TYPE& length, bool noLength = false); //!< deserialize data buffer
// serialize/deserialize Serializable

//! \brief deserialize a byte buffer of a given length
//!
//! Deserialize bytes into `buff` of `length` bytes. If `serializationMode` is set to `INCLUDE_LENGTH` then
//! the length is deserialized first followed by the bytes. Length may be omitted with `OMIT_LENGTH` and
//! in this case `length` bytes will be deserialized. `length` will be filled with the amount of data
//! deserialized.
//!
//! \param buff: buffer to hold deserialized data
//! \param length: length of data to deserialize length is filled with deserialized length
//! \param mode: deserialization type
//! \return status of serialization
SerializeStatus deserialize(U8* buff, FwSizeType& length, Serialization::t mode);

SerializeStatus deserialize(Serializable &val); //!< deserialize an object derived from serializable base class

Expand Down
Loading