def __init__(self, data):
self.data = data
def probe(self, probe):
- s = ord(self.data[probe / 8]) & (1 << (probe % 8))
+ s = self.data[probe / 8] & (1 << (probe % 8))
return True if s else False
def sampleiter(data, unitsize):
def __init__(self, **kwargs):
self.probes = Decoder.probes.copy()
+ self.output_protocol = None
+ self.output_annotation = None
# Set defaults, can be overridden in 'start'.
self.baudrate = 115200
def start(self, metadata):
self.unitsize = metadata['unitsize']
self.samplerate = metadata['samplerate']
+ # self.output_protocol = self.output_new(2)
+ self.output_annotation = self.output_new(1)
# TODO
### self.baudrate = metadata['baudrate']
# TODO: Currently only supports 1 stop bit.
def get_stop_bits(self, signal):
# Skip samples until we're in the middle of the stop bit(s).
- skip_parity = 0
- if self.parity != PARITY_NONE:
- skip_parity = 1
+ skip_parity = 0 if self.parity == PARITY_NONE else 1
if not self.reached_bit(self.num_data_bits + 1 + skip_parity):
return []
'data': None, 'ann': 'Stop bit'}]
return o
- def decode(self, data):
- """UART protocol decoder"""
-
+ def decode(self, timeoffset, duration, data):
out = []
- for sample in sampleiter(data["data"], self.unitsize):
+ for sample in sampleiter(data, self.unitsize):
# TODO: Eliminate the need for ord().
s = ord(sample.data)
# self.oldtx = tx
if out != []:
- self.put(out)
+ # self.put(self.output_protocol, 0, 0, out_proto)
+ self.put(self.output_annotation, 0, 0, out)