-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHighLevelAnalyzer.py
More file actions
38 lines (30 loc) · 1.42 KB
/
Copy pathHighLevelAnalyzer.py
File metadata and controls
38 lines (30 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# High Level Analyzer
# For more information and documentation, please go to https://github.com/saleae/logic2-examples
from saleae.analyzers import HighLevelAnalyzer, AnalyzerFrame, StringSetting, NumberSetting, ChoicesSetting
# High level analyzers must subclass the HighLevelAnalyzer class.
class Hla(HighLevelAnalyzer):
# List of settings that a user can set for this High Level Analyzer.
my_string_setting = StringSetting()
my_number_setting = NumberSetting(min=0, max=100)
my_choices_setting = ChoicesSetting(choices=('A', 'B'))
# An optional list of types this analyzer produces, providing a way to customize the way frames are displayed in Logic 2.
result_types = {
'mytype': {
'format': 'Output type: {{type}}, Input type: {{data.input_type}}'
}
}
def __init__(self):
'''
Initialize HLA.
Settings can be accessed using the same name used above.
'''
print("Settings:", self.name, self.count, self.letter)
def decode(self, frame: AnalyzerFrame):
'''
Process a frame from the input analyzer, and optionally return a single `AnalyzerFrame` or a list of `AnalyzerFrame`s.
The type and data values in `frame` will depend on the input analyzer.
'''
# Return the data frame itself
return AnalyzerFrame('mytype', frame.start_time, frame.end_time, {
'input_type': frame.type
})