summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorRyan Jarvis <ryan@shopboxretail.com>2019-01-19 00:05:07 -0800
committerUwe Hermann <uwe@hermann-uwe.de>2019-01-30 00:08:39 +0100
commit16d2031b149ff67be83b5600bdf5ad561add312d (patch)
tree242478dfaba1fa4e1542cfa492e328e4f8ffa6d0 /decoders
parentf78b814d54b19233d5e3f7cfef3d30a7a5ac8d40 (diff)
downloadlibsigrokdecode-16d2031b149ff67be83b5600bdf5ad561add312d.tar.gz
libsigrokdecode-16d2031b149ff67be83b5600bdf5ad561add312d.zip
Rename values that shadow built-in keywords
Diffstat (limited to 'decoders')
-rw-r--r--decoders/arm_etmv3/pd.py36
-rw-r--r--decoders/cec/pd.py26
-rw-r--r--decoders/cec/protocoldata.py8
-rw-r--r--decoders/jtag_ejtag/pd.py6
-rw-r--r--decoders/lin/pd.py16
-rw-r--r--decoders/spiflash/pd.py4
6 files changed, 48 insertions, 48 deletions
diff --git a/decoders/arm_etmv3/pd.py b/decoders/arm_etmv3/pd.py
index 8de3ce2..5916824 100644
--- a/decoders/arm_etmv3/pd.py
+++ b/decoders/arm_etmv3/pd.py
@@ -31,30 +31,30 @@ exc_names = [
for i in range(8, 496):
exc_names.append('IRQ%d' % i)
-def parse_varint(bytes):
+def parse_varint(bytes_):
'''Parse an integer where the top bit is the continuation bit.
Returns value and number of parsed bytes.'''
v = 0
- for i, b in enumerate(bytes):
+ for i, b in enumerate(bytes_):
v |= (b & 0x7F) << (i * 7)
if b & 0x80 == 0:
return v, i+1
- return v, len(bytes)
+ return v, len(bytes_)
-def parse_uint(bytes):
+def parse_uint(bytes_):
'''Parse little-endian integer.'''
v = 0
- for i, b in enumerate(bytes):
+ for i, b in enumerate(bytes_):
v |= b << (i * 8)
return v
-def parse_exc_info(bytes):
+def parse_exc_info(bytes_):
'''Parse exception information bytes from a branch packet.'''
- if len(bytes) < 1:
+ if len(bytes_) < 1:
return None
- excv, exclen = parse_varint(bytes)
- if bytes[exclen - 1] & 0x80 != 0x00:
+ excv, exclen = parse_varint(bytes_)
+ if bytes_[exclen - 1] & 0x80 != 0x00:
return None # Exception info not complete.
if exclen == 2 and excv & (1 << 13):
@@ -69,21 +69,21 @@ def parse_exc_info(bytes):
resume = (excv >> 14) & 0x0F
return (ns, exc, cancel, altisa, hyp, resume)
-def parse_branch_addr(bytes, ref_addr, cpu_state, branch_enc):
+def parse_branch_addr(bytes_, ref_addr, cpu_state, branch_enc):
'''Parse encoded branch address.
Returns addr, addrlen, cpu_state, exc_info.
Returns None if packet is not yet complete'''
- addr, addrlen = parse_varint(bytes)
+ addr, addrlen = parse_varint(bytes_)
- if bytes[addrlen-1] & 0x80 != 0x00:
+ if bytes_[addrlen - 1] & 0x80 != 0x00:
return None # Branch address not complete.
addr_bits = 7 * addrlen
have_exc_info = False
if branch_enc == 'original':
- if addrlen == 5 and bytes[4] & 0x40:
+ if addrlen == 5 and bytes_[4] & 0x40:
have_exc_info = True
elif branch_enc == 'alternative':
addr_bits -= 1 # Top bit of address indicates exc_info.
@@ -93,20 +93,20 @@ def parse_branch_addr(bytes, ref_addr, cpu_state, branch_enc):
exc_info = None
if have_exc_info:
- exc_info = parse_exc_info(bytes[addrlen:])
+ exc_info = parse_exc_info(bytes_[addrlen:])
if exc_info is None:
return None # Exception info not complete.
if addrlen == 5:
# Possible change in CPU state.
- if bytes[4] & 0xB8 == 0x08:
+ if bytes_[4] & 0xB8 == 0x08:
cpu_state = 'arm'
- elif bytes[4] & 0xB0 == 0x10:
+ elif bytes_[4] & 0xB0 == 0x10:
cpu_state = 'thumb'
- elif bytes[4] & 0xA0 == 0x20:
+ elif bytes_[4] & 0xA0 == 0x20:
cpu_state = 'jazelle'
else:
- raise NotImplementedError('Unhandled branch byte 4: 0x%02x' % bytes[4])
+ raise NotImplementedError('Unhandled branch byte 4: 0x%02x' % bytes_[4])
# Shift the address according to current CPU state.
if cpu_state == 'arm':
diff --git a/decoders/cec/pd.py b/decoders/cec/pd.py
index 6e8ddec..e4a40f3 100644
--- a/decoders/cec/pd.py
+++ b/decoders/cec/pd.py
@@ -116,41 +116,41 @@ class Decoder(srd.Decoder):
return
i = 0
- str = ''
+ string = ''
while i < len(self.cmd_bytes):
- str += '{:02x}'.format(self.cmd_bytes[i]['val'])
+ string += '{:02x}'.format(self.cmd_bytes[i]['val'])
if i != (len(self.cmd_bytes) - 1):
- str += ':'
+ string += ':'
i += 1
- self.put(self.frame_start, self.frame_end, self.out_ann, [7, [str]])
+ self.put(self.frame_start, self.frame_end, self.out_ann, [7, [string]])
i = 0
operands = 0
- str = ''
+ string = ''
while i < len(self.cmd_bytes):
if i == 0: # Parse header
(src, dst) = decode_header(self.cmd_bytes[i]['val'])
- str = 'HDR: ' + src + ', ' + dst
+ string = 'HDR: ' + src + ', ' + dst
elif i == 1: # Parse opcode
- str += ' | OPC: ' + opcodes.get(self.cmd_bytes[i]['val'], 'Invalid')
+ string += ' | OPC: ' + opcodes.get(self.cmd_bytes[i]['val'], 'Invalid')
else: # Parse operands
if operands == 0:
- str += ' | OPS: '
+ string += ' | OPS: '
operands += 1
- str += '0x{:02x}'.format(self.cmd_bytes[i]['val'])
+ string += '0x{:02x}'.format(self.cmd_bytes[i]['val'])
if i != len(self.cmd_bytes) - 1:
- str += ', '
+ string += ', '
i += 1
# Header only commands are PINGS
if i == 1:
- str += ' | OPC: PING' if self.eom else ' | OPC: NONE. Aborted cmd'
+ string += ' | OPC: PING' if self.eom else ' | OPC: NONE. Aborted cmd'
# Add extra information (ack of the command from the destination)
- str += ' | R: NACK' if is_nack else ' | R: ACK'
+ string += ' | R: NACK' if is_nack else ' | R: ACK'
- self.put(self.frame_start, self.frame_end, self.out_ann, [8, [str]])
+ self.put(self.frame_start, self.frame_end, self.out_ann, [8, [string]])
def process(self):
zero_time = ((self.rise - self.fall_start) / self.samplerate) * 1000.0
diff --git a/decoders/cec/protocoldata.py b/decoders/cec/protocoldata.py
index 833ac7f..78c3b6f 100644
--- a/decoders/cec/protocoldata.py
+++ b/decoders/cec/protocoldata.py
@@ -101,15 +101,15 @@ opcodes = {
0x9A: 'SET_AUDIO_RATE',
}
-def resolve_logical_address(id, is_initiator):
- if id < 0 or id > 0x0F:
+def resolve_logical_address(id_, is_initiator):
+ if id_ < 0 or id_ > 0x0F:
return 'Invalid'
# Special handling of 0x0F.
- if id == 0x0F:
+ if id_ == 0x0F:
return 'Unregistered' if is_initiator else 'Broadcast'
- return logical_adresses[id]
+ return logical_adresses[id_]
def decode_header(header):
src = (header & 0xF0) >> 4
diff --git a/decoders/jtag_ejtag/pd.py b/decoders/jtag_ejtag/pd.py
index ceaa114..94a3a1a 100644
--- a/decoders/jtag_ejtag/pd.py
+++ b/decoders/jtag_ejtag/pd.py
@@ -357,16 +357,16 @@ class Decoder(srd.Decoder):
def handle_ir_tdi(self, val):
code = bin2int(val[0])
- hex = '0x{:02X}'.format(code)
+ hex_value = '0x{:02X}'.format(code)
if code in ejtag_insn:
# Format instruction name.
insn = ejtag_insn[code]
s_short = insn[0]
- s_long = insn[0] + ': ' + insn[1] + ' (' + hex + ')'
+ s_long = insn[0] + ': ' + insn[1] + ' (' + hex_value + ')'
# Display it and select data register.
self.put_current([Ann.INSTRUCTION, [s_long, s_short]])
else:
- self.put_current([Ann.INSTRUCTION, [hex, 'IR TDI ({})'.format(hex)]])
+ self.put_current([Ann.INSTRUCTION, [hex_value, 'IR TDI ({})'.format(hex_value)]])
self.select_reg(code)
def handle_new_state(self, new_state):
diff --git a/decoders/lin/pd.py b/decoders/lin/pd.py
index e0340fc..e1b6d1b 100644
--- a/decoders/lin/pd.py
+++ b/decoders/lin/pd.py
@@ -150,7 +150,7 @@ class Decoder(srd.Decoder):
checksum = self.lin_rsp.pop() if len(self.lin_rsp) else None
if pid:
- id = pid[2] & 0x3F
+ id_ = pid[2] & 0x3F
parity = pid[2] >> 6
expected_parity = self.calc_parity(pid[2])
@@ -161,8 +161,8 @@ class Decoder(srd.Decoder):
ann_class = 0 if parity_valid else 3
self.put(pid[0], pid[1], self.out_ann, [ann_class, [
- 'ID: %02X Parity: %d (%s)' % (id, parity, 'ok' if parity_valid else 'bad'),
- 'ID: 0x%02X' % id, 'I: %d' % id
+ 'ID: %02X Parity: %d (%s)' % (id_, parity, 'ok' if parity_valid else 'bad'),
+ 'ID: 0x%02X' % id_, 'I: %d' % id_
]])
if len(self.lin_rsp):
@@ -188,9 +188,9 @@ class Decoder(srd.Decoder):
def checksum_is_valid(self, pid, data, checksum):
if self.lin_version == 2:
- id = pid & 0x3F
+ id_ = pid & 0x3F
- if id != 60 and id != 61:
+ if id_ != 60 and id_ != 61:
checksum += pid
for d in data:
@@ -203,10 +203,10 @@ class Decoder(srd.Decoder):
@staticmethod
def calc_parity(pid):
- id = [((pid & 0x3F) >> i) & 1 for i in range(8)]
+ id_ = [((pid & 0x3F) >> i) & 1 for i in range(8)]
- p0 = id[0] ^ id[1] ^ id[2] ^ id[4]
- p1 = not (id[1] ^ id[3] ^ id[4] ^ id[5])
+ p0 = id_[0] ^ id_[1] ^ id_[2] ^ id_[4]
+ p1 = not (id_[1] ^ id_[3] ^ id_[4] ^ id_[5])
return (p0 << 0) | (p1 << 1)
diff --git a/decoders/spiflash/pd.py b/decoders/spiflash/pd.py
index aecc2d3..bbdf3fb 100644
--- a/decoders/spiflash/pd.py
+++ b/decoders/spiflash/pd.py
@@ -473,8 +473,8 @@ class Decoder(srd.Decoder):
self.putx([Ann.FIELD, ['%s ID: 0x%02x' % (d, miso)]])
if self.cmdstate == 6:
- id = self.ids[1] if self.manufacturer_id_first else self.ids[0]
- self.device_id = id
+ id_ = self.ids[1] if self.manufacturer_id_first else self.ids[0]
+ self.device_id = id_
self.es_cmd = self.es
self.putc([Ann.REMS, self.cmd_vendor_dev_list()])
self.state = None