self.syncbuf = []
self.prevsample = 0
self.stream = 0
- self.stream_ss = None
+ self.ss_stream = None
self.bytenum = 0
def start(self):
def stream_changed(self, ss, stream):
if self.stream != stream:
if self.stream != 0:
- self.put(self.stream_ss, ss, self.out_ann,
+ self.put(self.ss_stream, ss, self.out_ann,
[0, ['Stream %d' % self.stream, 'S%d' % self.stream]])
self.stream = stream
- self.stream_ss = ss
+ self.ss_stream = ss
def emit_byte(self, ss, es, byte):
if self.stream == self.options['stream']:
self.oldpl = 0
self.oldsamplenum = 0
self.last_bit_pos = 0
- self.first_ss = 0
+ self.ss_first = 0
self.first_one = 0
self.state = 'HEADER'
self.data = 0
self.data_bits = 0
- self.data_ss = 0
+ self.ss_data = 0
self.data_parity = 0
self.payload_cnt = 0
self.data_col_parity = [0, 0, 0, 0, 0, 0]
if self.first_one > 0:
self.first_one += 1
if self.first_one == 9:
- self.put(self.first_ss, es, self.out_ann,
+ self.put(self.ss_first, es, self.out_ann,
[1, ['Header', 'Head', 'He', 'H']])
self.first_one = 0
self.state = 'PAYLOAD'
return
if self.first_one == 0:
self.first_one = 1
- self.first_ss = ss
+ self.ss_first = ss
if bit == 0:
self.first_one = 0
if self.state == 'PAYLOAD':
self.payload_cnt += 1
if self.data_bits == 0:
- self.data_ss = ss
+ self.ss_data = ss
self.data = 0
self.data_parity = 0
self.data_bits += 1
if self.data_bits == 5:
s = 'Version/customer' if self.payload_cnt <= 10 else 'Data'
c = 2 if self.payload_cnt <= 10 else 3
- self.put(self.data_ss, ss, self.out_ann,
+ self.put(self.ss_data, ss, self.out_ann,
[c, [s + ': %X' % self.data, '%X' % self.data]])
s = 'OK' if self.data_parity == bit else 'ERROR'
c = 4 if s == 'OK' else 5
if self.state == 'TRAILER':
self.payload_cnt += 1
if self.data_bits == 0:
- self.data_ss = ss
+ self.ss_data = ss
self.data = 0
self.data_parity = 0
self.data_bits += 1
# Emit an annotation for valid-looking tags.
all_col_parity_ok = (self.data_col_parity[1:5] == self.col_parity[1:5])
if all_col_parity_ok and self.all_row_parity_ok:
- self.put(self.first_ss, es, self.out_ann,
+ self.put(self.ss_first, es, self.out_ann,
[9, ['Tag: %010X' % self.tag, 'Tag', 'T']])
self.tag = 0
def __init__(self):
self.samplerate = None
self.oldpin = None
- self.packet_ss = None
+ self.ss_packet = None
self.ss = None
self.es = None
self.bits = []
if len(self.bits) == 24:
grb = reduce(lambda a, b: (a << 1) | b, self.bits)
rgb = (grb & 0xff0000) >> 8 | (grb & 0x00ff00) << 8 | (grb & 0x0000ff)
- self.put(self.packet_ss, samplenum, self.out_ann,
+ self.put(self.ss_packet, samplenum, self.out_ann,
[2, ['#%06x' % rgb]])
self.bits = []
- self.packet_ss = None
+ self.ss_packet = None
def decode(self, ss, es, data):
if not self.samplerate:
self.inreset = True
self.bits = []
- self.packet_ss = None
+ self.ss_packet = None
self.ss = None
if not self.oldpin and pin:
self.bits.append(bit_)
self.handle_bits(samplenum)
- if self.packet_ss is None:
- self.packet_ss = samplenum
+ if self.ss_packet is None:
+ self.ss_packet = samplenum
self.ss = samplenum
self.put(self.ss, self.es, self.out_ann, data)
def putb(self, data):
- self.put(self.block_ss, self.block_es, self.out_ann, data)
+ self.put(self.ss_block, self.es_block, self.out_ann, data)
def handle_wren(self, mosi, miso):
self.putx([0, ['Command: %s' % cmds[self.state][1]]])
# Bytes 2/3/4: Master sends read address (24bits, MSB-first).
self.putx([24, ['AD%d: 0x%02x' % (self.cmdstate - 1, mosi)]])
if self.cmdstate == 2:
- self.block_ss = self.ss
+ self.ss_block = self.ss
self.addr |= (mosi << ((4 - self.cmdstate) * 8))
elif self.cmdstate == 5:
self.putx([24, ['Dummy byte: 0x%02x' % mosi]])
- self.block_es = self.es
+ self.es_block = self.es
self.putb([5, ['Read address: 0x%06x' % self.addr]])
self.addr = 0
elif self.cmdstate >= 6:
# Bytes 6-x: Master reads data bytes (until CS# de-asserted).
# TODO: For now we hardcode 32 bytes per FAST READ command.
if self.cmdstate == 6:
- self.block_ss = self.ss
+ self.ss_block = self.ss
if self.cmdstate <= 32 + 5: # TODO: While CS# asserted.
self.data.append(miso)
if self.cmdstate == 32 + 5: # TODO: If CS# got de-asserted.
- self.block_es = self.es
+ self.es_block = self.es
s = ' '.join([hex(b)[2:] for b in self.data])
self.putb([25, ['Read data: %s' % s]])
self.data = []
def __init__(self):
self.oldstep = None
- self.prev_step_ss = None
+ self.ss_prev_step = None
self.pos = 0
self.prev_speed = None
self.prev_pos = None
self.unit = 'mm'
def step(self, ss, direction):
- if self.prev_step_ss is not None:
- delta = ss - self.prev_step_ss
+ if self.ss_prev_step is not None:
+ delta = ss - self.ss_prev_step
speed = self.samplerate / delta / self.scale
speed_txt = self.format % speed
pos_txt = self.format % (self.pos / self.scale)
- self.put(self.prev_step_ss, ss, self.out_ann,
+ self.put(self.ss_prev_step, ss, self.out_ann,
[0, [speed_txt + ' ' + self.unit + '/s', speed_txt]])
- self.put(self.prev_step_ss, ss, self.out_ann,
+ self.put(self.ss_prev_step, ss, self.out_ann,
[1, [pos_txt + ' ' + self.unit, pos_txt]])
self.pos += (1 if direction else -1)
- self.prev_step_ss = ss
+ self.ss_prev_step = ss
def metadata(self, key, value):
if key == srd.SRD_CONF_SAMPLERATE:
self.request = {}
self.request_id = 0
self.transaction_state = 'IDLE'
- self.transaction_ss = None
- self.transaction_es = None
+ self.ss_transaction = None
+ self.es_transaction = None
self.transaction_ep = None
self.transaction_addr = None
self.wrote_pcap_header = False
addr = self.transaction_addr
if not (addr, ep) in self.request:
self.request[(addr, ep)] = {'setup_data': [], 'data': [],
- 'type': None, 'ss': self.transaction_ss, 'es': None,
+ 'type': None, 'ss': self.ss_transaction, 'es': None,
'id': self.request_id, 'addr': addr, 'ep': ep}
self.request_id += 1
request_started = 1
if request['type'] in (None, 'BULK IN') and self.transaction_type == 'IN':
request['type'] = 'BULK IN'
request['data'] += self.transaction_data
- request['es'] = self.transaction_es
+ request['es'] = self.es_transaction
self.handle_request(request_started, request_end)
elif request['type'] in (None, 'BULK OUT') and self.transaction_type == 'OUT':
request['type'] = 'BULK OUT'
request['data'] += self.transaction_data
- request['es'] = self.transaction_es
+ request['es'] = self.es_transaction
self.handle_request(request_started, request_end)
# CONTROL, SETUP stage
# CONTROL, STATUS stage
elif request['type'] == 'SETUP IN' and self.transaction_type == 'OUT':
- request['es'] = self.transaction_es
+ request['es'] = self.es_transaction
self.handle_request(0, request_end)
elif request['type'] == 'SETUP OUT' and self.transaction_type == 'IN':
- request['es'] = self.transaction_es
+ request['es'] = self.es_transaction
self.handle_request(0, request_end)
else:
if pname == 'SOF':
return
if self.transaction_state == 'TOKEN RECEIVED':
- transaction_timeout = self.transaction_es
+ transaction_timeout = self.es_transaction
# Token length is 35 bits, timeout is 16..18 bit times
# (USB 2.0 7.1.19.1).
- transaction_timeout += int((self.transaction_es - self.transaction_ss) / 2)
+ transaction_timeout += int((self.es_transaction - self.ss_transaction) / 2)
if ss > transaction_timeout:
- self.transaction_es = transaction_timeout
+ self.es_transaction = transaction_timeout
self.handshake = 'timeout'
self.handle_transfer()
self.transaction_state = 'IDLE'
sync, pid, addr, ep, crc5 = pinfo
self.transaction_data = []
- self.transaction_ss = ss
- self.transaction_es = es
+ self.ss_transaction = ss
+ self.es_transaction = es
self.transaction_state = 'TOKEN RECEIVED'
self.transaction_ep = ep
self.transaction_addr = addr
self.handshake = pname
self.transaction_state = 'IDLE'
- self.transaction_es = es
+ self.es_transaction = es
self.handle_transfer()
elif pname == 'PRE':
self._d1_prev = None
self._state = None
- self._ss_state = None
+ self.ss_state = None
self.ss_bit = None
self.es_bit = None
elif self._state == 'invalid':
ann = [1, [self._state]]
if ann:
- self.put(self._ss_state, self.samplenum, self.out_ann, ann)
- self._ss_state = self.samplenum
+ self.put(self.ss_state, self.samplenum, self.out_ann, ann)
+ self.ss_state = self.samplenum
self._state = state
self._bits = []