diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2016-10-23 21:01:08 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2016-10-23 21:48:09 +0200 |
commit | 8284ca7360c96ac8085ba90b6f1f0e8fb88e6290 (patch) | |
tree | b26b6a560d2a4a71c184e071b3f96bb94e7070ac /decoders | |
parent | ea36c1988829b9f8e9385ff6e5e506e3cab46877 (diff) | |
download | libsigrokdecode-8284ca7360c96ac8085ba90b6f1f0e8fb88e6290.tar.gz libsigrokdecode-8284ca7360c96ac8085ba90b6f1f0e8fb88e6290.zip |
spi: Fix binary output for wordsizes > 8.
For wordsizes > 8, multiple bytes are used (big-endian).
This fixes bug #686.
Diffstat (limited to 'decoders')
-rw-r--r-- | decoders/spi/pd.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index fc8c7d0..ce007e2 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -152,6 +152,7 @@ class Decoder(srd.Decoder): self.out_binary = self.register(srd.OUTPUT_BINARY) self.out_bitrate = self.register(srd.OUTPUT_META, meta=(int, 'Bitrate', 'Bitrate during transfers')) + self.bw = (self.options['wordsize'] + 7) // 8 def putw(self, data): self.put(self.ss_block, self.samplenum, self.out_ann, data) @@ -165,10 +166,12 @@ class Decoder(srd.Decoder): if self.have_miso: ss, es = self.misobits[-1][1], self.misobits[0][2] - self.put(ss, es, self.out_binary, [0, bytes([so])]) + bdata = so.to_bytes(self.bw, byteorder='big') + self.put(ss, es, self.out_binary, [0, bdata]) if self.have_mosi: ss, es = self.mosibits[-1][1], self.mosibits[0][2] - self.put(ss, es, self.out_binary, [1, bytes([si])]) + bdata = si.to_bytes(self.bw, byteorder='big') + self.put(ss, es, self.out_binary, [1, bdata]) self.put(ss, es, self.out_python, ['BITS', si_bits, so_bits]) self.put(ss, es, self.out_python, ['DATA', si, so]) |