Automation API - High Level Analyzer

Hi
I have built my high-level analyzer which works great with the UI. I have also created an automation script from which I trigger a capture and record data into a file.

Now I want my automation script to call my high level analyzer, but when I run it says it cant load the extension.

This is how im trying to do this:

hla = capture.add_high_level_analyzer(extension_directory='SPI_ADC_HLA',
                                              name='SPI_ADC_HLA', input_analyzer=spi_analyzer)

capture.export_data_table(
            filepath=analyzer_export_filepath,
            analyzers=[spi_analyzer, hla] #analyzers=[spi_analyzer]
        )

My error:

Traceback (most recent call last):
  File "C:\energy_system_modeling\Projects\6_PVI\Saleae_SPI_sniffing_demo\logic_automation\SPI_analyzer.py", line 60, in <module>
    hla = capture.add_high_level_analyzer(extension_directory='C:\energy_system_modeling\Projects\6_PVI\Saleae_SPI_sniffing_demo\logic_automation\SPI_ADC_HLA',
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\saleae\automation\capture.py", line 149, in add_high_level_analyzer
    with _error_handler():
  File "C:\Program Files\Python311\Lib\contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "C:\Users\user\AppData\Roaming\Python\Python311\site-packages\saleae\automation\errors.py", line 121, in _error_handler
    raise grpc_error_to_exception(exc) from None
saleae.automation.errors.InvalidRequestError: Failed to load extension at SPI_ADC_HLA\extension.json

Any ideas? I tried providing a full path too but nothing works.
Also the extension loads perfectly with the UI

Took me a long time and it was the silliest thing. My solution:

hla = capture.add_high_level_analyzer(extension_directory=os.path.join(os.getcwd(), f'SPI_ADC_HLA'),
                                              name='SPI_ADC_HLA', input_analyzer=spi_analyzer, settings=None)

It would be really helpful if Saleae team could provide examples for their automation API. Could have saved some time.

1 Like

@ddominguezmoises Sorry for the trouble with that! We really should make our example scripts easier to find. I’ll work on getting that up somewhere obvious.

For reference, here is an example usage for adding HLAs that could have been helpful: