-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Update/framing deframing context #2150
base: devel
Are you sure you want to change the base?
Conversation
@LMPS97 @arizvi786 here are the changes you were interested in for Framer/Deframer. You can leverage this work immediately as:
|
@pcrosemurgy this PR breaks out routing from Deframer. It is possible that you could use these updates as you were specifically disrupted by the combined deframing and routing. |
// Specifically does nothing | ||
} | ||
|
||
void FprimeRouter ::deframedIn_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& packetBuffer, Fw::Buffer& context) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
// Handler implementations for user-defined typed input ports | ||
// ---------------------------------------------------------------------- | ||
|
||
void FprimeRouter ::cmdResponseIn_handler(const NATIVE_INT_TYPE portNum, |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
// Construction, initialization, and destruction | ||
// ---------------------------------------------------------------------- | ||
|
||
FprimeRouter ::FprimeRouter(const char* const compName) : FprimeRouterComponentBase(compName) {} |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
} | ||
|
||
// Whether to deallocate the packet buffer | ||
bool deallocate = true; |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
this->handle_framing(buffer, Fw::Buffer()); | ||
} | ||
|
||
void Framer ::bufferAndContextIn_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& data, Fw::Buffer& context) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
@LeStarch Thank you! I'll take a closer look at this! |
I am getting an error compiling |
@@ -39,11 +39,6 @@ class Framer : public FramerComponentBase, public FramingProtocolInterface { | |||
Framer(const char* const compName /*!< The component name*/ | |||
); | |||
|
|||
//! Initialize object Framer | |||
//! | |||
void init(const NATIVE_INT_TYPE instance = 0 /*!< The instance number*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was the init function deleted on framer
? Also, why only on framer
and not deframer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init
functions are provided by the component base class and are, in older component implementations, improperly shadowed. Thus, we are removing them.
Why not deframer? Oversight. We will remove it there too before merging.
I ran into a slight issue with the |
I just ran into an other issue when unit testing my code. Apparently, if you try to create a
I encountered this issue when a function of mine returns a non-valid |
FW_ASSERT(m_interface != nullptr); | ||
// Use of I32 size is explicit as ComPacketType will be specifically serialized as an I32 | ||
FpFrameHeader::TokenType real_data_size = size + ((packet_type != Fw::ComPacket::FW_PACKET_UNKNOWN) ? sizeof(I32) : 0); | ||
FpFrameHeader::TokenType real_data_size = context.getSize() + data.getSize(); | ||
FpFrameHeader::TokenType total = real_data_size + FpFrameHeader::SIZE + HASH_DIGEST_LENGTH; | ||
Fw::Buffer buffer = m_interface->allocate(total); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a check here to see if the buffer is empty since the buffer manager can run out of buffers. I don't think the check should be an assert since it wouldn't be appropriate to assert flight software on a lack of buffer manager buffers. Therefore, I think it should do an early return with an error code. This error code could be use by the framer and an evr could be outputted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed wholeheartedly. Although we should check for .isValid()
in the latest F´ because when buffer manager has no buffers, an invalid buffer is returned.
@@ -128,7 +128,8 @@ DeframingProtocol::DeframingStatus FprimeDeframing::deframe(Types::CircularBuffe | |||
buffer.setSize(size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the frame
function, this check should be a assert but a early return with an error code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
We should deallocate it when the buffer |
Change Description
This pull-request makes several changes to
Framer
andDeframer
.Work:
Rationale
Many projects need additional contextual metadata when framing, but wish to leverage existing Framer and Deframer code. This PR allows this. Many projects also handle routing and don't need routing code commingled with Deframer.