Metadata-Version: 2.5
Name: pycan-send
Version: 0.1.0
Summary: Command line tool that quickly lets you send a can frame using the message and signal names of a KCD or can-db-model YAML database
Project-URL: Documentation, https://sr.ht/~laplace/pycan-send#readme
Project-URL: Issues, https://sr.ht/~laplace/pycan-send/issues
Project-URL: Source, https://sr.ht/~laplace/pycan-send
Author-email: Alexander Becker <nabla.becker@mailbox.org>
License-Expression: GPL-3.0-or-later
License-File: LICENSE.txt
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.10
Requires-Dist: can-db-model>=0.1.1
Requires-Dist: cantools
Requires-Dist: click
Requires-Dist: python-can
Requires-Dist: rich
Description-Content-Type: text/markdown

# pycan-send

[![PyPI - Version](https://img.shields.io/pypi/v/pycan-send.svg)](https://pypi.org/project/pycan-send)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pycan-send.svg)](https://pypi.org/project/pycan-send)

-----

## Table of Contents

- [Installation](#installation)
- [License](#license)

## Installation

```console
pip install pycan-send
```

## Usage

```console
pycan-send path/to/file.kcd can0 -m MessageName -s SignalName Value
pycan-send path/to/file.yaml can0 -m MessageName -s SignalName Value
```

The database is loaded through [can-db-model](https://sr.ht/~laplace/can-db-model),
so it can be a KCD file (`.kcd`) or a can-db-model YAML file (`.yaml`/`.yml`).
`Value` can be numeric or, for signals that define labels in the database,
the label name itself (e.g. `-s Mode Active`).

## Verifying received signals

`pycan-verify` decodes incoming traffic and asserts that a single signal
on the first matching frame satisfies a constraint. It returns 0 on a
successful check and a distinct non-zero exit code for each failure
mode:

| Code | Meaning           |
|------|-------------------|
| 0    | pass              |
| 3    | timeout           |
| 4    | value below bound |
| 5    | value above bound |
| 1    | bus / decode error|
| 2    | CLI usage error   |

```console
pycan-verify path/to/file.kcd can0 -m Status -s Voltage --range 380 420
pycan-verify path/to/file.kcd can0 -m Status -s Mode --equal Active
pycan-verify path/to/file.kcd can0 -m Status -s Voltage --above 0 --timeout 0.5
```

`--above` and `--below` are inclusive. Exactly one of `--equal`,
`--range`, `--above`, `--below` must be given. `--prefix` works the
same as for `pycan-send` and is OR-ed with the message ID before
matching.

## Fish tab completion

One-shot (current shell only):

```fish
_PYCAN_SEND_COMPLETE=fish_source pycan-send | source
```

Persistent:

```fish
_PYCAN_SEND_COMPLETE=fish_source pycan-send > ~/.config/fish/completions/pycan-send.fish
```

Once enabled, tab completion works for database files (`.kcd`, `.yaml`,
`.yml`), message names (`-m <TAB>` after the database path), signal names,
and labels — all pulled live from the database given on the command line.

## License

`pycan-send` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
