X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fi2cdemux%2Fpd.py;h=2495e84931a3a42d0af015672d154bd32fd46d5e;hp=1bf96a94b8ac39b6e8ec6560eba08c5ba07e0fc0;hb=b66bfd9573bada4d3249e9029e6c6c6112d7b4ac;hpb=25ac80b22a198833caa515875ab61a1e15adca18 diff --git a/decoders/i2cdemux/pd.py b/decoders/i2cdemux/pd.py index 1bf96a9..2495e84 100644 --- a/decoders/i2cdemux/pd.py +++ b/decoders/i2cdemux/pd.py @@ -14,16 +14,13 @@ ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## along with this program; if not, see . ## -# Generic I²C demultiplexing protocol decoder - import sigrokdecode as srd class Decoder(srd.Decoder): - api_version = 1 + api_version = 3 id = 'i2cdemux' name = 'I²C demux' longname = 'I²C demultiplexer' @@ -31,19 +28,18 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = [] # TODO: Only known at run-time. - probes = [] - optional_probes = [] - options = {} - annotations = [] - def __init__(self, **kwargs): + def __init__(self): + self.reset() + + def reset(self): self.packets = [] # Local cache of I²C packets self.slaves = [] # List of known slave addresses self.stream = -1 # Current output stream self.streamcount = 0 # Number of created output streams def start(self): - self.out_proto = [] + self.out_python = [] # Grab I²C packets into a local cache, until an I²C STOP condition # packet comes along. At some point before that STOP condition, there @@ -65,8 +61,8 @@ class Decoder(srd.Decoder): # We're never seen this slave, add a new stream. self.slaves.append(databyte) - self.out_proto.append(self.register(srd.OUTPUT_PYTHON, - proto_id='i2c-%s' % hex(databyte))) + self.out_python.append(self.register(srd.OUTPUT_PYTHON, + proto_id='i2c-%s' % hex(databyte))) self.stream = self.streamcount self.streamcount += 1 elif cmd == 'STOP': @@ -75,10 +71,9 @@ class Decoder(srd.Decoder): # Send the whole chunk of I²C packets to the correct stream. for p in self.packets: - self.put(p[0], p[1], self.out_proto[self.stream], p[2]) + self.put(p[0], p[1], self.out_python[self.stream], p[2]) self.packets = [] self.stream = -1 else: pass # Do nothing, only add the I²C packet to our cache. -