X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fmorse%2Fpd.py;h=3048332354f4a86585ef3fc55fc16796cf2c39fb;hb=287e2788a726732e5f29eb3f5f4fe9d68fac4d05;hp=588394dadc2e5a5f5f266a02b048c257e1660200;hpb=500d5ff479c2ee1c1e5531735485311f4952c368;p=libsigrokdecode.git diff --git a/decoders/morse/pd.py b/decoders/morse/pd.py index 588394d..3048332 100644 --- a/decoders/morse/pd.py +++ b/decoders/morse/pd.py @@ -137,6 +137,9 @@ class Decoder(srd.Decoder): annotation_rows = tuple((u, v, (i,)) for i, (u, v) in enumerate(annotations)) def __init__(self): + self.reset() + + def reset(self): self.samplerate = None def metadata(self, key, value): @@ -151,8 +154,6 @@ class Decoder(srd.Decoder): # Annotate symbols, emit symbols, handle timeout via token. timeunit = self.options['timeunit'] - if self.samplerate is None: - self.samplerate = 1.0 self.wait({0: 'r'}) prevtime = self.samplenum # Time of an actual edge. @@ -214,6 +215,15 @@ class Decoder(srd.Decoder): yield None # Pass through flush of 5+ space. def decode(self): + + # Strictly speaking there is no point in running this decoder + # when the sample rate is unknown or zero. But the previous + # implementation already fell back to a rate of 1 in that case. + # We stick with this approach, to not introduce new constraints + # for existing use scenarios. + if not self.samplerate: + self.samplerate = 1.0 + # Annotate letters, group into words. s0 = s1 = None word = ''