summaryrefslogtreecommitdiff
path: root/decoders/spi.py
diff options
context:
space:
mode:
authorGareth McMullin <gareth@blacksphere.co.nz>2011-12-01 23:09:40 +1300
committerGareth McMullin <gareth@blacksphere.co.nz>2011-12-01 23:10:28 +1300
commit67e847fd2185aa5677954dceacf3c279d7a68af1 (patch)
tree81d6fc2e649e9414cc618ab615f88b8c6b4ef583 /decoders/spi.py
parent400f9ae7ff16bb611d758d75ff4931b667561b11 (diff)
downloadlibsigrokdecode-67e847fd2185aa5677954dceacf3c279d7a68af1.tar.gz
libsigrokdecode-67e847fd2185aa5677954dceacf3c279d7a68af1.zip
srd: PDs now explicitly register with sigrok module.
Diffstat (limited to 'decoders/spi.py')
-rw-r--r--decoders/spi.py22
1 files changed, 4 insertions, 18 deletions
diff --git a/decoders/spi.py b/decoders/spi.py
index 383206b..d9891b3 100644
--- a/decoders/spi.py
+++ b/decoders/spi.py
@@ -18,6 +18,8 @@
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
+import sigrok
+
class Sample():
def __init__(self, data):
self.data = data
@@ -30,6 +32,7 @@ def sampleiter(data, unitsize):
yield(Sample(data[i:i+unitsize]))
class Decoder():
+ id = 'spi'
name = 'SPI Decoder'
desc = '...desc...'
longname = '...longname...'
@@ -93,22 +96,5 @@ class Decoder():
# Keep stats for summary
self.bytesreceived += 1
-if __name__ == '__main__':
- data = open('spi_dump.bin').read()
-
- # dummy class to keep Decoder happy for test
- class Sigrok():
- def put(self, data):
- print "\t", data
- sigrok = Sigrok()
-
- dec = Decoder(driver='ols', unitsize=1, starttime=0)
- dec.decode({'time':0, 'duration':len(data), 'data':data, 'type':'logic'})
-
- print dec.summary()
-else:
- import sigrok
-
-#Tested with:
-# sigrok-cli -d 0:samplerate=1000000:rle=on --time=1s -p 1,2 -a spidec
+sigrok.register(Decoder)