From 62b37bb2d9e6865ac4a1a3503d6f8beeb62e48da Mon Sep 17 00:00:00 2001 From: chenyue Date: Wed, 17 Jun 2026 21:42:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=BD=E6=98=BE=E7=A4=BA=E6=95=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1-BISS/pd.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/1-BISS/pd.py b/1-BISS/pd.py index 1639b07..6b7552c 100644 --- a/1-BISS/pd.py +++ b/1-BISS/pd.py @@ -50,10 +50,10 @@ For 'START', 'START REPEAT', 'STOP', 'ACK', and 'NACK' is None. # CMD: [annotation-type-index, long annotation, short annotation] proto = { 'BIT': [0, 'Bit', 'B'], - 'START': [1, 'Start', 'Ss'], - 'DATA READ': [2, 'Start repeat', 'Sr'], - 'DATA READ1': [3, 'ACK', 'A'], - 'DATA READ2': [4, 'NACK', 'N'], + 'START': [1, 'Start', 'S'], + 'ASC': [2, 'arc start cds', 'ARC'], + 'P': [3, 'P', 'P'], + 'S': [4, 'S', 'S'], 'ERR': [5, 'Address read', 'AR'], 'CRC': [6, 'Address write', 'AW'], 'STOP': [7, 'Stop', 'P'], @@ -76,17 +76,21 @@ class Decoder(srd.Decoder): annotations = ( ('208', 'bit', 'Data/address bit'), ('207', 'start', 'Start condition'), - ('6', 'data', 'Repeat start condition'), - ('5', 'data1', 'ACK'), - ('0', 'data2', 'NACK'), + ('6', 'asc', 'arc start cds'), + ('5', 'data1', 'p'), + ('0', 'data2', 's'), ('112', 'error', 'Address read'), ('111', 'crc', 'Address write'), ('201', 'stop', 'Stop condition'), + ('202', 'value', 'value'), + ('203', 'value1', 'value2'), + ) annotation_rows = ( ('bits', 'Bits', (0,)), - ('addr-data', 'Address/Data', ( 2, 3, 4,)), - ('flag', 'Flag', ( 1, 5, 6, 7)), + ('p', 'p', ( 8,)), + ('s', 's', ( 9,)), + ('flag', 'Flag', ( 1, 2,3,4,5, 6, 7)), ) binary = ( ('address-read', 'Address read'), @@ -181,8 +185,8 @@ class Decoder(srd.Decoder): self.put(bit[1], bit[2], self.out_ann, [0, ['%d' % bit[0]]]) - self.putx([proto[cmd][0], ['%s: {$}' % proto[cmd][1], '%s: {$}' % proto[cmd][2], '{$}', d]]) - + self.put(self.ss, self.es, self.out_ann, [8, ['%d' % d]]) + self.putx([proto[cmd][0], proto[cmd][1:]]) # Done with this packet. self.bitcount = self.databyte = 0 self.bits = [] @@ -199,13 +203,13 @@ class Decoder(srd.Decoder): self.handle_start() elif self.state == 'FIND DATA': (scl, sda) = self.wait([{0: 'f'}]) - self.handle_data(scl, sda,'DATA READ',2,'FIND DATA1') + self.handle_data(scl, sda,'ASC',3,'FIND DATA1') elif self.state == 'FIND DATA1': (scl, sda) = self.wait([{0: 'f'}]) - self.handle_data(scl, sda,'DATA READ1',12,'FIND DATA2') + self.handle_data(scl, sda,'P',13,'FIND DATA2') elif self.state == 'FIND DATA2': (scl, sda) = self.wait([{0: 'f'}]) - self.handle_data(scl, sda,'DATA READ2',13,'FIND ERR') + self.handle_data(scl, sda,'S',13,'FIND ERR') elif self.state == 'FIND ERR': (scl, sda) = self.wait([{0: 'f'}]) self.handle_data(scl, sda,'ERR',2,'FIND CRC')