]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/jitter/pd.py
jitter: Simplify ascii-float binary out.
[libsigrokdecode.git] / decoders / jitter / pd.py
index b5e3a294727c1ff2961709814fee8c92839856d2..d6db8e599cb8c1905f75db07c39e7d07a2e38815 100644 (file)
@@ -60,7 +60,7 @@ class Decoder(srd.Decoder):
         ('sig_missed', 'Signal missed', (2,)),
     )
     binary = (
-        ('jitter', 'Raw jitter values'),
+        ('ascii-float', 'Jitter values as newline-separated ASCII floats'),
     )
 
     def __init__(self, **kwargs):
@@ -105,14 +105,14 @@ class Decoder(srd.Decoder):
 
         self.put(self.clk_start, self.sig_start, self.out_ann, [0, [delta_s]])
 
-    # Helper function for raw jitter value which could be useful for statistics.
+    # Helper function for ASCII float jitter values (one value per line).
     def putb(self, delta):
         if delta is None:
             return
-        # format the delta to an ascii output
-        for x in str(delta):
-            self.put(self.clk_start, self.sig_start, self.out_bin, (0, bytes([ord(x)])))
-        self.put(self.clk_start, self.sig_start, self.out_bin, (0, bytes([ord('\n')])))
+        # Format the delta to an ASCII float value terminated by a newline.
+        x = str(delta) + '\n'
+        self.put(self.clk_start, self.sig_start, self.out_bin,
+                 (0, x.encode('UTF-8')))
 
     # Helper function for missed clock and signal annotations.
     def putm(self, data):