CAN: Fix CAN-FD bitrate switch#132
Open
stephan-thiele wants to merge 17 commits intosigrokproject:masterfrom
Open
CAN: Fix CAN-FD bitrate switch#132stephan-thiele wants to merge 17 commits intosigrokproject:masterfrom
stephan-thiele wants to merge 17 commits intosigrokproject:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR builds on #131. Please do not review or merge, until #131 has been merged!
Summary
In this PR, CAN-FD bitrate switch decoding and annotion appearance are fixed.
In order to do this, the following steps have been done (More details below):
Current issues
Currently bitrate switch for CAN-FD is not decoded properly which may break decoding under certain circumstances. Also the annotation of BRS bit and CRC delimiter bit are not correct.
For the following images, the following settings were used:
BRS annotation has a gap and overlaps with next bit, if a nominal sample point of decoder is set to 75%:

After fix:

CRC delimiter Annotation looks okayish but is incorrect (Gap to ACK slot should be around 160ns instead):

After fix:

Decoding breaks, if ESI bit is set (DLC should be 8):

After fix:

Decoding breaks, if ACK slot is not set:

After fix (Error frames are not decoded yet, but that's another issue):

The fixes
Annotation
On CAN-FD, the bitrate is switched to FD bitrate at the sample point of
BRSbit and switched back to nominal bitrate the sample point of CRC-Delimiter.In the following example:
The current annotation just uses the FD bitrate and the sample point of the nominal bitrate, which makes the annotation too small and, if the nominal sample point and FD sample point differ, slightly overlapping. The correct way is to calculate the combined bit length from nominal and FD phase is as follows:
Bit widths for nominal and FD bitrates are:
Total bit width of BRS bit: 100 samples/bit * 0.75 + 50 samples/bit * 0.20 -> 85 samples.
For this task, the new annotation function
putx_brsis introduced.Decoding
Currently, when the bitrate is switched at the sample point, the sample point is defined as a dom edge, which leads to wrong decoding behaviour, as the effective sample point is wrong until another dom edge has been reached and leads to proper resynchonization. Thus, the fix of this PR simply defines the end of the bit, where birate is switched, as dom edge (forced DOM edge), regardless if it is a falling or rising edge. That way sampling is properly adjusted to new bitrate.