How-to diagnose CAN-based Cyphal networks via Yakut

Pika Spark is an Arduino Portenta X8 based micro robot control system combining an unprecedented amount of computing power and interfaces within an extremely small form factor. The Pika Spark has two (2) galvanically isolated CAN interfaces which can be used for communication with external devices. Galvanic isolation prevents ground-loops and increases overall system resilience and is an important feature in industrial-grade control systems.

This tutorial explains how-to to run Yakut CLI tool on the Pika Spark using one of its CAN interfaces for communicating with a Cyphal-enabled device such as the CyphalPicoBase/CAN.


Pika Spark running Yakut in a CAN-based Cyphal network w/ Zubax Babel and CyphalPicoBase/CAN


Cyphal is an open technology for real-time intravehicular distributed computing and communication based on modern networking standards (Ethernet, CAN FD, etc.). It was created to address the challenge of on-board deterministic computing and data distribution in next-generation intelligent vehicles: manned and unmanned aircraft, spacecraft, robots, and cars. If you want to learn more about Cyphal, you can watch a recording of Alexander Entinger's presentation called 'Introduction to Cyphal - A modern protocol for intravehicular distributed computing and communication', given at the Embedded Systems Engineering Kongress in Sindelfingen, 2024 (Slides, Video).

Yakút is a simple cross-platform command-line interface (CLI) tool for diagnostics and debugging of Cyphal networks which supports all Cyphal transports (UDP, serial, CAN, ...) and is compatible with all major features of the protocol.

The preferred way of getting anything done on the Arduino Portenta X8 is by using Docker. So let's start by creating a Dockerfile that installs Yakut and clones the repository  containing Cyphal's regulated DSDL definitions.


FROM debian:stable-slim
RUN apt update && apt install python3-full python3-venv python3-pip git -y

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH='$VIRTUAL_ENV/bin:$PATH'
RUN pip install yakut

RUN cd /opt && git clone https://github.com/OpenCyphal/public_regulated_data_types
ENV CYPHAL_PATH='/opt/public_regulated_data_types'

In the next step a Docker image is built from the Dockerfile using docker build.


docker build --pull --no-cache --tag pika_spark_yakut_can .

Now it's time to enable Pika Spark's CAN interface (we use can0) and configure it for a bitrate of 250 kBit/s which is the CyphalPicoBase/CAN's default bitrate. Note: the following commands need to be run with super-user privileges (i.e. precede those commands with sudo).


echo 160 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio160/direction
echo 0 > /sys/class/gpio/gpio160/value

ip link set can0 type can bitrate 250000
ip link set can0 up

As a final step run (docker run) the newly created pika_spark_yakut_can container passing the CAN interface via --network host and execute the yakut monitor command.


sudo docker run -it -u 0 --network host \
  pika_spark_yakut_can \
  yakut --transport 'CAN(can.media.socketcan.SocketCANMedia('can0',8),42)' monitor

Yakut is a powerful tool that can be used in many different ways for configuring, diagnosing, debugging and communicating with Cyphal-enabled networks. For more advanced use cases please look at Yakut's documentation.


TL;DR:

In order to simplify running Yakut connected to a Cyphal-based CAN network via one of Pika Spark's CAN interfaces ready-made bash scripts with integrated error handling and convenience features have been prepared.

git clone https://github.com/pika-spark/pika-spark-containers
cd pika-spark-containers/yakut-can
./docker-build.sh
sudo ./docker-run.sh can0 250000

All the best using Cyphal on your Pika Spark!

PS: Commercial support for Cyphal is available.