Skip to content

Instantly share code, notes, and snippets.

@fxadecimal
Last active May 30, 2025 18:37
Show Gist options
  • Save fxadecimal/a00802255fe79291b902de5b8a64f054 to your computer and use it in GitHub Desktop.
Save fxadecimal/a00802255fe79291b902de5b8a64f054 to your computer and use it in GitHub Desktop.
LibCSP python build on debian (raspberrypi os / ubuntu)

Building LibCSP w/python bindings on Debian

Tested on:

  • RaspberryPI OS lite (headless) 2025-05-13
  • Ubuntu 25.04
# Optional: on a fresh debian install
sudo apt update --fix-missing
sudo apt install -y openssh-server
sudo service openssh start
# you can now ssh in, on a fresh pi, run:
passwd

Build

# install build tools
sudo apt update --fix-missing
sudo apt install -y git cmake ninja-build pkg-config build-essential python3 python3-dev

# clone the repo
git clone https://github.com/libcsp/libcsp ~/libcsp
cd ~/libcsp

# install deps
sudo apt install -y libzmq3-dev libsocketcan-dev socat

# configure cmake for python / routing-table
cmake -GNinja -B build -DCSP_ENABLE_PYTHON3_BINDINGS=1 -DCSP_USE_RTABLE=1 && ninja -C build

# build using the included build script:
python3 examples/buildall.py --build-system=cmake

Test

Running the samples here

./build/examples/csp_server_client
# uses a internal loop back address

outputs:

Initialising CSPConnection table
[00 0x73c2fcb8a940] S:0, 0 -> 0, 0 -> 0 (17) fl 0
[01 0x73c2fcb8aa58] S:0, 0 -> 0, 0 -> 0 (18) fl 0
[02 0x73c2fcb8ab70] S:0, 0 -> 0, 0 -> 0 (19) fl 0
[03 0x73c2fcb8ac88] S:0, 0 -> 0, 0 -> 0 (20) fl 0
[04 0x73c2fcb8ada0] S:0, 0 -> 0, 0 -> 0 (21) fl 0
[05 0x73c2fcb8aeb8] S:0, 0 -> 0, 0 -> 0 (22) fl 0
[06 0x73c2fcb8afd0] S:0, 0 -> 0, 0 -> 0 (23) fl 0
[07 0x73c2fcb8b0e8] S:0, 0 -> 0, 0 -> 0 (24) fl 0
Interfaces
LOOP       addr: 0 netmask: 14 dfl: 0
           tx: 00000 rx: 00000 txe: 00000 rxe: 00000
           drop: 00000 autherr: 00000 frame: 00000
           txb: 0 (0B) rxb: 0 (0B)

Server task started
Client task started
Ping address: 0, result 1 [mS]
reboot system request sent to address: 0
Packet received on MY_SERVER_PORT: Hello world A

There are client-only examples

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment