> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lagerdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Logic Analyzer (Preview)

> Control logic analyzer channels and triggers

Control logic analyzer Nets through the Lager CLI for digital signal capture, protocol decoding, and trigger configuration.

<Warning>
  **Known limitations on the Rigol MSO5000.** Channel control, capture, measurements, cursors, and the edge and SPI triggers work. The pulse, UART and I2C triggers fail when an option configures them. Each failure prints `Error: Function not found: <method>` and exits 1. The CAN trigger and every bus decoder also fail. [Issue #418](https://github.com/lagerdata/lager/issues/418) tracks this work.
</Warning>

## Syntax

```bash theme={null}
lager logic [OPTIONS] NET_NAME COMMAND [ARGS]...
```

## Global Options

| Option      | Description                  |
| ----------- | ---------------------------- |
| `--box BOX` | Lager Box name or IP address |
| `--help`    | Show help message and exit   |

## Commands

| Command        | Description                    |
| -------------- | ------------------------------ |
| `enable`       | Enable logic analyzer channel  |
| `disable`      | Disable logic analyzer channel |
| `start`        | Start waveform capture         |
| `start-single` | Start single waveform capture  |
| `stop`         | Stop waveform capture          |
| `measure`      | Measure signal characteristics |
| `trigger`      | Configure trigger settings     |
| `cursor`       | Control cursor position        |

## Exit Codes

A command that fails prints the error and exits 1. This includes a net name that is not a logic net, and an error from the box. A command that succeeds exits 0.

## Command Reference

### `enable`

Enable logic analyzer channel for the specified net.

```bash theme={null}
lager logic NET_NAME enable [--box BOX] [--mcu MCU]
```

If the logic analyzer of the scope is off, `enable` turns it on. It then shows the channel of the net and makes that channel active. The channel must be `D0` to `D15`.

### `disable`

Disable logic analyzer channel.

```bash theme={null}
lager logic NET_NAME disable [--box BOX] [--mcu MCU]
```

`disable` hides the channel of the net. When no digital channel stays shown, `disable` also turns off the logic analyzer.

### `start`

Start continuous waveform capture.

```bash theme={null}
lager logic NET_NAME start [--box BOX] [--mcu MCU]
```

### `start-single`

Start single waveform capture (one-shot).

```bash theme={null}
lager logic NET_NAME start-single [--box BOX] [--mcu MCU]
```

### `stop`

Stop waveform capture.

```bash theme={null}
lager logic NET_NAME stop [--box BOX] [--mcu MCU]
```

***

## Measure Subcommands

### `measure period`

Measure signal period.

```bash theme={null}
lager logic NET_NAME measure period [--display BOOL] [--cursor BOOL]
```

### `measure freq`

Measure signal frequency.

```bash theme={null}
lager logic NET_NAME measure freq [--display BOOL] [--cursor BOOL]
```

### `measure dc-pos` / `measure dc-neg`

Measure positive or negative duty cycle.

```bash theme={null}
lager logic NET_NAME measure dc-pos [--display BOOL] [--cursor BOOL]
lager logic NET_NAME measure dc-neg [--display BOOL] [--cursor BOOL]
```

### `measure pw-pos` / `measure pw-neg`

Measure positive or negative pulse width.

```bash theme={null}
lager logic NET_NAME measure pw-pos [--display BOOL] [--cursor BOOL]
lager logic NET_NAME measure pw-neg [--display BOOL] [--cursor BOOL]
```

***

## Trigger Subcommands

### `trigger edge`

Set edge trigger configuration.

```bash theme={null}
lager logic NET_NAME trigger edge [OPTIONS]
```

**Options:**

* `--mode` - Trigger mode: `normal`, `auto`, `single` (default: normal)
* `--coupling` - Coupling mode: `dc`, `ac`, `low_freq_rej`, `high_freq_rej` (default: dc)
* `--source NET` - Trigger source net
* `--slope` - Trigger slope: `rising`, `falling`, `both`
* `--level FLOAT` - Trigger level in volts

### `trigger pulse`

Set pulse trigger configuration. On the Rigol MSO5000, this trigger does not work yet. See the limitations at the top of this page.

```bash theme={null}
lager logic NET_NAME trigger pulse [OPTIONS]
```

**Options:**

* `--mode` - Trigger mode
* `--coupling` - Coupling mode
* `--source NET` - Trigger source
* `--level FLOAT` - Trigger level
* `--trigger-on` - Trigger on. The CLI accepts `gt`, `lt` and `gtlt`, but the command then refuses each of these values with `is not a valid option`.
* `--upper FLOAT` - Upper pulse width
* `--lower FLOAT` - Lower pulse width

### `trigger i2c`

Set I2C protocol trigger. On the Rigol MSO5000, the options that configure this trigger do not work yet. See the limitations at the top of this page.

```bash theme={null}
lager logic NET_NAME trigger i2c [OPTIONS]
```

**Options:**

* `--mode` - Trigger mode
* `--coupling` - Coupling mode
* `--source-scl NET` - SCL trigger source
* `--source-sda NET` - SDA trigger source
* `--level-scl FLOAT` - SCL trigger level
* `--level-sda FLOAT` - SDA trigger level
* `--trigger-on` - Trigger on: `start`, `restart`, `stop`, `nack`, `address`, `data`, `addr_data`
* `--address INT` - Address value (for address trigger), as a decimal integer. The maximum is 127 for a 7-bit address, 255 for 8-bit, and 1023 for 10-bit.
* `--addr-width` - Address width: `7`, `8` or `10` bits. The CLI also accepts `9`, but the box refuses it.
* `--data INT` - Data value (for data trigger), as a decimal integer
* `--data-width` - Data width: `1`-`5` bytes
* `--direction` - Direction: `write`, `read`, `rw`

### `trigger uart`

Set UART protocol trigger. On the Rigol MSO5000, the options that configure this trigger do not work yet. See the limitations at the top of this page.

```bash theme={null}
lager logic NET_NAME trigger uart [OPTIONS]
```

**Options:**

* `--mode` - Trigger mode
* `--coupling` - Coupling mode
* `--source NET` - Trigger source
* `--level FLOAT` - Trigger level
* `--trigger-on` - Trigger on: `start`, `error`, `cerror`, `data`
* `--parity` - Parity: `even`, `odd`, `none`
* `--stop-bits` - Stop bits: `1`, `1.5`, `2`
* `--baud INT` - Baud rate (110 to 20000000)
* `--data-width INT` - Data width in bits: `5` to `8`. The CLI also accepts `9`, but the box refuses it.
* `--data INT` - Data value to trigger on, as a decimal integer

### `trigger spi`

Set SPI protocol trigger.

```bash theme={null}
lager logic NET_NAME trigger spi [OPTIONS]
```

**Options:**

* `--mode` - Trigger mode
* `--coupling` - Coupling mode
* `--source-mosi-miso NET` - MOSI/MISO source
* `--source-sck NET` - SCK source
* `--source-cs NET` - CS source
* `--level-mosi-miso FLOAT` - MOSI/MISO level
* `--level-sck FLOAT` - SCK level
* `--level-cs FLOAT` - CS level
* `--data INT` - Trigger data value, as a decimal integer. The maximum is 2^width − 1.
* `--data-width INT` - Data width in bits: `4` to `32`
* `--clk-slope` - Clock slope: `positive`, `negative`
* `--trigger-on` - Trigger on: `timeout`, `cs`
* `--cs-idle` - CS idle state: `high`, `low`. With `--trigger-on cs`, `high` triggers while CS is low, and `low` triggers while CS is high.
* `--timeout FLOAT` - Timeout length. `--trigger-on timeout` changes nothing unless you also give `--timeout`.

***

## Cursor Subcommands

### `cursor set-a` / `cursor set-b`

Set cursor A or B position.

```bash theme={null}
lager logic NET_NAME cursor set-a [--x FLOAT] [--y FLOAT]
lager logic NET_NAME cursor set-b [--x FLOAT] [--y FLOAT]
```

### `cursor move-a` / `cursor move-b`

Shift cursor position.

```bash theme={null}
lager logic NET_NAME cursor move-a [--del-x FLOAT] [--del-y FLOAT]
lager logic NET_NAME cursor move-b [--del-x FLOAT] [--del-y FLOAT]
```

### `cursor hide`

Hide the cursor.

```bash theme={null}
lager logic NET_NAME cursor hide
```

***

## Examples

```bash theme={null}
# Enable logic channel
lager logic SPI_CLK enable --box my-lager-box

# Start capture
lager logic SPI_CLK start

# Measure frequency
lager logic SPI_CLK measure freq

# Set edge trigger on rising edge at 1.5V
lager logic SPI_CLK trigger edge --slope rising --level 1.5

# Set SPI trigger on the 8-bit value 0xFF (255 in decimal)
lager logic SPI_MOSI trigger spi --data 255 --data-width 8
```

***

## Supported Hardware

| Manufacturer | Model Series | Features                      |
| ------------ | ------------ | ----------------------------- |
| Rigol        | MSO5000      | Mixed-signal, protocol decode |

***

## Notes

* Logic nets capture digital signals (high/low states)
* Protocol triggers (I2C, UART, SPI) require proper level configuration
* Use `lager nets` to see available logic nets
* Analog and Logic nets can be combined for mixed-signal analysis
* Integer options such as `--address` and `--data` take decimal values. A hex string such as `0x50` is refused.
