分离数据到不同的行

This commit is contained in:
2026-06-17 21:56:35 +08:00
parent 051bbaeb5f
commit 51dd512ff8
+9 -9
View File
@@ -54,8 +54,8 @@ proto = {
'ASC': [2, 'arc start cds', 'ARC'], 'ASC': [2, 'arc start cds', 'ARC'],
'P': [3, 'P', 'P'], 'P': [3, 'P', 'P'],
'S': [4, 'S', 'S'], 'S': [4, 'S', 'S'],
'ERR': [5, 'Address read', 'AR'], 'ERR': [5, 'err', 'err'],
'CRC': [6, 'Address write', 'AW'], 'CRC': [6, 'CRC', 'CRC'],
'STOP': [7, 'Stop', 'P'], 'STOP': [7, 'Stop', 'P'],
} }
@@ -146,7 +146,7 @@ class Decoder(srd.Decoder):
self.state = 'FIND START' self.state = 'FIND START'
self.bits = [] self.bits = []
# Gather 8 bits of data plus the ACK/NACK bit. # 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 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(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:]]) self.putx([proto[cmd][0], proto[cmd][1:]])
# Done with this packet. # Done with this packet.
self.bitcount = self.databyte = 0 self.bitcount = self.databyte = 0
@@ -203,19 +203,19 @@ class Decoder(srd.Decoder):
self.handle_start() self.handle_start()
elif self.state == 'FIND DATA': elif self.state == 'FIND DATA':
(scl, sda) = self.wait([{0: 'f'}]) (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': elif self.state == 'FIND DATA1':
(scl, sda) = self.wait([{0: 'f'}]) (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': elif self.state == 'FIND DATA2':
(scl, sda) = self.wait([{0: 'f'}]) (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': elif self.state == 'FIND ERR':
(scl, sda) = self.wait([{0: 'f'}]) (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': elif self.state == 'FIND CRC':
(scl, sda) = self.wait([{0: 'f'}]) (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': elif self.state == 'FIND STOP':
(scl, sda) = self.wait([{0: 'h', 1: 'r'}]) (scl, sda) = self.wait([{0: 'h', 1: 'r'}])
self.handle_stop() self.handle_stop()