diff --git a/libsigrokdecode4DSL/decoders/0-spi/pd.py b/libsigrokdecode4DSL/decoders/0-spi/pd.py index 680128c2..d908d652 100644 --- a/libsigrokdecode4DSL/decoders/0-spi/pd.py +++ b/libsigrokdecode4DSL/decoders/0-spi/pd.py @@ -3,7 +3,7 @@ ## ## Copyright (C) 2011 Gareth McMullin ## Copyright (C) 2012-2014 Uwe Hermann -## Copyright (C) 2019 DreamSourceLab +## Copyright (C) 2024 DreamSourceLab ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ ## along with this program; if not, see . ## +# +# 2024/3/18 DreamSourceLab : format output based on wordsize in hex +# + import sigrokdecode as srd from collections import namedtuple @@ -151,9 +155,9 @@ class Decoder(srd.Decoder): # Dataword annotations. if self.have_miso: - self.put(ss, es, self.out_ann, [0, ['@%02X' % self.misodata]]) + self.put(ss, es, self.out_ann, [0, ['@{1:0>{0}X}'.format(int((self.options['wordsize']+3)/4),self.misodata)]]) if self.have_mosi: - self.put(ss, es, self.out_ann, [1, ['@%02X' % self.mosidata]]) + self.put(ss, es, self.out_ann, [1, ['@{1:0>{0}X}'.format(int((self.options['wordsize']+3)/4),self.mosidata)]]) def reset_decoder_state(self): self.misodata = 0 if self.have_miso else None diff --git a/libsigrokdecode4DSL/decoders/1-spi/pd.py b/libsigrokdecode4DSL/decoders/1-spi/pd.py index 609b4a9c..6a81dc04 100644 --- a/libsigrokdecode4DSL/decoders/1-spi/pd.py +++ b/libsigrokdecode4DSL/decoders/1-spi/pd.py @@ -3,7 +3,7 @@ ## ## Copyright (C) 2011 Gareth McMullin ## Copyright (C) 2012-2014 Uwe Hermann -## Copyright (C) 2019 DreamSourceLab +## Copyright (C) 2024 DreamSourceLab ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -19,6 +19,10 @@ ## along with this program; if not, see . ## +# +# 2024/3/18 DreamSourceLab : format output based on wordsize in hex +# + import sigrokdecode as srd from collections import namedtuple @@ -199,11 +203,13 @@ class Decoder(srd.Decoder): bit = self.mosibits[blen-i-1] self.put(bit[1], bit[2], self.out_ann, [3, ['%d' % bit[0]]]) + + # Dataword annotations. if self.have_miso: - self.put(ss, es, self.out_ann, [0, ['@%02X' % self.misodata]]) + self.put(ss, es, self.out_ann, [0, ['@{1:0>{0}X}'.format(int((self.options['wordsize']+3)/4),self.misodata)]]) if self.have_mosi: - self.put(ss, es, self.out_ann, [1, ['@%02X' % self.mosidata]]) + self.put(ss, es, self.out_ann, [1, ['@{1:0>{0}X}'.format(int((self.options['wordsize']+3)/4),self.mosidata)]]) def reset_decoder_state(self): self.misodata = 0 if self.have_miso else None diff --git a/libsigrokdecode4DSL/decoders/tdm_audio/pd.py b/libsigrokdecode4DSL/decoders/tdm_audio/pd.py index 3b18466c..7cd5f888 100644 --- a/libsigrokdecode4DSL/decoders/tdm_audio/pd.py +++ b/libsigrokdecode4DSL/decoders/tdm_audio/pd.py @@ -2,6 +2,7 @@ ## This file is part of the libsigrokdecode project. ## ## Copyright (C) 2019 Ben Dooks +## Copyright (C) 2024 DreamSourceLab ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -17,6 +18,10 @@ ## along with this program; if not, see . ## +# +# 2024/3/18 DreamSourceLab : fix channel display error +# + import sigrokdecode as srd MAX_CHANNELS = 8 @@ -79,38 +84,37 @@ class Decoder(srd.Decoder): if self.ss_block is not None: if self.bitcount >= self.bitdepth: self.bitcount = 0 - self.channel += 1 - c1 = 'Channel %d' % self.channel - c2 = 'C%d' % self.channel - c3 = '%d' % self.channel + c1 = 'Channel %d' % (self.channel % self.channels) + c2 = 'C%d' % (self.channel % self.channels) + c3 = '%d' % (self.channel % self.channels) if self.bitdepth <= 8: v = '%02x' % self.data elif self.bitdepth <= 16: v = '%04x' % self.data else: v = '%08x' % self.data - - if self.channel < self.channels: - ch = self.channel - else: - ch = 0 + + ch = self.channel % self.channels self.put(self.ss_block, self.samplenum, self.out_ann, [ch, ['%s: %s' % (c1, v), '%s: %s' % (c2, v), '%s: %s' % (c3, v)]]) + self.data = 0 self.ss_block = self.samplenum self.samplecount += 1 + self.channel += 1 # Check for new frame. # Note, frame may be a single clock, or active for the first # sample in the frame. + if frame != self.lastframe and frame == 1: self.channel = 0 self.bitcount = 0 self.data = 0 if self.ss_block is None: self.ss_block = 0 - + self.lastframe = frame