I’m starting to investigate the Automation API, specifically on details about adding an analyzer to the capture.
I found the Automation API documentation:
https://saleae.github.io/logic2-automation/automation.html#capture
… which for add_analyzer() says:
- settings (
Optional
[Dict
[str
,Union
[str
,int
,float
,bool
]]]) – All settings for the analyzer. The keys and values here must exactly match the Analyzer settings as shown in the UI, defaults to None
However, I didn’t find where the specific keys and values are actually documented?
For HLAs, I believe this information can be retrieved from the Python source code, but for LLAs it is not as straight forward to easily extract this information. A tentative work around that I think might work is to add the low level analyzer to a capture, then create and export the ‘preset’ settings file (*.logic2Preset).
Inspecting this preset (JSON) file shows:
- a (list of) analyzers each comprised of settings, each comprised of:
– title (use for the add_analyzer() settingskey
… ?)
– setting (use use for the add_analyzer() settingsvalue
… ?)
However, I didn’t find it documented how to map these properties to the appropriate type (e.g., [str
, int
, float
, bool
]), so it may take some trial and error to figure it all out. Otherwise, is there a better way to extract this information? Is this information already documented somewhere that I missed?
Note: the saleae_example.py provided has an example for SPI (spi_analyzer):
# Add an analyzer to the capture
# Note: The simulator output is not actual SPI data
spi_analyzer = capture.add_analyzer('SPI', label=f'Test Analyzer', settings={
'MISO': 0,
'Clock': 1,
'Enable': 2,
'Bits per Transfer': '8 Bits per Transfer (Standard)'
})
… but it didn’t cover all the SPI settings available in the GUI:
- MOSI
- MISO
- Clock
- Enable
- ‘Significant Bit’
- ‘Bits per Transfer’
- ‘Clock State’
- ‘Clock Phase’
- ‘Enable Line’
Likewise, it isn’t 100% clear what the ‘default’ value might be (or which settings are r, if it is NOT explicitly specified – which I assume will be an LLA specific choice for each setting.
As per the Analyzer SDK API documentation, the possible Analyzer Settings Interfaces Objects are as follows:
AnalyzerSettingInterfaceChannel
- Used exclusively for input channel selection.AnalyzerSettingInterfaceNumberList
- Used to provide a list of numerical options for the user to choose from. Note that this can be used to select from several enum types as well, as illustrated below. (Each dropdown below is implemented with its own interface object)AnalyzerSettingInterfaceInteger
- Allows a user to type an integer into a box.AnalyzerSettingInterfaceText
- Allows a user to enter some text into a textbox.AnalyzerSettingInterfaceBool
- Provides the user with a checkbox.
… but it seemed like AnalyzerSettingInterfaceNumberList
was specified using the string (dropdownText) rather than the integer (value) format?
Anyway, for more complete documentation – it would be nice to have a list of all the officially supported low level analyzers and the exact syntax for key
and value
(s) to use for the settings parameter.
Also, I recognize that the HLAs are considered ‘external extensions’ vs. natively supported, so I think it’s fair to look in the HLA’s source file(s) directly (unless any are natively supported in the future).
For example, I understand the HLA Setting
classes (i.e., StringSetting, NumberSetting, or ChoicesSetting) would define the key
(label …?) and value
to use for the settings parameter in add_high_level_analyzer() API, as per the example from High-Level Analyzer (HLA) Extensions:
class MyHla(HighLevelAnalyzer):
my_string_setting = StringSetting(label='My String')
my_number_setting = NumberSetting(label='My Number', min_value=0, max_value=100)
my_choices_setting = ChoicesSetting(label='My Choice', ['A', 'B'])