diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2018-09-09 17:31:04 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2018-09-09 17:39:01 +0200 |
commit | 8a8b516aff4005faeea3df0f3ecb22527c10ae8d (patch) | |
tree | ba8fd6540043bd7fabaaa1841329bb916daa1523 /decoders/cec | |
parent | fb248c04c3a96c90aab6472d8641683281f46f69 (diff) | |
download | libsigrokdecode-8a8b516aff4005faeea3df0f3ecb22527c10ae8d.tar.gz libsigrokdecode-8a8b516aff4005faeea3df0f3ecb22527c10ae8d.zip |
cec: Simplify a few code snippets.
Diffstat (limited to 'decoders/cec')
-rw-r--r-- | decoders/cec/pd.py | 19 | ||||
-rw-r--r-- | decoders/cec/protocoldata.py | 5 |
2 files changed, 6 insertions, 18 deletions
diff --git a/decoders/cec/pd.py b/decoders/cec/pd.py index 6c84a4b..a742f81 100644 --- a/decoders/cec/pd.py +++ b/decoders/cec/pd.py @@ -84,8 +84,7 @@ class Decoder(srd.Decoder): def precalculate(self): # Restrict max length of ACK/NACK labels to 2 BIT pulses. - bit_time = timing[Pulse.ZERO]['total']['min'] - bit_time = bit_time * 2 + bit_time = timing[Pulse.ZERO]['total']['min'] * 2 self.max_ack_len_samples = round((bit_time / 1000) * self.samplerate) def reset(self): @@ -149,16 +148,10 @@ class Decoder(srd.Decoder): # Header only commands are PINGS if i == 1: - if self.eom: - str += ' | OPC: PING' - else: - str += ' | OPC: NONE. Aborted cmd' + str += ' | OPC: PING' if self.eom else ' | OPC: NONE. Aborted cmd' # Add extra information (ack of the command from the destination) - if is_nack: - str += ' | R: NACK' - else: - str += ' | R: ACK' + str += ' | R: NACK' if is_nack else ' | R: ACK' self.put(self.frame_start, self.frame_end, self.out_ann, [8, [str]]) @@ -254,10 +247,8 @@ class Decoder(srd.Decoder): self.eom = bit self.frame_end = self.fall_end - if self.eom: - self.put(self.fall_start, self.fall_end, self.out_ann, [2, ['EOM=Y']]) - else: - self.put(self.fall_start, self.fall_end, self.out_ann, [1, ['EOM=N']]) + a = [2, ['EOM=Y']] if self.eom else [1, ['EOM=N']] + self.put(self.fall_start, self.fall_end, self.out_ann, a) self.set_stat(Stat.WAIT_ACK) diff --git a/decoders/cec/protocoldata.py b/decoders/cec/protocoldata.py index dd867e0..fb80494 100644 --- a/decoders/cec/protocoldata.py +++ b/decoders/cec/protocoldata.py @@ -107,10 +107,7 @@ def resolve_logical_address(id, is_initiator): # Special handling of 0x0F. if id == 0x0F: - if is_initiator: - return 'Unregistered' - else: - return 'Broadcast' + return 'Unregistered' if is_initiator else 'Broadcast' return logical_adresses[id] |