Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 0 additions & 8 deletions Demos/communication/Lin/LinMasterDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ class LinMaster : public ApplicationBase
{
const auto linId{static_cast<unsigned>(linFrame.id)};

if (_linController->Status() != LinControllerStatus::Operational)
{
std::stringstream ss;
ss << "LIN Frame with ID=" << linId << " not sent, since the controller is not operational";
GetLogger()->Warn(ss.str());
return;
}

_linController->SendFrame(linFrame, responseType);

std::stringstream ss;
Expand Down
2 changes: 1 addition & 1 deletion SilKit/IntegrationTests/ITest_NetSimLin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ TEST_F(ITest_NetSimLin, networksimulation_lin_dynamic)
{
SendLinFrames(now, linController, callCounts.silKitSentMsgLin.SentFramesTrivial);
SendLinFrameHeaders(now, linController, callCounts.silKitSentMsgLin.SentFrameHeadersTrivial);
WakeupOnce(now, linController);
GoToSleepOnce(now, linController);
WakeupOnce(now, linController);
}
}, _stepSize);

Expand Down
12 changes: 12 additions & 0 deletions SilKit/source/services/lin/LinController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ void LinController::WarnOnReceptionWhileInactive() const
_logger->Warn(errorMsg);
}

void LinController::WarnOnReceptionWhileSleeping() const
{
std::string warnMsg = fmt::format("Sleeping LinController received a transmission. This transmission is ignored!");
_logger->Warn(warnMsg);
}

void LinController::WarnOnUnneededStatusChange(LinControllerStatus status) const
{
std::string errorMsg =
Expand Down Expand Up @@ -756,6 +762,12 @@ void LinController::ReceiveMsg(const IServiceEndpoint* from, const LinTransmissi
return;
}

if(_controllerStatus == LinControllerStatus::Sleep || _controllerStatus == LinControllerStatus::Unknown)
{
WarnOnReceptionWhileSleeping();
return;
}

const auto& frame = msg.frame;
bool isGoToSleepFrame = frame.id == GoToSleepFrame().id && frame.data == GoToSleepFrame().data;

Expand Down
1 change: 1 addition & 0 deletions SilKit/source/services/lin/LinController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class LinController
void WarnOnReceptionWithInvalidLinId(LinId invalidLinId, const std::string& fromParticipantName,
const std::string& fromServiceName) const;
void WarnOnReceptionWhileInactive() const;
void WarnOnReceptionWhileSleeping() const;
void WarnOnUnneededStatusChange(LinControllerStatus status) const;
void WarnOnInvalidLinId(LinId invalidLinId, const std::string& callingMethodName) const;
void WarnOnUnusedResponseMode(const std::string& callingMethodName) const;
Expand Down
15 changes: 15 additions & 0 deletions SilKit/source/services/lin/SimBehaviorTrivial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "LinController.hpp"
#include "SimBehaviorTrivial.hpp"
#include "Assert.hpp"
#include "LoggerMessage.hpp"

namespace SilKit {
namespace Services {
Expand Down Expand Up @@ -88,11 +89,25 @@ void SimBehaviorTrivial::SendMsgImpl(MsgT&& msg)

void SimBehaviorTrivial::SendMsg(LinSendFrameRequest&& msg)
{
auto controllerStatus = _parentController->Status();
if(controllerStatus == LinControllerStatus::Sleep || controllerStatus == LinControllerStatus::Unknown)
{
Logging::Warn(_participant->GetLogger(),
"LinController not operational. SendFrameRequest will not be sent!");
return;
}
_parentController->SendFrameHeader(msg.frame.id);
}

void SimBehaviorTrivial::SendMsg(LinTransmission&& msg)
{
auto controllerStatus = _parentController->Status();
if(controllerStatus == LinControllerStatus::Sleep || controllerStatus == LinControllerStatus::Unknown)
{
Logging::Warn(_participant->GetLogger(),
"LinController not operational. LinTransmission will not be sent!");
return;
}
SendMsgImpl(msg);
}

Expand Down
4 changes: 3 additions & 1 deletion docs/changelog/versions/latest.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# [5.0.4] - UNRELEASED

> This changelog entry is still empty.
## Fixed

- `Lin controller`: fixed tx/rx behaviour when controller is not operational
Loading