Metadata-Version: 2.4
Name: saleae-mso-api
Version: 0.5.7
Summary: Saleae Logic MSO Python Automation API
Classifier: Private :: Do Not Upload
Requires-Python: >=3.11
Requires-Dist: matplotlib>=3.10.1
Requires-Dist: numpy>=2.2.3
Requires-Dist: psutil>=7.0.0
Requires-Dist: pyusb>=1.3.1
Requires-Dist: wmi>=1.5.1; sys_platform == 'win32'
Provides-Extra: build
Requires-Dist: hatchling; extra == 'build'
Provides-Extra: dev
Requires-Dist: boto3-stubs>=1.37.14; extra == 'dev'
Requires-Dist: boto3>=1.37.14; extra == 'dev'
Requires-Dist: brainstem>=2.11.2; extra == 'dev'
Requires-Dist: dotenv>=0.9.9; extra == 'dev'
Requires-Dist: jupyter-book>=0.15.1; extra == 'dev'
Requires-Dist: matplotlib>=3.10.1; extra == 'dev'
Requires-Dist: nbconvert>=7.0.0; extra == 'dev'
Requires-Dist: nbformat>=5.9.0; extra == 'dev'
Requires-Dist: playwright>=1.40.0; extra == 'dev'
Requires-Dist: pyserial>=3.5; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Requires-Dist: pyvisa-py>=0.8.0; (sys_platform == 'linux' or sys_platform == 'darwin') and extra == 'dev'
Requires-Dist: pyvisa>=1.14.1; extra == 'dev'
Requires-Dist: ruff>=0.10.0; extra == 'dev'
Description-Content-Type: text/markdown

# Saleae MSO API

This repository contains the Saleae Mixed Signal Oscilloscope (MSO) API, which provides programmatic control
over capturing analog signals in various configurations.

## Features

- Configure and run captures on a Saleae Logic MSO
- Load and analyze capture data
- Extract specific segments based on trigger conditions after the fact

## Installation

Your system will need to have drivers installed, which happens automatically
any time Logic is installed.

We recommend using the `uv` package manager over `pip`, `pipx`, or even `poetry`.
Get `uv` by visiting the [uv installation instructions](https://docs.astral.sh/uv/getting-started/installation/).

```bash
# set up a virual environment
uv venv
# Install the package from the Saleae private python package index
uv add saleae-mso-api --index https://downloads.saleae.com/pypi/
```

## Quick Example

```python
from pathlib import Path
import numpy as np
from saleae import mso_api

mso = mso_api.MSO()

capture_config = mso_api.CaptureConfig(
    enabled_channels=[mso_api.AnalogChannel(channel=0, name="clock")],
    analog_settings=mso_api.AnalogSettings(sample_rate=100e6),
    capture_settings=mso_api.TimedCapture(capture_length_seconds=0.1),
)

for n in range(3):
    save_dir = Path('my-captures') / f'{n:02d}'
    capture = mso.capture(capture_config, save_dir=save_dir)
    avg_voltage = np.mean(capture.analog_data["clock"])
    print(f"Capture {n:02d} in {save_dir} avg voltage: {avg_voltage:.3f} V")
```

## Development

See the [Contributing](docs/contributing.md) guide for full information on how to contribute to this project.

### Development Quick Setup

The following should get you set up quickly on Windows:

If you are missing the NI VISA drivers, install those
[from National Instruments here](https://www.ni.com/en/support/downloads/drivers/download.ni-visa.html).

```
git clone git@github.com:saleae/mso-api.git
cd mso-api
uv venv
.venv\Scripts\activate
uv sync --all-extras
pytest tests
```

### Updating underlying binaries

If you've cloned the repository and created the virtualenv, you can use `tools/update_binaries.py` to to update the underlying binaries.

You'll want to clone `monorepo` locally as well to help the tool find the git hashes
where graphio was updated. You'll also need to set the following environment variables
by writing them to a file called `.env` in your repository root. Here's example contents you'll need
filled out to perform the update:

    # key will need read credentials to the bucket
    AWS_ACCESS_KEY_ID=...
    AWS_SECRET_ACCESS_KEY=...
    TOOLS_BUCKET_NAME="logic2-dev-s3.saleae.com"
    TOOLS_ARTIFACT_PATH_TEMPLATE="graph-io/builds-development/$commit/$platform/graphio-tools.zip"
    MONOREPO_ROOT=C:\...

Once that file is filled out you can do the following to update the binaries to the tip of `develop`:

    cd monorepo
    git checkout develop
    git pull && git show

    # copy commit hash

    cd mso-api
    uv run tools/update_binaries.py --hash <paste commit hash>
    git commit -a -m "updated binaries to <paste commit hash>"
    git push

## License, Copyright

This project is proprietary and not licensed for public use.
Copyright 2025, Saleae Inc.
