]> sigrok.org Git - libsigrokdecode.git/blame_incremental - decoders/uart/pd.py
uart: Drop question mark from two option names.
[libsigrokdecode.git] / decoders / uart / pd.py
... / ...
CommitLineData
1##
2## This file is part of the libsigrokdecode project.
3##
4## Copyright (C) 2011-2014 Uwe Hermann <uwe@hermann-uwe.de>
5##
6## This program is free software; you can redistribute it and/or modify
7## it under the terms of the GNU General Public License as published by
8## the Free Software Foundation; either version 2 of the License, or
9## (at your option) any later version.
10##
11## This program is distributed in the hope that it will be useful,
12## but WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14## GNU General Public License for more details.
15##
16## You should have received a copy of the GNU General Public License
17## along with this program; if not, see <http://www.gnu.org/licenses/>.
18##
19
20import sigrokdecode as srd
21from common.srdhelper import bitpack
22from math import floor, ceil
23
24'''
25OUTPUT_PYTHON format:
26
27Packet:
28[<ptype>, <rxtx>, <pdata>]
29
30This is the list of <ptype>s and their respective <pdata> values:
31 - 'STARTBIT': The data is the (integer) value of the start bit (0/1).
32 - 'DATA': This is always a tuple containing two items:
33 - 1st item: the (integer) value of the UART data. Valid values
34 range from 0 to 511 (as the data can be up to 9 bits in size).
35 - 2nd item: the list of individual data bits and their ss/es numbers.
36 - 'PARITYBIT': The data is the (integer) value of the parity bit (0/1).
37 - 'STOPBIT': The data is the (integer) value of the stop bit (0 or 1).
38 - 'INVALID STARTBIT': The data is the (integer) value of the start bit (0/1).
39 - 'INVALID STOPBIT': The data is the (integer) value of the stop bit (0/1).
40 - 'PARITY ERROR': The data is a tuple with two entries. The first one is
41 the expected parity value, the second is the actual parity value.
42 - 'BREAK': The data is always 0.
43 - 'FRAME': The data is always a tuple containing two items: The (integer)
44 value of the UART data, and a boolean which reflects the validity of the
45 UART frame.
46 - 'IDLE': The data is always 0.
47
48The <rxtx> field is 0 for RX packets, 1 for TX packets.
49'''
50
51# Used for differentiating between the two data directions.
52RX = 0
53TX = 1
54
55# Given a parity type to check (odd, even, zero, one), the value of the
56# parity bit, the value of the data, and the length of the data (5-9 bits,
57# usually 8 bits) return True if the parity is correct, False otherwise.
58# 'none' is _not_ allowed as value for 'parity_type'.
59def parity_ok(parity_type, parity_bit, data, data_bits):
60
61 if parity_type == 'ignore':
62 return True
63
64 # Handle easy cases first (parity bit is always 1 or 0).
65 if parity_type == 'zero':
66 return parity_bit == 0
67 elif parity_type == 'one':
68 return parity_bit == 1
69
70 # Count number of 1 (high) bits in the data (and the parity bit itself!).
71 ones = bin(data).count('1') + parity_bit
72
73 # Check for odd/even parity.
74 if parity_type == 'odd':
75 return (ones % 2) == 1
76 elif parity_type == 'even':
77 return (ones % 2) == 0
78
79class SamplerateError(Exception):
80 pass
81
82class ChannelError(Exception):
83 pass
84
85class Decoder(srd.Decoder):
86 api_version = 3
87 id = 'uart'
88 name = 'UART'
89 longname = 'Universal Asynchronous Receiver/Transmitter'
90 desc = 'Asynchronous, serial bus.'
91 license = 'gplv2+'
92 inputs = ['logic']
93 outputs = ['uart']
94 tags = ['Embedded/industrial']
95 optional_channels = (
96 # Allow specifying only one of the signals, e.g. if only one data
97 # direction exists (or is relevant).
98 {'id': 'rx', 'name': 'RX', 'desc': 'UART receive line'},
99 {'id': 'tx', 'name': 'TX', 'desc': 'UART transmit line'},
100 )
101 options = (
102 {'id': 'baudrate', 'desc': 'Baud rate', 'default': 115200},
103 {'id': 'data_bits', 'desc': 'Data bits', 'default': 8,
104 'values': (5, 6, 7, 8, 9)},
105 {'id': 'parity', 'desc': 'Parity', 'default': 'none',
106 'values': ('none', 'odd', 'even', 'zero', 'one', 'ignore')},
107 {'id': 'stop_bits', 'desc': 'Stop bits', 'default': 1.0,
108 'values': (0.0, 0.5, 1.0, 1.5)},
109 {'id': 'bit_order', 'desc': 'Bit order', 'default': 'lsb-first',
110 'values': ('lsb-first', 'msb-first')},
111 {'id': 'format', 'desc': 'Data format', 'default': 'hex',
112 'values': ('ascii', 'dec', 'hex', 'oct', 'bin')},
113 {'id': 'invert_rx', 'desc': 'Invert RX', 'default': 'no',
114 'values': ('yes', 'no')},
115 {'id': 'invert_tx', 'desc': 'Invert TX', 'default': 'no',
116 'values': ('yes', 'no')},
117 {'id': 'rx_packet_delim', 'desc': 'RX packet delimiter (decimal)',
118 'default': -1},
119 {'id': 'tx_packet_delim', 'desc': 'TX packet delimiter (decimal)',
120 'default': -1},
121 {'id': 'rx_packet_len', 'desc': 'RX packet length', 'default': -1},
122 {'id': 'tx_packet_len', 'desc': 'TX packet length', 'default': -1},
123 )
124 annotations = (
125 ('rx-data', 'RX data'),
126 ('tx-data', 'TX data'),
127 ('rx-start', 'RX start bits'),
128 ('tx-start', 'TX start bits'),
129 ('rx-parity-ok', 'RX parity OK bits'),
130 ('tx-parity-ok', 'TX parity OK bits'),
131 ('rx-parity-err', 'RX parity error bits'),
132 ('tx-parity-err', 'TX parity error bits'),
133 ('rx-stop', 'RX stop bits'),
134 ('tx-stop', 'TX stop bits'),
135 ('rx-warnings', 'RX warnings'),
136 ('tx-warnings', 'TX warnings'),
137 ('rx-data-bits', 'RX data bits'),
138 ('tx-data-bits', 'TX data bits'),
139 ('rx-break', 'RX break'),
140 ('tx-break', 'TX break'),
141 ('rx-packet', 'RX packet'),
142 ('tx-packet', 'TX packet'),
143 )
144 annotation_rows = (
145 ('rx-data-bits', 'RX bits', (12,)),
146 ('rx-data', 'RX', (0, 2, 4, 6, 8)),
147 ('rx-warnings', 'RX warnings', (10,)),
148 ('rx-break', 'RX break', (14,)),
149 ('rx-packets', 'RX packets', (16,)),
150 ('tx-data-bits', 'TX bits', (13,)),
151 ('tx-data', 'TX', (1, 3, 5, 7, 9)),
152 ('tx-warnings', 'TX warnings', (11,)),
153 ('tx-break', 'TX break', (15,)),
154 ('tx-packets', 'TX packets', (17,)),
155 )
156 binary = (
157 ('rx', 'RX dump'),
158 ('tx', 'TX dump'),
159 ('rxtx', 'RX/TX dump'),
160 )
161 idle_state = ['WAIT FOR START BIT', 'WAIT FOR START BIT']
162
163 def putx(self, rxtx, data):
164 s, halfbit = self.startsample[rxtx], self.bit_width / 2.0
165 self.put(s - floor(halfbit), self.samplenum + ceil(halfbit), self.out_ann, data)
166
167 def putx_packet(self, rxtx, data):
168 s, halfbit = self.ss_packet[rxtx], self.bit_width / 2.0
169 self.put(s - floor(halfbit), self.samplenum + ceil(halfbit), self.out_ann, data)
170
171 def putpx(self, rxtx, data):
172 s, halfbit = self.startsample[rxtx], self.bit_width / 2.0
173 self.put(s - floor(halfbit), self.samplenum + ceil(halfbit), self.out_python, data)
174
175 def putg(self, data):
176 s, halfbit = self.samplenum, self.bit_width / 2.0
177 self.put(s - floor(halfbit), s + ceil(halfbit), self.out_ann, data)
178
179 def putp(self, data):
180 s, halfbit = self.samplenum, self.bit_width / 2.0
181 self.put(s - floor(halfbit), s + ceil(halfbit), self.out_python, data)
182
183 def putgse(self, ss, es, data):
184 self.put(ss, es, self.out_ann, data)
185
186 def putpse(self, ss, es, data):
187 self.put(ss, es, self.out_python, data)
188
189 def putbin(self, rxtx, data):
190 s, halfbit = self.startsample[rxtx], self.bit_width / 2.0
191 self.put(s - floor(halfbit), self.samplenum + ceil(halfbit), self.out_binary, data)
192
193 def __init__(self):
194 self.reset()
195
196 def reset(self):
197 self.samplerate = None
198 self.samplenum = 0
199 self.frame_start = [-1, -1]
200 self.frame_valid = [None, None]
201 self.startbit = [-1, -1]
202 self.cur_data_bit = [0, 0]
203 self.datavalue = [0, 0]
204 self.paritybit = [-1, -1]
205 self.stopbit1 = [-1, -1]
206 self.startsample = [-1, -1]
207 self.state = ['WAIT FOR START BIT', 'WAIT FOR START BIT']
208 self.databits = [[], []]
209 self.break_start = [None, None]
210 self.packet_cache = [[], []]
211 self.ss_packet, self.es_packet = [None, None], [None, None]
212 self.idle_start = [None, None]
213
214 def start(self):
215 self.out_python = self.register(srd.OUTPUT_PYTHON)
216 self.out_binary = self.register(srd.OUTPUT_BINARY)
217 self.out_ann = self.register(srd.OUTPUT_ANN)
218 self.bw = (self.options['data_bits'] + 7) // 8
219
220 def metadata(self, key, value):
221 if key == srd.SRD_CONF_SAMPLERATE:
222 self.samplerate = value
223 # The width of one UART bit in number of samples.
224 self.bit_width = float(self.samplerate) / float(self.options['baudrate'])
225
226 def get_sample_point(self, rxtx, bitnum):
227 # Determine absolute sample number of a bit slot's sample point.
228 # bitpos is the samplenumber which is in the middle of the
229 # specified UART bit (0 = start bit, 1..x = data, x+1 = parity bit
230 # (if used) or the first stop bit, and so on).
231 # The samples within bit are 0, 1, ..., (bit_width - 1), therefore
232 # index of the middle sample within bit window is (bit_width - 1) / 2.
233 bitpos = self.frame_start[rxtx] + (self.bit_width - 1) / 2.0
234 bitpos += bitnum * self.bit_width
235 return bitpos
236
237 def wait_for_start_bit(self, rxtx, signal):
238 # Save the sample number where the start bit begins.
239 self.frame_start[rxtx] = self.samplenum
240 self.frame_valid[rxtx] = True
241
242 self.state[rxtx] = 'GET START BIT'
243
244 def get_start_bit(self, rxtx, signal):
245 self.startbit[rxtx] = signal
246
247 # The startbit must be 0. If not, we report an error and wait
248 # for the next start bit (assuming this one was spurious).
249 if self.startbit[rxtx] != 0:
250 self.putp(['INVALID STARTBIT', rxtx, self.startbit[rxtx]])
251 self.putg([rxtx + 10, ['Frame error', 'Frame err', 'FE']])
252 self.frame_valid[rxtx] = False
253 es = self.samplenum + ceil(self.bit_width / 2.0)
254 self.putpse(self.frame_start[rxtx], es, ['FRAME', rxtx,
255 (self.datavalue[rxtx], self.frame_valid[rxtx])])
256 self.state[rxtx] = 'WAIT FOR START BIT'
257 return
258
259 self.cur_data_bit[rxtx] = 0
260 self.datavalue[rxtx] = 0
261 self.startsample[rxtx] = -1
262
263 self.putp(['STARTBIT', rxtx, self.startbit[rxtx]])
264 self.putg([rxtx + 2, ['Start bit', 'Start', 'S']])
265
266 self.state[rxtx] = 'GET DATA BITS'
267
268 def handle_packet(self, rxtx):
269 d = 'rx' if (rxtx == RX) else 'tx'
270 delim = self.options[d + '_packet_delim']
271 plen = self.options[d + '_packet_len']
272 if delim == -1 and plen == -1:
273 return
274
275 # Cache data values until we see the delimiter and/or the specified
276 # packet length has been reached (whichever happens first).
277 if len(self.packet_cache[rxtx]) == 0:
278 self.ss_packet[rxtx] = self.startsample[rxtx]
279 self.packet_cache[rxtx].append(self.datavalue[rxtx])
280 if self.datavalue[rxtx] == delim or len(self.packet_cache[rxtx]) == plen:
281 self.es_packet[rxtx] = self.samplenum
282 s = ''
283 for b in self.packet_cache[rxtx]:
284 s += self.format_value(b)
285 if self.options['format'] != 'ascii':
286 s += ' '
287 if self.options['format'] != 'ascii' and s[-1] == ' ':
288 s = s[:-1] # Drop trailing space.
289 self.putx_packet(rxtx, [16 + rxtx, [s]])
290 self.packet_cache[rxtx] = []
291
292 def get_data_bits(self, rxtx, signal):
293 # Save the sample number of the middle of the first data bit.
294 if self.startsample[rxtx] == -1:
295 self.startsample[rxtx] = self.samplenum
296
297 self.putg([rxtx + 12, ['%d' % signal]])
298
299 # Store individual data bits and their start/end samplenumbers.
300 s, halfbit = self.samplenum, int(self.bit_width / 2)
301 self.databits[rxtx].append([signal, s - halfbit, s + halfbit])
302
303 # Return here, unless we already received all data bits.
304 self.cur_data_bit[rxtx] += 1
305 if self.cur_data_bit[rxtx] < self.options['data_bits']:
306 return
307
308 # Convert accumulated data bits to a data value.
309 bits = [b[0] for b in self.databits[rxtx]]
310 if self.options['bit_order'] == 'msb-first':
311 bits.reverse()
312 self.datavalue[rxtx] = bitpack(bits)
313 self.putpx(rxtx, ['DATA', rxtx,
314 (self.datavalue[rxtx], self.databits[rxtx])])
315
316 b = self.datavalue[rxtx]
317 formatted = self.format_value(b)
318 if formatted is not None:
319 self.putx(rxtx, [rxtx, [formatted]])
320
321 bdata = b.to_bytes(self.bw, byteorder='big')
322 self.putbin(rxtx, [rxtx, bdata])
323 self.putbin(rxtx, [2, bdata])
324
325 self.handle_packet(rxtx)
326
327 self.databits[rxtx] = []
328
329 # Advance to either reception of the parity bit, or reception of
330 # the STOP bits if parity is not applicable.
331 self.state[rxtx] = 'GET PARITY BIT'
332 if self.options['parity'] == 'none':
333 self.state[rxtx] = 'GET STOP BITS'
334
335 def format_value(self, v):
336 # Format value 'v' according to configured options.
337 # Reflects the user selected kind of representation, as well as
338 # the number of data bits in the UART frames.
339
340 fmt, bits = self.options['format'], self.options['data_bits']
341
342 # Assume "is printable" for values from 32 to including 126,
343 # below 32 is "control" and thus not printable, above 127 is
344 # "not ASCII" in its strict sense, 127 (DEL) is not printable,
345 # fall back to hex representation for non-printables.
346 if fmt == 'ascii':
347 if v in range(32, 126 + 1):
348 return chr(v)
349 hexfmt = "[{:02X}]" if bits <= 8 else "[{:03X}]"
350 return hexfmt.format(v)
351
352 # Mere number to text conversion without prefix and padding
353 # for the "decimal" output format.
354 if fmt == 'dec':
355 return "{:d}".format(v)
356
357 # Padding with leading zeroes for hex/oct/bin formats, but
358 # without a prefix for density -- since the format is user
359 # specified, there is no ambiguity.
360 if fmt == 'hex':
361 digits = (bits + 4 - 1) // 4
362 fmtchar = "X"
363 elif fmt == 'oct':
364 digits = (bits + 3 - 1) // 3
365 fmtchar = "o"
366 elif fmt == 'bin':
367 digits = bits
368 fmtchar = "b"
369 else:
370 fmtchar = None
371 if fmtchar is not None:
372 fmt = "{{:0{:d}{:s}}}".format(digits, fmtchar)
373 return fmt.format(v)
374
375 return None
376
377 def get_parity_bit(self, rxtx, signal):
378 self.paritybit[rxtx] = signal
379
380 if parity_ok(self.options['parity'], self.paritybit[rxtx],
381 self.datavalue[rxtx], self.options['data_bits']):
382 self.putp(['PARITYBIT', rxtx, self.paritybit[rxtx]])
383 self.putg([rxtx + 4, ['Parity bit', 'Parity', 'P']])
384 else:
385 # TODO: Return expected/actual parity values.
386 self.putp(['PARITY ERROR', rxtx, (0, 1)]) # FIXME: Dummy tuple...
387 self.putg([rxtx + 6, ['Parity error', 'Parity err', 'PE']])
388 self.frame_valid[rxtx] = False
389
390 self.state[rxtx] = 'GET STOP BITS'
391
392 # TODO: Currently only supports 1 stop bit.
393 def get_stop_bits(self, rxtx, signal):
394 self.stopbit1[rxtx] = signal
395
396 # Stop bits must be 1. If not, we report an error.
397 if self.stopbit1[rxtx] != 1:
398 self.putp(['INVALID STOPBIT', rxtx, self.stopbit1[rxtx]])
399 self.putg([rxtx + 10, ['Frame error', 'Frame err', 'FE']])
400 self.frame_valid[rxtx] = False
401
402 self.putp(['STOPBIT', rxtx, self.stopbit1[rxtx]])
403 self.putg([rxtx + 4, ['Stop bit', 'Stop', 'T']])
404
405 # Pass the complete UART frame to upper layers.
406 es = self.samplenum + ceil(self.bit_width / 2.0)
407 self.putpse(self.frame_start[rxtx], es, ['FRAME', rxtx,
408 (self.datavalue[rxtx], self.frame_valid[rxtx])])
409
410 self.state[rxtx] = 'WAIT FOR START BIT'
411 self.idle_start[rxtx] = self.frame_start[rxtx] + self.frame_len_sample_count
412
413 def handle_break(self, rxtx):
414 self.putpse(self.frame_start[rxtx], self.samplenum,
415 ['BREAK', rxtx, 0])
416 self.putgse(self.frame_start[rxtx], self.samplenum,
417 [rxtx + 14, ['Break condition', 'Break', 'Brk', 'B']])
418 self.state[rxtx] = 'WAIT FOR START BIT'
419
420 def get_wait_cond(self, rxtx, inv):
421 # Return condititions that are suitable for Decoder.wait(). Those
422 # conditions either match the falling edge of the START bit, or
423 # the sample point of the next bit time.
424 state = self.state[rxtx]
425 if state == 'WAIT FOR START BIT':
426 return {rxtx: 'r' if inv else 'f'}
427 if state == 'GET START BIT':
428 bitnum = 0
429 elif state == 'GET DATA BITS':
430 bitnum = 1 + self.cur_data_bit[rxtx]
431 elif state == 'GET PARITY BIT':
432 bitnum = 1 + self.options['data_bits']
433 elif state == 'GET STOP BITS':
434 bitnum = 1 + self.options['data_bits']
435 bitnum += 0 if self.options['parity'] == 'none' else 1
436 want_num = ceil(self.get_sample_point(rxtx, bitnum))
437 return {'skip': want_num - self.samplenum}
438
439 def get_idle_cond(self, rxtx, inv):
440 # Return a condition that corresponds to the (expected) end of
441 # the next frame, assuming that it will be an "idle frame"
442 # (constant high input level for the frame's length).
443 if self.idle_start[rxtx] is None:
444 return None
445 end_of_frame = self.idle_start[rxtx] + self.frame_len_sample_count
446 if end_of_frame < self.samplenum:
447 return None
448 return {'skip': end_of_frame - self.samplenum}
449
450 def inspect_sample(self, rxtx, signal, inv):
451 # Inspect a sample returned by .wait() for the specified UART line.
452 if inv:
453 signal = not signal
454
455 state = self.state[rxtx]
456 if state == 'WAIT FOR START BIT':
457 self.wait_for_start_bit(rxtx, signal)
458 elif state == 'GET START BIT':
459 self.get_start_bit(rxtx, signal)
460 elif state == 'GET DATA BITS':
461 self.get_data_bits(rxtx, signal)
462 elif state == 'GET PARITY BIT':
463 self.get_parity_bit(rxtx, signal)
464 elif state == 'GET STOP BITS':
465 self.get_stop_bits(rxtx, signal)
466
467 def inspect_edge(self, rxtx, signal, inv):
468 # Inspect edges, independently from traffic, to detect break conditions.
469 if inv:
470 signal = not signal
471 if not signal:
472 # Signal went low. Start another interval.
473 self.break_start[rxtx] = self.samplenum
474 return
475 # Signal went high. Was there an extended period with low signal?
476 if self.break_start[rxtx] is None:
477 return
478 diff = self.samplenum - self.break_start[rxtx]
479 if diff >= self.break_min_sample_count:
480 self.handle_break(rxtx)
481 self.break_start[rxtx] = None
482
483 def inspect_idle(self, rxtx, signal, inv):
484 # Check each edge and each period of stable input (either level).
485 # Can derive the "idle frame period has passed" condition.
486 if inv:
487 signal = not signal
488 if not signal:
489 # Low input, cease inspection.
490 self.idle_start[rxtx] = None
491 return
492 # High input, either just reached, or still stable.
493 if self.idle_start[rxtx] is None:
494 self.idle_start[rxtx] = self.samplenum
495 diff = self.samplenum - self.idle_start[rxtx]
496 if diff < self.frame_len_sample_count:
497 return
498 ss, es = self.idle_start[rxtx], self.samplenum
499 self.putpse(ss, es, ['IDLE', rxtx, 0])
500 self.idle_start[rxtx] = self.samplenum
501
502 def decode(self):
503 if not self.samplerate:
504 raise SamplerateError('Cannot decode without samplerate.')
505
506 has_pin = [self.has_channel(ch) for ch in (RX, TX)]
507 if not True in has_pin:
508 raise ChannelError('Need at least one of TX or RX pins.')
509
510 opt = self.options
511 inv = [opt['invert_rx'] == 'yes', opt['invert_tx'] == 'yes']
512 cond_data_idx = [None] * len(has_pin)
513
514 # Determine the number of samples for a complete frame's time span.
515 # A period of low signal (at least) that long is a break condition.
516 frame_samples = 1 # START
517 frame_samples += self.options['data_bits']
518 frame_samples += 0 if self.options['parity'] == 'none' else 1
519 frame_samples += self.options['stop_bits']
520 frame_samples *= self.bit_width
521 self.frame_len_sample_count = ceil(frame_samples)
522 self.break_min_sample_count = self.frame_len_sample_count
523 cond_edge_idx = [None] * len(has_pin)
524 cond_idle_idx = [None] * len(has_pin)
525
526 while True:
527 conds = []
528 if has_pin[RX]:
529 cond_data_idx[RX] = len(conds)
530 conds.append(self.get_wait_cond(RX, inv[RX]))
531 cond_edge_idx[RX] = len(conds)
532 conds.append({RX: 'e'})
533 cond_idle_idx[RX] = None
534 idle_cond = self.get_idle_cond(RX, inv[RX])
535 if idle_cond:
536 cond_idle_idx[RX] = len(conds)
537 conds.append(idle_cond)
538 if has_pin[TX]:
539 cond_data_idx[TX] = len(conds)
540 conds.append(self.get_wait_cond(TX, inv[TX]))
541 cond_edge_idx[TX] = len(conds)
542 conds.append({TX: 'e'})
543 cond_idle_idx[TX] = None
544 idle_cond = self.get_idle_cond(TX, inv[TX])
545 if idle_cond:
546 cond_idle_idx[TX] = len(conds)
547 conds.append(idle_cond)
548 (rx, tx) = self.wait(conds)
549 if cond_data_idx[RX] is not None and self.matched[cond_data_idx[RX]]:
550 self.inspect_sample(RX, rx, inv[RX])
551 if cond_edge_idx[RX] is not None and self.matched[cond_edge_idx[RX]]:
552 self.inspect_edge(RX, rx, inv[RX])
553 self.inspect_idle(RX, rx, inv[RX])
554 if cond_idle_idx[RX] is not None and self.matched[cond_idle_idx[RX]]:
555 self.inspect_idle(RX, rx, inv[RX])
556 if cond_data_idx[TX] is not None and self.matched[cond_data_idx[TX]]:
557 self.inspect_sample(TX, tx, inv[TX])
558 if cond_edge_idx[TX] is not None and self.matched[cond_edge_idx[TX]]:
559 self.inspect_edge(TX, tx, inv[TX])
560 self.inspect_idle(TX, tx, inv[TX])
561 if cond_idle_idx[TX] is not None and self.matched[cond_idle_idx[TX]]:
562 self.inspect_idle(TX, tx, inv[TX])