diff --git a/decoders/i2c_packet/pd.py b/decoders/i2c_packet/pd.py index e8cc18a4..5c299c7f 100644 --- a/decoders/i2c_packet/pd.py +++ b/decoders/i2c_packet/pd.py @@ -44,10 +44,7 @@ ''' class Ann: - PACKET_READ, \ - PACKET_WRITE, \ - TRANSACTION, \ - = range(3) + DATA = 0 class Decoder(srd.Decoder): api_version = 3 @@ -62,17 +59,12 @@ class Decoder(srd.Decoder): options = ( {'id': 'format', 'desc': 'Data format', 'default': 'hex', 'values': ('ascii', 'dec', 'hex', 'oct', 'bin')}, - {'id': 'transaction', 'desc': 'Transaction mode', 'default': 'no', 'values': ('yes', 'no')}, ) annotations = ( - ('rd', 'Read'), - ('wr', 'Write'), ('data', 'Data'), ) annotation_rows = ( - ('rd', 'Read', (Ann.PACKET_READ, )), - ('wr', 'Write', (Ann.PACKET_WRITE, )), - ('data', 'Data', (Ann.TRANSACTION, )), + ('packet', 'Packet', (Ann.DATA,)), ) def __init__(self): @@ -84,7 +76,6 @@ def __init__(self): self.packet_ss = 0 self.packet_part_ss = 0 self.packet_es = 0 - self.transaction = False self.read_sign = False self.address = 0 self.fmt = None @@ -105,7 +96,6 @@ def start(self): self.fmt = '{:03o}' else: self.fmt = None - self.transaction = self.options['transaction'] == 'yes' self.packet_data = deque() def reset(self): @@ -130,6 +120,7 @@ def format_data_value(self, v): # below 32 is "control" and thus not printable, above 127 is # "not ASCII" in its strict sense, 127 (DEL) is not printable, # fall back to hex representation for non-printables. + # (comment from same code of uart PD by Gerhard Sittig @gsigh) if self.fmt is None: if 32 <= v <= 126: return chr(v) @@ -153,7 +144,7 @@ def format_packet(self): packet_str_short = packet_str[2:] - if self.transaction and self.packet_str: + if self.packet_str: packet_str = self.packet_str + ' [SR] ' + packet_str packet_str_short = self.packet_str_short + ' [SR] ' + packet_str_short @@ -168,24 +159,20 @@ def handle_packet(self, start_repeat=False): packet_str, packet_str_short = self.format_packet() ptype = 'PACKET READ' if self.read_sign else 'PACKET WRITE' - self.putp(self.packet_part_ss, self.packet_es, (ptype, (self.address, tuple(self.packet_data)))) + self.putp(self.packet_part_ss, self.packet_es, + (ptype, (self.address, tuple(self.packet_data)))) if not start_repeat: - self.putp(self.packet_es, self.packet_es, ('TRANSACTION END', None)) + self.putp(self.packet_es, self.packet_es, + ('TRANSACTION END', None)) - if start_repeat and self.transaction: + if start_repeat: self.packet_data.clear() self.packet_str = packet_str self.packet_str_short = packet_str_short else: - if self.transaction: - ann = Ann.TRANSACTION - elif self.read_sign: - ann = Ann.PACKET_READ - else: - ann = Ann.PACKET_WRITE - - packet_ss = self.packet_ss if self.transaction else self.packet_part_ss - self.putg(packet_ss, self.packet_es, [ann, [packet_str, packet_str_short]]) + packet_ss = self.packet_ss + self.putg(packet_ss, self.packet_es, + [Ann.DATA, [packet_str, packet_str_short]]) self.reset() def decode(self, ss, es, data):