diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2019-10-10 09:01:01 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2019-11-29 20:33:48 +0100 |
commit | e4eeaab3206e757592cea79f4686180bc3ee38e0 (patch) | |
tree | f882729810e00d6e31416a88b9614569d235f7a7 | |
parent | 8abd7aa36c1a8c2d83777fedba499f6fb7f38e06 (diff) | |
download | libsigrokdecode-e4eeaab3206e757592cea79f4686180bc3ee38e0.tar.gz libsigrokdecode-e4eeaab3206e757592cea79f4686180bc3ee38e0.zip |
can: more robust sample point position for low sample rates
Do more of the calculation with floating point, only trim precision and
enforce integers at the end of the determination of the next sample
point. This shall increase robustness at low capture sample rates.
-rw-r--r-- | decoders/can/pd.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/decoders/can/pd.py b/decoders/can/pd.py index 3ab82b0..8817097 100644 --- a/decoders/can/pd.py +++ b/decoders/can/pd.py @@ -147,9 +147,9 @@ class Decoder(srd.Decoder): # Determine the position of the next desired bit's sample point. def get_sample_point(self, bitnum): samplenum = self.dom_edge_snum - samplenum += int(self.bit_width * (bitnum - self.dom_edge_bcount)) - samplenum += int(self.sample_point) - return samplenum + samplenum += self.bit_width * (bitnum - self.dom_edge_bcount) + samplenum += self.sample_point + return int(samplenum) def is_stuff_bit(self): # CAN uses NRZ encoding and bit stuffing. |