@@ -180,88 +180,77 @@ void LinController::ThrowIfNotConfiguredTxUnconditional(LinId linId)
180180
181181void LinController::WarnOnWrongDataLength (const LinFrame& receivedFrame, const LinFrame& configuredFrame) const
182182{
183- std::string errorMsg =
184- fmt::format (" Mismatch between configured ({}) and received ({}) LinDataLength in LinFrame with ID {}" ,
185- configuredFrame.dataLength , receivedFrame.dataLength , static_cast <uint16_t >(receivedFrame.id ));
186- _logger->Warn (errorMsg);
183+ Logging::Warn (_logger, " Mismatch between configured ({}) and received ({}) LinDataLength in LinFrame with ID {}" ,
184+ configuredFrame.dataLength , receivedFrame.dataLength , static_cast <uint16_t >(receivedFrame.id ));
187185}
188186
189187void LinController::WarnOnWrongChecksum (const LinFrame& receivedFrame, const LinFrame& configuredFrame) const
190188{
191- std::string errorMsg = fmt::format (
192- " Mismatch between configured ({}) and received ({}) LinChecksumModel in LinFrame with ID {}" ,
193- configuredFrame.checksumModel , receivedFrame.checksumModel , static_cast <uint16_t >(receivedFrame.id ));
194- _logger->Warn (errorMsg);
189+ Logging::Warn (_logger, " Mismatch between configured ({}) and received ({}) LinChecksumModel in LinFrame with ID {}" ,
190+ configuredFrame.checksumModel , receivedFrame.checksumModel , static_cast <uint16_t >(receivedFrame.id ));
195191}
196192
197193void LinController::WarnOnReceptionWithInvalidDataLength (LinDataLength invalidDataLength,
198194 const std::string& fromParticipantName,
199195 const std::string& fromServiceName) const
200196{
201- std::string errorMsg =
202- fmt::format (" LinController received transmission with invalid payload length {} from {{{}, {}}}. This "
203- " tranmission is ignored." ,
204- static_cast <uint16_t >(invalidDataLength), fromParticipantName, fromServiceName);
205- _logger->Warn (errorMsg);
197+ Logging::Warn (_logger,
198+ " LinController received transmission with invalid payload length {} from {{{}, {}}}. This "
199+ " tranmission is ignored." ,
200+ static_cast <uint16_t >(invalidDataLength), fromParticipantName, fromServiceName);
206201}
207202
208203void LinController::WarnOnReceptionWithInvalidLinId (LinId invalidLinId, const std::string& fromParticipantName,
209204 const std::string& fromServiceName) const
210205{
211- std::string errorMsg = fmt::format (
206+ Logging::Warn (
207+ _logger,
212208 " LinController received transmission with invalid LIN ID {} from {{{}, {}}}. This transmission is ignored." ,
213209 static_cast <uint16_t >(invalidLinId), fromParticipantName, fromServiceName);
214- _logger->Warn (errorMsg);
215210}
216211
217- void LinController::WarnOnReceptionWhileInactive () const
212+ void LinController::WarnOnReceptionWhileInactive (const LinTransmission& msg ) const
218213{
219- std::string errorMsg = fmt::format (" Inactive LinController received a transmission. This transmission is ignored." );
220- _logger->Warn (errorMsg);
214+ Logging::Warn (_logger, " Inactive LinController received a transmission ({}). This transmission is ignored." , msg);
215+ }
216+
217+ void LinController::WarnOnReceptionWhileSleeping () const
218+ {
219+ Logging::Warn (_logger, " Sleeping LinController received a transmission. This transmission is ignored!" );
221220}
222221
223222void LinController::WarnOnUnneededStatusChange (LinControllerStatus status) const
224223{
225- std::string errorMsg =
226- fmt::format (" Invalid LinController status change: controller is already in {} mode." , status);
227- _logger->Warn (errorMsg);
224+ Logging::Warn (_logger, " Invalid LinController status change: controller is already in {} mode." , status);
228225}
229226
230227void LinController::WarnOnInvalidLinId (LinId invalidLinId, const std::string& callingMethodName) const
231228{
232- std::string errorMsg =
233- fmt::format (" Invalid ID={} in call to '{}'" , static_cast <uint16_t >(invalidLinId), callingMethodName);
234- _logger->Warn (errorMsg);
229+ Logging::Warn (_logger, " Invalid ID={} in call to '{}'" , static_cast <uint16_t >(invalidLinId), callingMethodName);
235230}
236231
237232void LinController::WarnOnUnusedResponseMode (const std::string& callingMethodName) const
238233{
239- std::string errorMsg =
240- fmt::format (" LinFrameResponseMode::Unused is not allowed in call to '{}'." , callingMethodName);
241- _logger->Warn (errorMsg);
234+ Logging::Warn (_logger, " LinFrameResponseMode::Unused is not allowed in call to '{}'." , callingMethodName);
242235}
243236
244237void LinController::WarnOnResponseModeReconfiguration (LinId id, LinFrameResponseMode currentResponseMode) const
245238{
246- std::string errorMsg =
247- fmt::format (" Can't set response mode for ID={}. Mode is already configured to {}." , id, currentResponseMode);
248- _logger->Warn (errorMsg);
239+ Logging::Warn (_logger, " Can't set response mode for ID={}. Mode is already configured to {}." , id, currentResponseMode);
249240}
250241
251242
252243void LinController::WarnOnUnconfiguredSlaveResponse (LinId id) const
253244{
254- std::string errorMsg = fmt::format ( " No slave has configured a response for ID={}. Use Init() or SetFrameResponse() "
255- " on the slave node to configure responses. " ,
256- id);
257- _logger-> Warn (errorMsg );
245+ Logging::Warn (_logger,
246+ " No slave has configured a response for ID={}. Use Init() or SetFrameResponse() on the slave node to "
247+ " configure responses. " ,
248+ id );
258249}
259250
260251void LinController::WarnOnSendFrameSlaveResponseWithMasterTx (LinId id) const
261252{
262- std::string errorMsg =
263- fmt::format (" Master has already configured a response on ID={}. Ignoring this call to SendFrame()" , id);
264- _logger->Warn (errorMsg);
253+ Logging::Warn (_logger, " Master has already configured a response on ID={}. Ignoring this call to SendFrame()" , id);
265254}
266255
267256void LinController::ThrowOnSendAttemptWithUndefinedChecksum (const LinFrame& frame) const
@@ -752,7 +741,13 @@ void LinController::ReceiveMsg(const IServiceEndpoint* from, const LinTransmissi
752741
753742 if (_controllerMode == LinControllerMode::Inactive)
754743 {
755- WarnOnReceptionWhileInactive ();
744+ WarnOnReceptionWhileInactive (msg);
745+ return ;
746+ }
747+
748+ if (_controllerStatus == LinControllerStatus::Sleep || _controllerStatus == LinControllerStatus::Unknown)
749+ {
750+ WarnOnReceptionWhileSleeping ();
756751 return ;
757752 }
758753
0 commit comments