## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
+import sigrok
+
class Sample():
def __init__(self, data):
self.data = data
for i in range(0, len(data), unitsize):
yield(Sample(data[i:i+unitsize]))
-class Decoder():
+class Decoder(sigrok.Decoder):
+ id = 'transitioncounter'
name = 'Transition counter'
longname = '...'
desc = 'Counts rising/falling edges in the signal.'
probes = {}
options = {}
- def __init__(self, unitsize, **kwargs):
- # Metadata comes in here, we don't care for now.
- # print kwargs
- self.unitsize = unitsize
-
+ def __init__(self, **kwargs):
self.probes = Decoder.probes.copy()
# TODO: Don't hardcode the number of channels.
self.rising = [0] * self.channels
self.falling = [0] * self.channels
+ def start(self, metadata):
+ self.unitsize = metadata['unitsize']
+
def report(self):
pass
channel(s) of the signal."""
# We should accept a list of samples and iterate...
- for sample in sampleiter(data["data"], self.unitsize):
+ for sample in sampleiter(data['data'], self.unitsize):
# TODO: Eliminate the need for ord().
s = ord(sample.data)
outdata = []
for i in range(self.channels):
outdata += [[self.transitions[i], self.rising[i], self.falling[i]]]
- sigrok.put(outdata)
-
-# Use psyco (if available) as it results in huge performance improvements.
-try:
- import psyco
- psyco.bind(decode)
-except ImportError:
- pass
-
-import sigrok
+ self.put(outdata)