From: Uwe Hermann Date: Tue, 3 Dec 2013 13:46:23 +0000 (+0100) Subject: uart: Display non-ASCII characters properly. X-Git-Tag: libsigrokdecode-0.3.0~211 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8705ddc81b001d7f79ed94e9aa34b792cfdd4481;p=libsigrokdecode.git uart: Display non-ASCII characters properly. We use the [XX] notation for non-printable characters, which is what various other logic analyzer software packages do too, e.g. the CWAV USBee Suite. This fixes bug #201. --- diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index f010480..d71fc23 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -222,7 +222,8 @@ class Decoder(srd.Decoder): b, f = self.databyte[rxtx], self.options['format'] if f == 'ascii': - self.putx(rxtx, [rxtx, [chr(b)]]) + c = chr(b) if chr(b).isprintable() else '[%02X]' % b + self.putx(rxtx, [rxtx, [c]]) elif f == 'dec': self.putx(rxtx, [rxtx, [str(b)]]) elif f == 'hex':