I am using a S32K144 EVB as a LIN slave. I am using Vector Canalyzer to send 5 different LIN messages. Two for sending data to the EVB, and 3 for requesting data from the EVB.
The issue I'm seeing is the checksum on the response from the EVB is always calculated in classic mode no matter what option I pick in the LIN config block. I need the checksum to be in enhanced mode. The data itself in the message from the EVB are correct.
It can be best seen in the message with ID 4. The data bytes are all 0 so the classic checksum is 255 but the enhanced checksum would take into account the PID and the checksum should be 59
It can also be confirmed with a LIN checksum calculator here: https://linchecksumcalculator.machsystems.cz/
I have went through the "intro to LIN block" training here:
And I noticed in that video at 23:43 the checksum type is selected as enhanced and at 25:47 the PLIN viewer shows the received checksum as classic
I have attached a model with just the LIN portion responding with constant data.
My system layout
Hardware: S32K144 EVB, Vector CANalyzer
Software: MATLAB Version 9.7 (R2019b), Simulink Version 10.0 (R2019b), Model-Based Design Toolbox for S32K1xx Series Version 4.2.0 (R2016a-R2020a)
已解决! 转到解答。
Hello, @ruihang_wu
I apologize for the late response. I have investigated the problem regarding the checksum value in enhanced mode for LIN communication and it looks like a problem in the SDK for the LIN driver. The function that computes the checksum should take all data bytes and add them modulo 256 together. In enhanced mode also the PID should be took in this computation. But the SDK function ignores the PID in classical and also in enhanced mode.
I have modified a source file that contains the function that computes the checksum. You can test the functionality by copying the file into "{toolbox_path}\src\S32_Platform_SDK\platform\drivers\src\lpuart". Then try to build your application as usual.
Let me know if it works.
Best regards,
Stefan.
I think I found that another workaround to this issue is to actually select the "Classic" checksum type and leave the "Classic PIDs list" at the default "0" value. Apparently even when "Classic" is selected, only the PIDs in the "Classic PIDs list" use the Classic checksum and all the rest use Enhanced. Fixing the driver C code is the better solution, but this can work as a quick fix:
Hello @ruihang_wu,
Thank you very much for reporting this!
@stefancinipeanu started to investigate your reported behavior.
Regards,
Marius
Hello, @ruihang_wu
I apologize for the late response. I have investigated the problem regarding the checksum value in enhanced mode for LIN communication and it looks like a problem in the SDK for the LIN driver. The function that computes the checksum should take all data bytes and add them modulo 256 together. In enhanced mode also the PID should be took in this computation. But the SDK function ignores the PID in classical and also in enhanced mode.
I have modified a source file that contains the function that computes the checksum. You can test the functionality by copying the file into "{toolbox_path}\src\S32_Platform_SDK\platform\drivers\src\lpuart". Then try to build your application as usual.
Let me know if it works.
Best regards,
Stefan.