From 98b8913915e8649cca83f543e84fbf128707b5fb Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Fri, 23 Sep 2016 22:19:57 +0200 Subject: 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. --- decoders/uart/pd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'decoders') 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] = [] -- cgit v1.2.3-70-g09d2