self.databyte = 0
self.wr = -1
self.startsample = -1
+ self.is_repeat_start = 0
self.FIND_START, self.FIND_ADDRESS, self.FIND_DATA = range(3)
self.state = self.FIND_START
pass
def is_start_condition(self, scl, sda):
- '''START condition (S): SDA = falling, SCL = high'''
+ """START condition (S): SDA = falling, SCL = high"""
if (self.oldsda == 1 and sda == 0) and scl == 1:
return True
return False
def is_data_bit(self, scl, sda):
- '''Data sampling of receiver: SCL = rising'''
+ """Data sampling of receiver: SCL = rising"""
if self.oldscl == 0 and scl == 1:
return True
return False
def is_stop_condition(self, scl, sda):
- '''STOP condition (P): SDA = rising, SCL = high'''
+ """STOP condition (P): SDA = rising, SCL = high"""
if (self.oldsda == 0 and sda == 1) and scl == 1:
return True
return False
out = []
# o = {'type': 'S', 'range': (self.samplenum, self.samplenum),
# 'data': None, 'ann': None},
- o = 'S'
+ o = (self.is_repeat_start == 1) and 'Sr' or 'S'
out.append(o)
self.state = self.FIND_ADDRESS
self.bitcount = self.databyte = 0
+ self.is_repeat_start = 1
self.wr = -1
return out
def find_address_or_data(self, scl, sda):
- '''Gather 8 bits of data plus the ACK/NACK bit.'''
+ """Gather 8 bits of data plus the ACK/NACK bit."""
out = o = []
if self.startsample == -1:
# 'range': (self.startsample, self.samplenum - 1),
# 'data': d, 'ann': None}
- o = {'data': "0x%02x" % d}
+ o = {'data': '0x%02x' % d}
# TODO: Simplify.
if self.state == self.FIND_ADDRESS and self.wr == 1:
o = 'P'
out.append(o)
self.state = self.FIND_START
+ self.is_repeat_start = 0
self.wr = -1
return out
o = ack = d = ''
# We should accept a list of samples and iterate...
- for sample in sampleiter(data["data"], self.unitsize):
+ for sample in sampleiter(data['data'], self.unitsize):
# TODO: Eliminate the need for ord().
s = ord(sample.data)
if out != []:
sigrok.put(out)
-# Use psyco (if available) as it results in huge performance improvements.
-try:
- import psyco
- psyco.bind(decode)
-except ImportError:
- pass
-
import sigrok