Nissan LEAF: Increase robustness by using CRC bit on incoming messages #134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR adds CRC checking on all incoming LEAF BMS messages that have a CRC
Why
EV conversions and high voltage systems are noisy. Incase a high voltage connection comes too close to an unshielded CAN network, message data can become corrupt. Incase the VCU interprets one of these corrupt frames, it can wreck havoc on the decision making (Imagine suddenly seeing undervoltage and the vehicle cuts out at a critical moment!). This is why OEMs use CRCs, counters and other methods to ensure CAN data is valid.
How
We now use the already existing CRC algorithm used to sign outgoing messages, in reverse. Incoming messages get their CRC byte inspected, incase we notice that the actual value deviates from the calculated CRC, we simply discard the message.
Warning
Code has not been tested on a vehicle, only on simulated values. Please test on a vehicle equipped with LEAF BMS before merging.
For future development, we should consider incrementing a counter/flag/event that corrupted CAN messages have been detected.