diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2016-06-22 22:16:09 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2016-06-22 22:16:09 +0200 |
commit | b33a73bc0e7185cadc8b93fd283be4007d8167ee (patch) | |
tree | 7789a84e1e1858a62be1bb56afcebedbffa8f232 /decoders/spiflash | |
parent | 1ec9c5e29850740a96d3e2b137ace9a4a678d786 (diff) | |
download | libsigrokdecode-b33a73bc0e7185cadc8b93fd283be4007d8167ee.tar.gz libsigrokdecode-b33a73bc0e7185cadc8b93fd283be4007d8167ee.zip |
spiflash: Add a 'format' option.
Diffstat (limited to 'decoders/spiflash')
-rw-r--r-- | decoders/spiflash/pd.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/decoders/spiflash/pd.py b/decoders/spiflash/pd.py index 03e16e2..10c3919 100644 --- a/decoders/spiflash/pd.py +++ b/decoders/spiflash/pd.py @@ -84,6 +84,8 @@ class Decoder(srd.Decoder): options = ( {'id': 'chip', 'desc': 'Chip', 'default': tuple(chips.keys())[0], 'values': tuple(chips.keys())}, + {'id': 'format', 'desc': 'Data format', 'default': 'hex', + 'values': ('hex', 'ascii')}, ) def __init__(self): @@ -361,7 +363,10 @@ class Decoder(srd.Decoder): # Print accumulated block of data # (called on CS# de-assert via self.on_end_transaction callback). self.es_block = self.es # Ends on the CS# de-assert sample. - s = ' '.join([('%02x' % b) for b in self.data]) + if self.options['format'] == 'hex': + s = ' '.join([('%02x' % b) for b in self.data]) + else: + s = ''.join(map(chr, self.data)) self.putb([25, ['%s %d bytes: %s' % (label, len(self.data), s)]]) def decode(self, ss, es, data): |