Skip to content

Commit e9409d7

Browse files
committed
i2c_packet: removed non-transaction mode
1 parent a05d3a9 commit e9409d7

1 file changed

Lines changed: 12 additions & 25 deletions

File tree

decoders/i2c_packet/pd.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@
4444
'''
4545

4646
class Ann:
47-
PACKET_READ, \
48-
PACKET_WRITE, \
49-
TRANSACTION, \
50-
= range(3)
47+
DATA = 0
5148

5249
class Decoder(srd.Decoder):
5350
api_version = 3
@@ -62,17 +59,12 @@ class Decoder(srd.Decoder):
6259
options = (
6360
{'id': 'format', 'desc': 'Data format', 'default': 'hex',
6461
'values': ('ascii', 'dec', 'hex', 'oct', 'bin')},
65-
{'id': 'transaction', 'desc': 'Transaction mode', 'default': 'no', 'values': ('yes', 'no')},
6662
)
6763
annotations = (
68-
('rd', 'Read'),
69-
('wr', 'Write'),
7064
('data', 'Data'),
7165
)
7266
annotation_rows = (
73-
('rd', 'Read', (Ann.PACKET_READ, )),
74-
('wr', 'Write', (Ann.PACKET_WRITE, )),
75-
('data', 'Data', (Ann.TRANSACTION, )),
67+
('data', 'Data', (Ann.DATA,)),
7668
)
7769

7870
def __init__(self):
@@ -84,7 +76,6 @@ def __init__(self):
8476
self.packet_ss = 0
8577
self.packet_part_ss = 0
8678
self.packet_es = 0
87-
self.transaction = False
8879
self.read_sign = False
8980
self.address = 0
9081
self.fmt = None
@@ -105,7 +96,6 @@ def start(self):
10596
self.fmt = '{:03o}'
10697
else:
10798
self.fmt = None
108-
self.transaction = self.options['transaction'] == 'yes'
10999
self.packet_data = deque()
110100

111101
def reset(self):
@@ -130,6 +120,7 @@ def format_data_value(self, v):
130120
# below 32 is "control" and thus not printable, above 127 is
131121
# "not ASCII" in its strict sense, 127 (DEL) is not printable,
132122
# fall back to hex representation for non-printables.
123+
# (comment from same code of uart PD by Gerhard Sittig @gsigh)
133124
if self.fmt is None:
134125
if 32 <= v <= 126:
135126
return chr(v)
@@ -153,7 +144,7 @@ def format_packet(self):
153144

154145
packet_str_short = packet_str[2:]
155146

156-
if self.transaction and self.packet_str:
147+
if self.packet_str:
157148
packet_str = self.packet_str + ' [SR] ' + packet_str
158149
packet_str_short = self.packet_str_short + ' [SR] ' + packet_str_short
159150

@@ -168,24 +159,20 @@ def handle_packet(self, start_repeat=False):
168159
packet_str, packet_str_short = self.format_packet()
169160

170161
ptype = 'PACKET READ' if self.read_sign else 'PACKET WRITE'
171-
self.putp(self.packet_part_ss, self.packet_es, (ptype, (self.address, tuple(self.packet_data))))
162+
self.putp(self.packet_part_ss, self.packet_es,
163+
(ptype, (self.address, tuple(self.packet_data))))
172164
if not start_repeat:
173-
self.putp(self.packet_es, self.packet_es, ('TRANSACTION END', None))
165+
self.putp(self.packet_es, self.packet_es,
166+
('TRANSACTION END', None))
174167

175-
if start_repeat and self.transaction:
168+
if start_repeat:
176169
self.packet_data.clear()
177170
self.packet_str = packet_str
178171
self.packet_str_short = packet_str_short
179172
else:
180-
if self.transaction:
181-
ann = Ann.TRANSACTION
182-
elif self.read_sign:
183-
ann = Ann.PACKET_READ
184-
else:
185-
ann = Ann.PACKET_WRITE
186-
187-
packet_ss = self.packet_ss if self.transaction else self.packet_part_ss
188-
self.putg(packet_ss, self.packet_es, [ann, [packet_str, packet_str_short]])
173+
packet_ss = self.packet_ss
174+
self.putg(packet_ss, self.packet_es,
175+
[Ann.DATA, [packet_str, packet_str_short]])
189176
self.reset()
190177

191178
def decode(self, ss, es, data):

0 commit comments

Comments
 (0)