diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2016-09-23 22:19:57 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2016-10-23 21:48:09 +0200 |
commit | 98b8913915e8649cca83f543e84fbf128707b5fb (patch) | |
tree | 391d29a573a470927382cb38257f0ef7a638a3b2 /decoders | |
parent | 711d0602317e28ddc123ab540036b37979df70c4 (diff) | |
download | libsigrokdecode-98b8913915e8649cca83f543e84fbf128707b5fb.tar.gz libsigrokdecode-98b8913915e8649cca83f543e84fbf128707b5fb.zip |
uart: Emit 2 bytes for 9-bit UART binary output.
For 5..8 data bits the binary output will be 1 byte, for 9 data bits
it will be 2 bytes (big-endian).
This fixes bug #708.
Diffstat (limited to 'decoders')
-rw-r--r-- | decoders/uart/pd.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index 093f3fc..6bba653 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -179,6 +179,7 @@ class Decoder(srd.Decoder): self.out_python = self.register(srd.OUTPUT_PYTHON) self.out_binary = self.register(srd.OUTPUT_BINARY) self.out_ann = self.register(srd.OUTPUT_ANN) + self.bw = (self.options['num_data_bits'] + 7) // 8 def metadata(self, key, value): if key == srd.SRD_CONF_SAMPLERATE: @@ -279,8 +280,9 @@ class Decoder(srd.Decoder): if formatted is not None: self.putx(rxtx, [rxtx, [formatted]]) - self.putbin(rxtx, [rxtx, bytes([b])]) - self.putbin(rxtx, [2, bytes([b])]) + bdata = b.to_bytes(self.bw, byteorder='big') + self.putbin(rxtx, [rxtx, bdata]) + self.putbin(rxtx, [2, bdata]) self.databits[rxtx] = [] |