]> sigrok.org Git - libsigrokdecode.git/commitdiff
can: more robust sample point position for low sample rates
authorGerhard Sittig <redacted>
Thu, 10 Oct 2019 07:01:01 +0000 (09:01 +0200)
committerUwe Hermann <redacted>
Fri, 29 Nov 2019 19:33:48 +0000 (20:33 +0100)
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.

decoders/can/pd.py

index 3ab82b02c054dea02f0c5b4b7c0fbac0564f2917..8817097b50e48cef770c031fe2f0efcb7113def9 100644 (file)
@@ -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.