diff --git a/1-BISS/pd.py b/1-BISS/pd.py index 9fb1920..53fe030 100644 --- a/1-BISS/pd.py +++ b/1-BISS/pd.py @@ -54,8 +54,8 @@ proto = { 'ASC': [2, 'arc start cds', 'ARC'], 'P': [3, 'P', 'P'], 'S': [4, 'S', 'S'], - 'ERR': [5, 'Address read', 'AR'], - 'CRC': [6, 'Address write', 'AW'], + 'ERR': [5, 'err', 'err'], + 'CRC': [6, 'CRC', 'CRC'], 'STOP': [7, 'Stop', 'P'], } @@ -146,7 +146,7 @@ class Decoder(srd.Decoder): self.state = 'FIND START' self.bits = [] # Gather 8 bits of data plus the ACK/NACK bit. - def handle_data(self, scl, sda,cmd,size,next_state): + def handle_data(self, scl, sda,cmd,size,next_state,num): # 记录数据值 self.databyte <<= 1 @@ -185,7 +185,7 @@ class Decoder(srd.Decoder): self.put(bit[1], bit[2], self.out_ann, [0, ['%d' % bit[0]]]) - self.put(self.ss, self.es, self.out_ann, [8, ['{$}', d]]) + self.put(self.ss, self.es, self.out_ann, [num, ['{$}', d]]) self.putx([proto[cmd][0], proto[cmd][1:]]) # Done with this packet. self.bitcount = self.databyte = 0 @@ -203,19 +203,19 @@ class Decoder(srd.Decoder): self.handle_start() elif self.state == 'FIND DATA': (scl, sda) = self.wait([{0: 'f'}]) - self.handle_data(scl, sda,'ASC',3,'FIND DATA1') + self.handle_data(scl, sda,'ASC',3,'FIND DATA1',1) elif self.state == 'FIND DATA1': (scl, sda) = self.wait([{0: 'f'}]) - self.handle_data(scl, sda,'P',13,'FIND DATA2') + self.handle_data(scl, sda,'P',13,'FIND DATA2',8) elif self.state == 'FIND DATA2': (scl, sda) = self.wait([{0: 'f'}]) - self.handle_data(scl, sda,'S',13,'FIND ERR') + self.handle_data(scl, sda,'S',13,'FIND ERR',9) elif self.state == 'FIND ERR': (scl, sda) = self.wait([{0: 'f'}]) - self.handle_data(scl, sda,'ERR',2,'FIND CRC') + self.handle_data(scl, sda,'ERR',2,'FIND CRC',1) elif self.state == 'FIND CRC': (scl, sda) = self.wait([{0: 'f'}]) - self.handle_data(scl, sda,'CRC',6,'FIND STOP') + self.handle_data(scl, sda,'CRC',6,'FIND STOP',1) elif self.state == 'FIND STOP': (scl, sda) = self.wait([{0: 'h', 1: 'r'}]) self.handle_stop()