summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorBert Vermeulen <bert@biot.com>2011-12-15 03:31:31 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2011-12-28 12:17:13 +0100
commit1aef2f93a29f01168c04fd0478b29af290d8756b (patch)
treea82ddaa52862dcb8302d58b9b902f7d38b0b1c57 /decoders
parente508088229e96423854ba6db63084c9bb18eeb34 (diff)
downloadlibsigrokdecode-1aef2f93a29f01168c04fd0478b29af290d8756b.tar.gz
libsigrokdecode-1aef2f93a29f01168c04fd0478b29af290d8756b.zip
make time/duration work, at least when loading from a session file
PD decode() call now takes 3 arguments: timeoffset, duration, data as per the current API specification.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/i2c.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/decoders/i2c.py b/decoders/i2c.py
index 9ff89c9..c57dd33 100644
--- a/decoders/i2c.py
+++ b/decoders/i2c.py
@@ -313,11 +313,26 @@ class Decoder(sigrok.Decoder):
self.is_repeat_start = 0
self.wr = -1
- def decode(self, data):
+ def put(self, output_id, data):
+ timeoffset = self.timeoffset + ((self.samplenum - self.bitcount) * self.period)
+ if self.bitcount > 0:
+ duration = self.bitcount * self.period
+ else:
+ duration = self.period
+ print "**", timeoffset, duration
+ super(Decoder, self).put(timeoffset, duration, output_id, data)
+
+ def decode(self, timeoffset, duration, data):
"""I2C protocol decoder"""
+ self.timeoffset = timeoffset
+ self.duration = duration
+ print "++", timeoffset, duration, len(data)
+ # duration of one bit in ps, only valid for this call to decode()
+ self.period = duration / len(data)
+
# We should accept a list of samples and iterate...
- for sample in sampleiter(data['data'], self.unitsize):
+ for sample in sampleiter(data, self.unitsize):
# TODO: Eliminate the need for ord().
s = ord(sample.data)