From: Simon Ruderich Date: Thu, 8 Feb 2024 23:21:23 +0000 (+0100) Subject: avr_isp: fix crash if part name is not known X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c600ee71ea021fd581cf48419e6a051da5b44c06;p=libsigrokdecode.git avr_isp: fix crash if part name is not known Decoding an unknown part causes a KeyError exception. For example for an ATmega328/P: srd: KeyError: Calling avr_isp-1 decode() failed: (149, 15) --- diff --git a/decoders/avr_isp/pd.py b/decoders/avr_isp/pd.py index e3af4d6..9e3c5df 100644 --- a/decoders/avr_isp/pd.py +++ b/decoders/avr_isp/pd.py @@ -123,9 +123,12 @@ class Decoder(srd.Decoder): self.part_number = ret[3] self.putx([Ann.RSB2, ['Part number: 0x%02x' % ret[3]]]) - p = part[(self.part_fam_flash_size, self.part_number)] - data = [Ann.DEV, ['Device: Atmel %s' % p]] - self.put(self.ss_device, self.es_cmd, self.out_ann, data) + # Part name if known + key = (self.part_fam_flash_size, self.part_number) + if key in part: + p = part[key] + data = [Ann.DEV, ['Device: Atmel %s' % p]] + self.put(self.ss_device, self.es_cmd, self.out_ann, data) # Sanity check on reply. if ret[1] != 0x30 or ret[2] != self.xx or ret[0] != self.mm: