X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=decoders%2Fi2cfilter%2Fi2cfilter.py;h=fad11c31d77a718023dda904c3a00ffa59bb3b86;hb=ee3e279c7558b388410d16cbce9db6c80e9c0c67;hp=6c1f4c862e300d80dcfe457aa4ecdad00fa06ffd;hpb=e4f822680083b65e34b9c8b091025f66ea6efde6;p=libsigrokdecode.git diff --git a/decoders/i2cfilter/i2cfilter.py b/decoders/i2cfilter/i2cfilter.py index 6c1f4c8..fad11c3 100644 --- a/decoders/i2cfilter/i2cfilter.py +++ b/decoders/i2cfilter/i2cfilter.py @@ -30,10 +30,13 @@ class Decoder(srd.Decoder): license = 'gplv3+' inputs = ['i2c'] outputs = [] + probes = [] + optional_probes = [] options = { 'address': ['Address to filter out of the I2C stream', 0], 'direction': ['Direction to filter (read/write)', ''] } + annotations = [] def __init__(self, **kwargs): self.state = None @@ -41,11 +44,14 @@ class Decoder(srd.Decoder): def start(self, metadata): self.out_proto = self.add(srd.OUTPUT_PROTO, 'i2cdata') if self.options['direction'] not in ('', 'read', 'write'): - raise Exception("Invalid direction: expected 'read' or 'write'") + raise Exception('Invalid direction: expected "read" or "write"') + + def report(self): + pass def decode(self, ss, es, data): try: - cmd, data, ack_bit = data + cmd, data = data except Exception as e: raise Exception('Malformed I2C input: %s' % str(e)) from e @@ -57,6 +63,9 @@ class Decoder(srd.Decoder): if cmd == 'STOP': self.state = None return + if cmd in ('ACK', 'NACK'): + # Don't care, we just want data. + return if self.state == 'start': # Start of a transfer, see if we want this one.