I’m adding some general error handling into the firmware for my company’s S32K344-based ECM. I see various NXP MCAL/drivers code calling into the AUTOSAR Det_ReportError interface with meaningful information. I’d like to capture that information for logging. According to the AUTOSAR DET documentation there’s supposed to be a way to register callbacks that I’d think would be appropriate to accomplish the desired logging, however it doesn’t seem that NXP’s version of DET is supporting this? The implementation in RTD/src/Det.c appears to be only a stub that simply sets some variables in memory and returns without doing anything more.
Is there something I’m missing? Is there some way I should be able to get the usage of Det_ReportError from NXP's MCAL/drivers to actually do something useful (e.g. callout to logging function)?
Unfortunately, we don't have any implementation for DET. It is a responsibility of integrators to decide what to do next with the reported error. I would suggest that in Det_ReportError function, you can simply log the error code to a console.
The challenge is, RTD/src/Det.c is generated code, and I'm not sure the peripheral configuration tool lets us turn this one off. So even if I edit the function as you suggest, it would get overwritten the next time peripheral configuration changes and code gets generated again. It isn't a __weak__ function either so I can't just replace it with my own function of the same name.
I ended up using GCC linker's --wrap option so, any calls to Det_ReportError go to my own implementation named __wrap_Det_ReportError.
I see. The point is the driver code is refreshed every code generation, and the code modified in e.g. RTD/src/Det.c will be overwritten by the original code imported from the Platform SDK. You can get rid of it by directly modifying the code from Platform SDK, e.g. C:\NXP\S32DS.3.4\S32DS\software\PlatformSDK_S32K3_2022_03\SW32K3_RTD_4_4_2_0_0_D2203\Det_TS_T40D34M20I0R0\src\Det.c
After that, re-generate the code to take effect.