From b33a73bc0e7185cadc8b93fd283be4007d8167ee Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Wed, 22 Jun 2016 22:16:09 +0200 Subject: spiflash: Add a 'format' option. --- decoders/spiflash/pd.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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): -- cgit v1.2.3-70-g09d2