How to get CAN ID in CanIf User RxIndication callback?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get CAN ID in CanIf User RxIndication callback?

435 Views
Soratari
Contributor I

Hello, I am using S32K144 with SW32K1_S32M24x_RTD_R21-11_3.0.0 and have configured CanIf to use a custom callback function.

 

My Configuration:
CanIfRxPduUserRxIndicationName is set to "Service_CanIf_RxIndication"
This callback is invoked from CanIf_RxIndication() when a CAN message is received.

 

Problem:
I noticed that in CanIf_RxIndication(), the CAN ID is available through the Mailbox->CanId parameter. However, in my Service_CanIf_RxIndication() callback, I can only receive the PduId - there is no way to retrieve the actual CAN ID. Also, I noticed that CanIf.h header states: "Stub Version - This file contains sample code only."

 

My Questions:
1. Can I modify or replace the CanIf.c stub code?
Since CanIf.h explicitly states it is a "Stub Version" and "sample code only", is it acceptable to modify CanIf.c to pass the CAN ID to the user callback?

2. Would modifying the stub code violate AUTOSAR architecture?
If I customize the CanIf stub implementation, does this break AUTOSAR compliance or cause any compatibility issues?

3. Are there any alternative solutions?
Is there a recommended way to pass the CAN ID to the upper layer callback without modifying the CanIf source code?

 

Environment:
MCU: S32K144
RTD Version: SW32K1_S32M24x_RTD_R21-11_3.0.0
IDE: S32 Design Studio 3.6

 

 


Thank you for your help!

0 Kudos
Reply
1 Reply

387 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @Soratari,

Q1. Yes, stub modules are meant to be edited/replaced. Since the CanIf module is a stub, it just provides the header files required by the CAN driver, such as CanIf_Cbk.h.

Q2. No, it would not violate ASR architecture, as long as you follow the guidelines and do not change the standardize function names, variables, etc.

Q3. Normally, stub modules are for testing purposes. You should use CanIf, EthIf & LinIf from a third-party provider, such as Elektrobit (EB), Vector, etc. However, for debugging purposes, it is fine to modify it yourself.

Best regards,
Julián

0 Kudos
Reply