First off, you can place print(“”) statements in your HLA, and they will appear in the terminal view in the app. The terminal view is accessed on the analyzer sidebar, by clicking the little terminal icon:
That should help a lot for debugging.
Second, you can’t stop the capture from an HLA, unfortunately. However, you can create a unique frame that you can search for in the sidebar.
For your first question, first take a look at the I2C frame format here: https://support.saleae.com/extensions/analyzer-frame-types/i2c-analyzer
The main thing your code is missing is that it’s not checking the frame type first.
I modified your example a bit to show how frame type is used:
def __init__(self):
pass
def decode(self, frame: AnalyzerFrame):
i = 0
# The 'data' field only contains one byte [8 bits]
ch = None
type = None
ack = None
if frame.type == 'address':
address = frame.data['address'][0]
ch = address.decode('ascii')
print('HLA parsed an address frame: ' + ch)
type = 'address'
elif frame.type == 'data':
data = frame.data['data']
ch = data.decode('ascii')
print('HLA parsed an data frame: ' + ch)
type = 'data'
else:
print("unrecognized frame type, ignoring")
return
try:
ack = frame.data['ack']
except:
# no ACK bit. this only happens if there was an error decoding the frame, e.g. bad I2C data.
print('ack bit missing, skipping this frame.')
return
if ch in chr(0x0B) and not ack:
return AnalyzerFrame(type, frame.start_time, frame.end_time, {
'input_type': frame.type
})