Metadata-Version: 2.4
Name: cyphal-cynic
Version: 0.1.1
Summary: Cyphal Network Investigation Console -- a minimal CLI for inspecting and exercising Cyphal networks.
Author-email: Pavel Kirienko <pavel@opencyphal.org>
License-Expression: MIT
Project-URL: Homepage, https://opencyphal.org
Project-URL: Repository, https://github.com/OpenCyphal/yakut
Keywords: cyphal,opencyphal,pubsub,cli,diagnostics,vehicular,avionics,communication-protocol
Classifier: Intended Audience :: Developers
Classifier: Environment :: Console
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Embedded Systems
Classifier: Topic :: System :: Networking
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pycyphal2[pythoncan,udp]>=2.0.0.dev5
Requires-Dist: pydsdl==1.25.0rc1
Requires-Dist: PyYAML~=6.0
Requires-Dist: coloredlogs~=15.0
Requires-Dist: pyserial~=3.5
Requires-Dist: rich~=14.1
Provides-Extra: test
Requires-Dist: pytest~=9.0; extra == "test"
Dynamic: license-file

<div align="center">

<img src="https://opencyphal.org/favicon-192.png" width="60px">

<h1>Cynic</h1>

_Cyphal Network Investigation Console_

[![PyPI](https://img.shields.io/pypi/v/cyphal-cynic?logo=pypi&color=ffff00)](https://pypi.org/project/cyphal-cynic/)
[![Forum](https://img.shields.io/discourse/https/forum.opencyphal.org/users.svg?logo=discourse&color=1700b3)](https://forum.opencyphal.org)

</div>

---

Cynic is a simple command-line tool for inspecting and exercising
[Cyphal](https://opencyphal.org) networks.

Cynic is built for use with Cyphal v1.1, which introduces named topics.
It is fully interoperable with Cyphal/CAN v1.0 via pinned topics, where the topic name is constructed from its
subject-ID, like `1234#1234`.

<img src="hero.png" width="900px">

## Usage

Install:

```
pip install cyphal-cynic
```

Run `cn --help` for full usage info, or read the code -- it is simple and compact. Some basic examples are shown below.

### List topics visible in the network

```shell
cn ls
cn --can=can0 ls
cn --can=COM8 --bitrate=125000 ls
```

### Publish/subscribe

```shell
printf '\x01\x02' | cn pub topic/foo
cn sub -o raw topic/foo > messages.bin
```

Set defaults per directory in `cynic.toml`, or use environment variables:

```toml
can = "/dev/serial/by-id/usb-Zubax*Babel*if00"  # or SocketCAN iface name
bitrate = 1_000_000
dsdl_root = ["/home/user/public_regulated_data_types/uavcan", "/home/user/zubax_dsdl"]
```

### RPC/streaming

Send a request, print response(s):

```shell
cn req topic/foo/bar --io=zubax/primitive/String1K.1.0.dsdl -- 'Hello world!'
```

## Showcase

### Firmware update via Cyphal/CAN

Put this in `./cynic.toml` so that you don't have to say `--can=slcan0` with every command (optional):

```toml
can = "slcan0"  # Can also be a file wildcard for SLCAN
```

Run the file server in the background (or in a second terminal); the topic name here is arbitrarily chosen as `fwupd`:

```shell
cn fs fwupd &
```

Command the remote node to download the specified firmware file from topic `fwupd`:

```shell
echo 'upd com.zubax.fluxgrip-1-1.0.41c608fbec4f54d9.16c6d0fc4c1e972a.app.release.bin fwupd' | \
    cn pub -i ~/zubax/zubax_dsdl/zubax/primitive/String256.1.0.dsdl command
```
