From: Uwe Hermann Date: Thu, 12 Sep 2013 07:32:28 +0000 (+0200) Subject: uart: Use same length for data output in all cases. X-Git-Tag: libsigrokdecode-0.3.0~321 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1f224555348ff440bdbd7014f66ac5ce44eb4d27;p=libsigrokdecode.git uart: Use same length for data output in all cases. Until now you could get e.g. "d" or "df" as hex output from the UART PD. This will now be a common-length "0D" and "DF". When all data byte annotations are of the same lengths the readability in GUI traces is a lot better. Also, hardcode hex characters to be upper-case (for now). The same applies to oct ("021" instead of "21") and bin output ("00001001" instead of "1001"). --- diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index 5a6dfc0..e67da57 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -227,11 +227,11 @@ class Decoder(srd.Decoder): elif f == 'dec': self.putx(rxtx, [0, [s + str(b)]]) elif f == 'hex': - self.putx(rxtx, [0, [s + hex(b)[2:]]]) + self.putx(rxtx, [0, [s + hex(b)[2:].zfill(2).upper()]]) elif f == 'oct': - self.putx(rxtx, [0, [s + oct(b)[2:]]]) + self.putx(rxtx, [0, [s + oct(b)[2:].zfill(3)]]) elif f == 'bin': - self.putx(rxtx, [0, [s + bin(b)[2:]]]) + self.putx(rxtx, [0, [s + bin(b)[2:].zfill(8)]]) else: raise Exception('Invalid data format option: %s' % f)