Skip to content

Conversation

@thomas-bc
Copy link
Collaborator

Related Issue(s)
Has Unit Tests (y/n)
Documentation Included (y/n)

Change Description

Fix #3770

This reverts the Drv.ByteStreamDriver interface to be synchronous, and adds in a Drv.AsyncByteStreamDriver.
Svc.ComStub can work with either, depending on which ports are connected.

Testing/Review Recommendations

Svc.ComStub code has a lot of branching and stuff - needs careful review.

Future Work

Double check with Hub pattern

//! Construct object ComStubTester
//!
ComStubTester();
ComStubTester(TestMode mode = TestMode::UNSPECIFIED); //!< Constructor with test mode

Check warning

Code scanning / CppCheck

Constructors callable with one argument should be marked explicit. Warning test

Constructors callable with one argument should be marked explicit.
}

void LinuxUartDriver ::send_handler(const FwIndexType portNum, Fw::Buffer& serBuffer) {
Drv::ByteStreamStatus LinuxUartDriver ::send_handler(const FwIndexType portNum, Fw::Buffer& serBuffer) {

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
// ----------------------------------------------------------------------

void TcpClientComponentImpl::send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {
Drv::ByteStreamStatus TcpClientComponentImpl::send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
// ----------------------------------------------------------------------

void TcpServerComponentImpl::send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {
Drv::ByteStreamStatus TcpServerComponentImpl::send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
// ----------------------------------------------------------------------

void UdpComponentImpl::send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {
Drv::ByteStreamStatus UdpComponentImpl::send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
// A message should never get here if we need to reinitialize
FW_ASSERT(!this->m_reinitialize || !this->isConnected_comStatusOut_OutputPort(0));
if (this->isConnected_drvSendOut_OutputPort(0)) {
this->handleSynchronousSend(sendBuffer, context);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter sendBuffer has not been checked.
// A message should never get here if we need to reinitialize
FW_ASSERT(!this->m_reinitialize || !this->isConnected_comStatusOut_OutputPort(0));
if (this->isConnected_drvSendOut_OutputPort(0)) {
this->handleSynchronousSend(sendBuffer, context);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter context has not been checked.
if (this->isConnected_drvSendOut_OutputPort(0)) {
this->handleSynchronousSend(sendBuffer, context);
} else if (this->isConnected_drvAsyncSendOut_OutputPort(0)) {
this->handleAsynchronousSend(sendBuffer, context);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter sendBuffer has not been checked.
if (this->isConnected_drvSendOut_OutputPort(0)) {
this->handleSynchronousSend(sendBuffer, context);
} else if (this->isConnected_drvAsyncSendOut_OutputPort(0)) {
this->handleAsynchronousSend(sendBuffer, context);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter context has not been checked.
} else {
// Receive successful - forward data with empty context
ComCfg::FrameContext emptyContext; // ComStub knows nothing about the received bytes, empty context
this->dataOut_out(0, recvBuffer, emptyContext);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter recvBuffer has not been checked.
if (this->m_retry_count < this->RETRY_LIMIT) {
// Attempt retry if under the limit
this->m_retry_count++;
this->drvAsyncSendOut_out(0, fwBuffer);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter fwBuffer has not been checked.
this->drvAsyncSendOut_out(0, fwBuffer);
} else {
// Exceeded retry limit - return buffer and notify failure
this->dataReturnOut_out(0, fwBuffer, this->m_storedContext);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter fwBuffer has not been checked.
const Drv::ByteStreamStatus& sendStatus) {
if (sendStatus != Drv::ByteStreamStatus::SEND_RETRY) {
// Not retrying - return buffer ownership and send status
void ComStub::drvAsyncSendReturnIn_handler(FwIndexType portNum, //!< The port number

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
// Helper method implementations
// ----------------------------------------------------------------------

void ComStub::handleSynchronousSend(Fw::Buffer& sendBuffer, const ComCfg::FrameContext& context) {

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
this->comStatusOut_out(0, comSuccess);
}

void ComStub::handleAsyncRetry(Fw::Buffer& fwBuffer) {

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.

void ComStub::handleAsynchronousSend(Fw::Buffer& sendBuffer, const ComCfg::FrameContext& context) {
this->m_storedContext = context; // Store the context for async callback
this->drvAsyncSendOut_out(0, sendBuffer);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter sendBuffer has not been checked.
thomas-bc added a commit to fprime-community/fprime-tutorial-hello-world that referenced this pull request Aug 6, 2025
thomas-bc added a commit to fprime-community/fprime-system-reference that referenced this pull request Aug 6, 2025
thomas-bc added a commit to fprime-community/fprime-tutorial-math-component that referenced this pull request Aug 6, 2025
thomas-bc added a commit to fprime-community/fprime-workshop-led-blinker that referenced this pull request Aug 6, 2025
thomas-bc added a commit to nasa/fprime-tools that referenced this pull request Aug 6, 2025
…3987) (#282)

* remove async comdriver connection

* remove packets include

nasa/fprime#3987
@thomas-bc thomas-bc merged commit 89bccfa into nasa:devel Aug 6, 2025
49 checks passed
@thomas-bc thomas-bc deleted the byte-stream-sync branch August 6, 2025 18:21
thomas-bc added a commit to nasa/fprime-examples that referenced this pull request Aug 6, 2025
thomas-bc added a commit to tanuj-rai/fprime-tools that referenced this pull request Aug 11, 2025
…3987) (nasa#282)

* remove async comdriver connection

* remove packets include

nasa/fprime#3987
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ByteStreamDriverInterface should provide a port for synchronous sending

2 participants