From: Uwe Hermann Date: Wed, 22 Jun 2016 20:16:09 +0000 (+0200) Subject: spiflash: Add a 'format' option. X-Git-Tag: libsigrokdecode-0.5.0~161 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b33a73bc0e7185cadc8b93fd283be4007d8167ee;p=libsigrokdecode.git spiflash: Add a 'format' option. --- 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):