From: Gerhard Sittig Date: Thu, 10 Oct 2019 07:01:01 +0000 (+0200) Subject: can: more robust sample point position for low sample rates X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e4eeaab3206e757592cea79f4686180bc3ee38e0;p=libsigrokdecode.git 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. --- 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.