Saleae Logic 2 Automation API

@timreyes thanks a bunch my friend and appreciate that you had Labor Day etc to deal with and a backlog. Thank you much for the code snippet and its perfect.

Hope all is well

Hi everyone, I have a short question
I’m using Logic16 as device and I create a driver for saleae where I have a error for it:
If I try to put 1.8 or any other voltage on digital_threshold_volts:

invalid voltage setting. selected 1.8 Volts. options: 1.8V to 3.6V, 3.6V to 5.0V

If I try to send it as string “1.8V to 3.6V” is saying only accept “real value”

Logic 16 is compatible with python API?
image

@viespe.georgesorin When looking at the documentation for digital_threshold_volts, it looks like we may not have added support for our Gen1 Logic devices.
https://saleae.github.io/logic2-automation/automation.html#saleae.automation.LogicDeviceConfiguration

Let me double check this with the software team here and we’ll get back to you on that.

@viespe.georgesorin I checked in with the software team here, and this unfortunately looks like a bug. We’ve got this logged internally on our backlog now.

Thank you for your reply, any idea when will be the next update/fix?

@viespe.georgesorin This particular bug is on our backlog now, but we haven’t assigned a release date for it yet.

Does the API support a method for checking the supported samples rates of the current device?

See the automation API for manager get_devices() function, which returns DeviceDesc that includes the device_type enumeration. From that list, you can infer the sample rates as they are documented in the Saleae logic datasheets.

1 Like

@lucasrangit We haven’t published an official list of available sample rate options for every distinct channel configuration. Having said that, an alternative way to check the available sampling rates is, in case an unsupported sampling rate is configured via our Automation API, the resulting error message printed to the console will show the available and valid sampling rate values you can use (example below).

saleae.automation.errors.InvalidRequestError: Invalid supplied sample rate. Allowed sample rates with channel configuration: {"digital":500000000}, {"digital":250000000}, {"digital":125000000}, {"digital":100000000}, {"digital":50000000}, {"digital":25000000}, {"digital":20000000}, {"digital":12500000}, {"digital":10000000}, {"digital":6250000}, {"digital":5000000}, {"digital":4000000}, {"digital":2500000}, {"digital":2000000}, {"digital":1000000}

Please also keep in mind that our Automation API is not able to configure sampling rates below 625 kS/s (you will notice those lower sampling rates missing from the list in the image above).

We’re tracking the request to get those added in the feature request post below.

I hope that helps!

1 Like

Thanks @BitBob and @timreyes , the InvalidRequestError message is an easier way to see the list of supported sample rates for the given channel configuration and device.

I’m not sure where else to post this to get help. I’m using the new API and trying to use the basic example provided at https://saleae.github.io/logic2-automation/getting_started.html.
I had to modify it a bit to get it to run as certain things like:

with automation.Manager.connect(port=10430) as manager

changed to:

with automation.Manager(port=10430) as manager

I think the example is outdated? I’m currently getting stuck at manager.start_capture().

I’m getting the following error: saleae.automation.InvalidRequestError: At least 1 digital or analog channel must be enabled.

But as far as I can see I’ve configured everything right.?

Can someone advise what I’m configuring incorrectly? I’m using a Logic Pro 16.
Below is the code I’m using.

from saleae import automation
import os
from datetime import datetime

with automation.Manager(port=10430) as manager:
    # List connected devices
    devices = manager.get_devices()
    if not devices:
        raise Exception("No devices connected.")
    for device in devices:
        print(f"Device ID: {device.serial_number}, Type: {device.device_type}")

    # Use the first connected device
    device_id = devices[0].serial_number

    # Configure the capturing device
    device_configuration = automation.LogicDeviceConfiguration(
        enabled_digital_channels=[0, 1],
        digital_sample_rate=500000000,
        #digital_threshold_volts=3.3,
    )

    # Set capture configuration for a 5-second duration
    capture_configuration = automation.CaptureConfiguration(
        capture_mode=automation.DigitalTriggerCaptureMode(trigger_channel_index=0,trigger_type=automation.DigitalTriggerType.RISING),
    )

    # Start the capture
    with manager.start_capture(
            device_serial_number=device_id,
            device_configuration=device_configuration,
            capture_configuration=capture_configuration) as capture:

        # Wait for the capture to complete
        capture.wait()


        # Create a directory to store the output
        output_dir = os.path.join(os.getcwd(), f'output-{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}')
        os.makedirs(output_dir, exist_ok=True)

        # Export raw digital data to a CSV file
        capture.export_raw_data_csv(directory=output_dir, digital_channels=[0, 1])

        # Save the capture to a file
        capture_filepath = os.path.join(output_dir, 'example_capture.sal')
        capture.save_capture(filepath=capture_filepath)