X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fdcf77%2Fdcf77.py;h=573888f15e88e91c20d7521d98d55df5fac3adaa;hb=271acd3bde96474c7ed5f822d470f555af8e7d93;hp=48b3bba174c7bc4c4b555c685612409b2b2e45ba;hpb=64c29e28e0efa184319f7831b3eca18c7f73f7d0;p=libsigrokdecode.git diff --git a/decoders/dcf77/dcf77.py b/decoders/dcf77/dcf77.py index 48b3bba..573888f 100644 --- a/decoders/dcf77/dcf77.py +++ b/decoders/dcf77/dcf77.py @@ -18,25 +18,11 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -# # DCF77 protocol decoder -# -# More information: -# http://en.wikipedia.org/wiki/DCF77 -# - -# -# Protocol output format: -# TODO -# import sigrokdecode as srd import calendar -# States -WAIT_FOR_RISING_EDGE = 0 -GET_BIT = 1 - # Annotation feed formats ANN_ASCII = 0 @@ -45,17 +31,20 @@ def bcd2int(b): return (b & 0x0f) + ((b >> 4) * 10) class Decoder(srd.Decoder): + api_version = 1 id = 'dcf77' name = 'DCF77' longname = 'DCF77 time protocol' desc = 'TODO.' - longdesc = 'TODO.' license = 'gplv2+' inputs = ['logic'] outputs = ['dcf77'] probes = [ {'id': 'data', 'name': 'DATA', 'desc': 'DATA line'}, ] + optional_probes = [ + {'id': 'pon', 'name': 'PON', 'desc': 'TODO'}, + ] options = {} annotations = [ # ANN_ASCII @@ -63,7 +52,7 @@ class Decoder(srd.Decoder): ] def __init__(self, **kwargs): - self.state = WAIT_FOR_RISING_EDGE + self.state = 'WAIT FOR RISING EDGE' self.oldval = None self.samplenum = 0 self.bit_start = 0 @@ -210,11 +199,9 @@ class Decoder(srd.Decoder): raise Exception('Invalid DCF77 bit: %d' % c) def decode(self, ss, es, data): - for samplenum, (pon, val) in data: # FIXME - - 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: + if self.state == 'WAIT FOR RISING EDGE': # Wait until the next rising edge occurs. if not (self.oldval == 0 and val == 1): self.oldval = val @@ -268,10 +255,10 @@ class Decoder(srd.Decoder): self.handle_dcf77_bit(bit) self.bitcount += 1 - self.state = WAIT_FOR_RISING_EDGE + self.state = 'WAIT FOR RISING EDGE' else: - raise Exception('Invalid state: %s' % self.state) + raise Exception('Invalid state: %d' % self.state) self.oldval = val