Metadata-Version: 2.4
Name: lr-dmx-tester
Version: 0.1.0
Summary: Send and measure DMX frames & latency together with a compatible hardware tester
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Embedded Systems
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyserial>=3.5
Provides-Extra: dev
Requires-Dist: build>=1.2.2; extra == "dev"
Requires-Dist: mypy>=1.11; extra == "dev"
Requires-Dist: pytest>=8.3; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Requires-Dist: twine>=5.1; extra == "dev"
Dynamic: license-file

# lr-dmx-tester

Python CLI and API for communicating with DMX tester firmware over the RPC serial interface.

## Install

Install from PyPI:

```bash
python -m pip install lr-dmx-tester
```

Or install from this repository:

```bash
python -m venv .venv
source .venv/bin/activate
python -m pip install -e .
```

## CLI usage

The package provides the dmx_tester command:

```bash
dmx_tester --help
```

The first argument is a serial target, either:

- A tty path, for example /dev/ttyACM1
- A board serial number, for example 1050266122

Examples:

```bash
dmx_tester /dev/ttyACM1 send --data-val 0x55 --data-len 24
dmx_tester 1050266122 send-baud 250000 --data-val 0x12 --data-len 24
dmx_tester 1050266122 send-many 100 --data-val 0x7f --data-len 24
dmx_tester 1050266122 receive
dmx_tester 1050266122 latency --data-len 128 --n-reports 3
dmx_tester 1050266122 reset
```

Common options:

- --timeout: Per-line serial timeout in seconds
- --log-level: DEBUG, INFO, WARNING, or ERROR
- --no-reset-before: Skip reset before the selected command
- --no-reset-after: Skip reset after the selected command

The CLI prints JSON output to stdout.

## Python API

Primary classes:

- RpcClient: Low-level RPC transport and request/response handling
- DmxCommands: High-level DMX command wrappers

Example:

```python
from dmx_tester.rpc_client import RpcClient
from dmx_tester.cmd_dmx import DmxCommands

client = RpcClient("/dev/ttyACM1", timeout=10.0)
client.open()

try:
    commands = DmxCommands(client)
    commands.cmd_reset_wait_for_restart(timeout=2.0, retries=3)
    commands.cmd_dmx_send(
        break_time=92.0,
        mark_time=12.0,
        data_val=0x55,
        data_len=24,
    )
finally:
    client.rpc_stop()
```

Latency reports API example:

```python
from dmx_tester.rpc_client import RpcClient
from dmx_tester.cmd_dmx import DmxCommands

client = RpcClient("1050266122", timeout=10.0)
client.open()

try:
    commands = DmxCommands(client)
    reports = commands.cmd_dmx_latency(data_len=128, n_reports=3)
    for report in reports:
        print(report)
finally:
    client.rpc_stop()
```

## Notes

- Data length is validated to DMX limits.
- Data value must be in range 0x00..0xFF.
- Some commands reset the board by design.

## License

This package is licensed under the MIT License. See LICENSE.
