X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Feeprom24xx%2Fpd.py;h=7491f581c572e15fec3864f6e2f92b98bcb9310e;hb=42fb0f33ff23c1633324bde8b3cf400493237d97;hp=982cb50cef66794c806ef7c5824446feae409079;hpb=d6d8a8a440ea2a81e6ddde33d16bc84d01cdb432;p=libsigrokdecode.git diff --git a/decoders/eeprom24xx/pd.py b/decoders/eeprom24xx/pd.py index 982cb50..7491f58 100644 --- a/decoders/eeprom24xx/pd.py +++ b/decoders/eeprom24xx/pd.py @@ -17,6 +17,7 @@ ## along with this program; if not, see . ## +import copy import sigrokdecode as srd from .lists import * @@ -28,7 +29,7 @@ class Decoder(srd.Decoder): desc = '24xx series I²C EEPROM protocol.' license = 'gplv2+' inputs = ['i2c'] - outputs = ['eeprom24xx'] + outputs = [] tags = ['IC', 'Memory'] options = ( {'id': 'chip', 'desc': 'Chip', 'default': 'generic', @@ -38,7 +39,7 @@ class Decoder(srd.Decoder): ) annotations = ( # Warnings - ('warnings', 'Warnings'), + ('warning', 'Warning'), # Bits/bytes ('control-code', 'Control code'), ('address-pin', 'Address pin (A0/A1/A2)'), @@ -416,16 +417,25 @@ class Decoder(srd.Decoder): self.reset_variables() def decode(self, ss, es, data): - self.cmd, self.databyte = data + cmd, _ = data # Collect the 'BITS' packet, then return. The next packet is # guaranteed to belong to these bits we just stored. - if self.cmd == 'BITS': - self.bits = self.databyte + if cmd == 'BITS': + _, databits = data + self.bits = copy.deepcopy(databits) return - # Store the start/end samples of this I²C packet. + # Store the start/end samples of this I²C packet. Deep copy + # caller's data, assuming that implementation details of the + # above complex methods can access the data after returning + # from the .decode() invocation, with the data having become + # invalid by that time of access. This conservative approach + # can get weakened after close inspection of those methods. self.ss, self.es = ss, es + _, databyte = data + databyte = copy.deepcopy(databyte) + self.cmd, self.databyte = cmd, databyte # State machine. s = 'handle_%s' % self.state.lower().replace(' ', '_')