diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2017-05-03 22:37:15 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2017-05-06 19:56:55 +0200 |
commit | b13ced31554253f301143aa7c8121a4460db57b6 (patch) | |
tree | af1c64004295daff65d4f1820b70005e98c1432b | |
parent | 3a9c517e63cfced0470b08a7d8b5fc1006b55e8e (diff) | |
download | libsigrokdecode-b13ced31554253f301143aa7c8121a4460db57b6.tar.gz libsigrokdecode-b13ced31554253f301143aa7c8121a4460db57b6.zip |
eeprom93cxx: Shorten put_word() a bit.
-rw-r--r-- | decoders/eeprom93cxx/pd.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/decoders/eeprom93cxx/pd.py b/decoders/eeprom93cxx/pd.py index 0fd6969..06d92fb 100644 --- a/decoders/eeprom93cxx/pd.py +++ b/decoders/eeprom93cxx/pd.py @@ -62,16 +62,11 @@ class Decoder(srd.Decoder): # Decode word (MSb first). word = 0 for b in range(len(data)): - if si: - word += (data[b]['si'] << (len(data) - b - 1)) - else: - word += (data[b]['so'] << (len(data) - b - 1)) - if si: - self.put(data[0]['ss'], data[-1]['se'], - self.out_ann, [0, ['Data: 0x%x' % word, '0x%x' % word]]) - else: - self.put(data[0]['ss'], data[-1]['se'], - self.out_ann, [1, ['Data: 0x%x' % word, '0x%x' % word]]) + idx = 'si' if si else 'so' + word += (data[b][idx] << (len(data) - b - 1)) + idx = 0 if si else 1 + self.put(data[0]['ss'], data[-1]['se'], + self.out_ann, [idx, ['Data: 0x%x' % word, '0x%x' % word]]) def decode(self, ss, es, data): if len(data) < (2 + self.addresssize): |