]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/dcf77/dcf77.py
srd: dcf77: Bugfix, PD was broken.
[libsigrokdecode.git] / decoders / dcf77 / dcf77.py
index eabceeeeecca4c8cc2cc45f3a50add51873719a7..e84b3db0e5f05034e4527b05ee617679deeff251 100644 (file)
@@ -23,9 +23,6 @@
 import sigrokdecode as srd
 import calendar
 
 import sigrokdecode as srd
 import calendar
 
-# Annotation feed formats
-ANN_ASCII = 0
-
 # Return the specified BCD number (max. 8 bits) as integer.
 def bcd2int(b):
     return (b & 0x0f) + ((b >> 4) * 10)
 # Return the specified BCD number (max. 8 bits) as integer.
 def bcd2int(b):
     return (b & 0x0f) + ((b >> 4) * 10)
@@ -35,8 +32,7 @@ class Decoder(srd.Decoder):
     id = 'dcf77'
     name = 'DCF77'
     longname = 'DCF77 time protocol'
     id = 'dcf77'
     name = 'DCF77'
     longname = 'DCF77 time protocol'
-    desc = 'TODO.'
-    longdesc = 'TODO.'
+    desc = 'European longwave time signal (77.5kHz carrier signal).'
     license = 'gplv2+'
     inputs = ['logic']
     outputs = ['dcf77']
     license = 'gplv2+'
     inputs = ['logic']
     outputs = ['dcf77']
@@ -48,8 +44,7 @@ class Decoder(srd.Decoder):
     ]
     options = {}
     annotations = [
     ]
     options = {}
     annotations = [
-        # ANN_ASCII
-        ['ASCII', 'TODO: description'],
+        ['Text', 'Human-readable text'],
     ]
 
     def __init__(self, **kwargs):
     ]
 
     def __init__(self, **kwargs):
@@ -200,9 +195,7 @@ class Decoder(srd.Decoder):
             raise Exception('Invalid DCF77 bit: %d' % c)
 
     def decode(self, ss, es, data):
             raise Exception('Invalid DCF77 bit: %d' % c)
 
     def decode(self, ss, es, data):
-        for samplenum, (val) in data: # TODO: Handle optional PON.
-
-            self.samplenum += 1 # FIXME. Use samplenum. Off-by-one?
+        for (self.samplenum, (val)) in data: # TODO: Handle optional PON.
 
             if self.state == 'WAIT FOR RISING EDGE':
                 # Wait until the next rising edge occurs.
 
             if self.state == 'WAIT FOR RISING EDGE':
                 # Wait until the next rising edge occurs.
@@ -228,13 +221,13 @@ class Decoder(srd.Decoder):
                     self.bitcount = 0
                     self.bit_start_old = self.bit_start
                     self.dcf77_bitnumber_is_known = 1
                     self.bitcount = 0
                     self.bit_start_old = self.bit_start
                     self.dcf77_bitnumber_is_known = 1
-                    # Don't switch to GET_BIT state this time.
+                    # Don't switch to 'GET BIT' state this time.
                     continue
 
                 self.bit_start_old = self.bit_start
                     continue
 
                 self.bit_start_old = self.bit_start
-                self.state = GET_BIT
+                self.state = 'GET BIT'
 
 
-            elif self.state == GET_BIT:
+            elif self.state == 'GET BIT':
                 # Wait until the next falling edge occurs.
                 if not (self.oldval == 1 and val == 0):
                     self.oldval = val
                 # Wait until the next falling edge occurs.
                 if not (self.oldval == 1 and val == 0):
                     self.oldval = val
@@ -253,7 +246,7 @@ class Decoder(srd.Decoder):
                 else:
                     bit = -1 # TODO: Error?
 
                 else:
                     bit = -1 # TODO: Error?
 
-                # TODO: There's no bit 59, make sure none is decoded.
+                # There's no bit 59, make sure none is decoded.
                 if bit in (0, 1) and self.bitcount in range(0, 58 + 1):
                     self.handle_dcf77_bit(bit)
                     self.bitcount += 1
                 if bit in (0, 1) and self.bitcount in range(0, 58 + 1):
                     self.handle_dcf77_bit(bit)
                     self.bitcount += 1