X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fi2s%2Fpd.py;h=054d69e11a36f2cf5966d976f06d38e1a32555b6;hb=4f4e035397fa0770d47bf8b663e87651e0709511;hp=beee07925ce57c6018cecc59b215071c7ee6ba2e;hpb=30c855f60df2ae5d2edc568c51920f215ab38e0c;p=libsigrokdecode.git diff --git a/decoders/i2s/pd.py b/decoders/i2s/pd.py index beee079..054d69e 100644 --- a/decoders/i2s/pd.py +++ b/decoders/i2s/pd.py @@ -33,9 +33,6 @@ Packet: : integer ''' -class SamplerateError(Exception): - pass - class Decoder(srd.Decoder): api_version = 3 id = 'i2s' @@ -45,6 +42,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['i2s'] + tags = ['Audio', 'PC'] channels = ( {'id': 'sck', 'name': 'SCK', 'desc': 'Bit clock line'}, {'id': 'ws', 'name': 'WS', 'desc': 'Word select line'}, @@ -60,6 +58,9 @@ class Decoder(srd.Decoder): ) def __init__(self): + self.reset() + + def reset(self): self.samplerate = None self.oldws = 1 self.bitcount = 0 @@ -89,12 +90,12 @@ class Decoder(srd.Decoder): self.put(self.ss_block, self.samplenum, self.out_ann, data) def report(self): - # Calculate the sample rate. samplerate = '?' if self.ss_block is not None and \ self.first_sample is not None and \ - self.ss_block > self.first_sample: + self.ss_block > self.first_sample and \ + self.samplerate: samplerate = '%d' % (self.samplesreceived * self.samplerate / (self.ss_block - self.first_sample)) @@ -125,8 +126,6 @@ class Decoder(srd.Decoder): return struct.pack('