forked from Ivasoft/DSView
Fix decoder issues (stop of i2c, break of dmx512)
This commit is contained in:
@@ -249,6 +249,12 @@ class Decoder(srd.Decoder):
|
|||||||
elif (self.matched & (0b1 << 2)):
|
elif (self.matched & (0b1 << 2)):
|
||||||
self.handle_stop()
|
self.handle_stop()
|
||||||
elif self.state == 'FIND ACK':
|
elif self.state == 'FIND ACK':
|
||||||
# Wait for a data/ack bit: SCL = rising.
|
# Wait for any of the following conditions (or combinations):
|
||||||
(scl, sda) = self.wait({0: 'r'})
|
# a) a data/ack bit: SCL = rising.
|
||||||
self.get_ack(scl, sda)
|
# b) STOP condition (P): SCL = high, SDA = rising
|
||||||
|
(scl, sda) = self.wait([{0: 'r'}, {0: 'h', 1: 'r'}])
|
||||||
|
if (self.matched & (0b1 << 0)):
|
||||||
|
self.get_ack(scl, sda)
|
||||||
|
elif (self.matched & (0b1 << 1)):
|
||||||
|
self.handle_stop()
|
||||||
|
|
||||||
|
|||||||
@@ -285,6 +285,12 @@ class Decoder(srd.Decoder):
|
|||||||
elif (self.matched & (0b1 << 2)):
|
elif (self.matched & (0b1 << 2)):
|
||||||
self.handle_stop()
|
self.handle_stop()
|
||||||
elif self.state == 'FIND ACK':
|
elif self.state == 'FIND ACK':
|
||||||
# Wait for a data/ack bit: SCL = rising.
|
# Wait for any of the following conditions (or combinations):
|
||||||
(scl, sda) = self.wait({0: 'r'})
|
# a) a data/ack bit: SCL = rising.
|
||||||
self.get_ack(scl, sda)
|
# b) STOP condition (P): SCL = high, SDA = rising
|
||||||
|
(scl, sda) = self.wait([{0: 'r'}, {0: 'h', 1: 'r'}])
|
||||||
|
if (self.matched & (0b1 << 0)):
|
||||||
|
self.get_ack(scl, sda)
|
||||||
|
elif (self.matched & (0b1 << 1)):
|
||||||
|
self.handle_stop()
|
||||||
|
|
||||||
|
|||||||
@@ -83,12 +83,13 @@ class Decoder(srd.Decoder):
|
|||||||
|
|
||||||
inv = self.options['invert'] == 'yes'
|
inv = self.options['invert'] == 'yes'
|
||||||
|
|
||||||
|
(dmx,) = self.wait({0: 'h' if inv else 'l'})
|
||||||
|
self.run_start = self.samplenum
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# Seek for an interval with no state change with a length between
|
# Seek for an interval with no state change with a length between
|
||||||
# 88 and 1000000 us (BREAK).
|
# 88 and 1000000 us (BREAK).
|
||||||
if self.state == 'FIND BREAK':
|
if self.state == 'FIND BREAK':
|
||||||
(dmx,) = self.wait({0: 'h' if inv else 'l'})
|
|
||||||
self.run_start = self.samplenum
|
|
||||||
(dmx,) = self.wait({0: 'f' if inv else 'r'})
|
(dmx,) = self.wait({0: 'f' if inv else 'r'})
|
||||||
runlen = (self.samplenum - self.run_start) * self.sample_usec
|
runlen = (self.samplenum - self.run_start) * self.sample_usec
|
||||||
if runlen > 88 and runlen < 1000000:
|
if runlen > 88 and runlen < 1000000:
|
||||||
@@ -98,6 +99,9 @@ class Decoder(srd.Decoder):
|
|||||||
elif runlen >= 1000000:
|
elif runlen >= 1000000:
|
||||||
# Error condition.
|
# Error condition.
|
||||||
self.putr([10, ['Invalid break length']])
|
self.putr([10, ['Invalid break length']])
|
||||||
|
else:
|
||||||
|
(dmx,) = self.wait({0: 'h' if inv else 'l'})
|
||||||
|
self.run_start = self.samplenum
|
||||||
# Directly following the BREAK is the MARK AFTER BREAK.
|
# Directly following the BREAK is the MARK AFTER BREAK.
|
||||||
elif self.state == 'MARK MAB':
|
elif self.state == 'MARK MAB':
|
||||||
self.run_start = self.samplenum
|
self.run_start = self.samplenum
|
||||||
|
|||||||
Reference in New Issue
Block a user