A simple, bundled backend (FastAPI) + frontend (Vite/React) app for working with CAN bus on:
- Linux Mint via SocketCAN (real adapters or virtual
vcan). - Windows 10/11 via Kvaser CANlib (python-can “kvaser” backend).
The app bundles everything into a single executable per OS. When you start it, your browser opens to http://127.0.0.1:8000.
-
Go to the GitHub Releases page of this repo.
-
Download the file for your OS:
- Windows:
can-tool-windows-vX.Y.Z.exe - Linux Mint:
can-tool-linux-vX.Y.Z
- Windows:
-
Follow the platform guide below.
Tip: Each tag
vX.Y.Zautomatically builds and attaches the latest executables.
Prerequisites
- Install Kvaser CANlib drivers (from Kvaser). Plug in your Kvaser adapter.
Run the tool
- Double-click
can-tool-windows-vX.Y.Z.exe. - Your browser should open to http://127.0.0.1:8000.
- Interface: pick
kvaser0(orkvaser1if you have more than one). - Click Connect. (There’s no “Bring up” on Windows; bitrate is set through CANlib.)
- Use Presets (right panel) or the Message Builder to transmit frames.
Troubleshooting
- No Kvaser interfaces: install Kvaser CANlib and replug the adapter.
- Windows Defender SmartScreen: click More info → Run anyway (you built this 🙂
Prerequisites (one-time)
Open Terminal and run:
sudo apt update
sudo apt install -y can-utils libcap2-binRun the tool
# In the folder where you downloaded it
chmod +x can-tool-linux-vX.Y.Z
./can-tool-linux-vX.Y.ZThe app opens http://127.0.0.1:8000.
Choose an interface
- Virtual testing: select
vcan0. - Real hardware: select your device (often
can0for USB adapters).
Bring the link up (Linux only)
-
Click Bring up (sets bitrate for
can*or creates/upsvcan*).- For
can*: the backend doesdown → type can bitrate 250000 → up. - For
vcan*: it createsvcan0if missing and brings it up (no bitrate). - It will use privileges automatically; if needed you’ll see a password prompt.
- For
-
Click Connect.
Optional (avoid password prompts) Grant the binary CAN capabilities once:
sudo setcap 'cap_net_raw,cap_net_admin+eip' ./can-tool-linux-vX.Y.Z
getcap ./can-tool-linux-vX.Y.Z
# expect: ./can-tool-linux-vX.Y.Z cap_net_admin,cap_net_raw=eipTroubleshooting
-
Port 8000 already in use
sudo lsof -i TCP:8000 -sTCP:LISTEN -n -P kill -9 <PID_SHOWN>
-
“RTNETLINK answers: Device or resource busy” You tried to set bitrate while the link was up or it’s
vcan. Click Bring up again (the tool now forces down → set type/bitrate → up forcan*and skips bitrate onvcan*). -
“Could not access SocketCAN device can0 (No such device)” Your adapter isn’t exposed as
can0. Check:ip -br link | grep -E '^(v?can)' dmesg | grep -i can
-
Diagnostics bundle (optional):
scripts/linux/can_diag.shcollects logs into a tar.gz you can share.
-
Backend:
backend/app.py(FastAPI).-
Serves the UI and provides
/api/*. -
Linux-only bring-up endpoint
/api/can/bringup:vcan*: create if missing, thenip link set <iface> up.can*:ip link set <iface> down→type can bitrate <bps>→up. Uses directipif the binary hascap_net_admin; otherwise falls back topkexecfor a GUI elevation prompt.
-
Streams frames over
/api/stream. -
Stores user presets and groups in your user profile (see
/api/config-paths).
-
-
CAN backends
- Linux: SocketCAN via
python-can(loopback enabled so self-test echoes onvcan). - Windows: Kvaser via
python-can’skvaserinterface (requires CANlib). - (Optional) Intrepid
icsneopysupport exists but we’re focusing on Windows+Mint now.
- Linux: SocketCAN via
-
Frontend: Vite/React in
frontend/(compiled assets are served by the backend).
cd backend
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
uvicorn app:app --reload --host 0.0.0.0 --port 8000
# API docs: http://localhost:8000/docscd frontend
npm ci
npm run dev
# App: http://localhost:5173 (talks to backend on :8000)CI handles this for releases (see below). For manual builds:
# 1) Frontend build → copy into backend/static
cd frontend && npm ci && npm run build
mkdir -p ../backend/static && cp -r dist/* ../backend/static/
# 2) Backend bundle
cd ../backend
pip install -r requirements.txt
pip install pyinstaller
pyinstaller can-tool.spec
# Output in dist/ (Windows: can-tool.exe, Linux: can-tool)-
Workflow:
.github/workflows/build-and-release.yml -
Trigger: When you push a tag matching
v*(e.g.,v0.0.6) or run it manually. -
Matrix: ubuntu-latest and windows-latest (macOS disabled).
-
Outputs: Attaches:
can-tool-linux-vX.Y.Zcan-tool-windows-vX.Y.Z.exe
Tag & push to release:
# from your main branch
git pull
git tag v0.0.6
git push origin v0.0.6The workflow builds both executables, uploads them as artifacts, and publishes a GitHub Release for that tag.
- Health:
curl http://127.0.0.1:8000/api/health - List interfaces:
curl http://127.0.0.1:8000/api/interfaces - Bring up (Linux):
curl -X POST http://127.0.0.1:8000/api/can/bringup -H 'Content-Type: application/json' -d '{"iface":"can0","bitrate":250000}' - WebSocket stream:
ws://127.0.0.1:8000/api/stream
-
Windows supports Kvaser adapters via CANlib. Other Windows adapters are not configured here.
-
Linux bring-up requires either:
- one-time
setcap(recommended), or - a pkexec password prompt when you press Bring up.
- one-time
If something doesn’t work:
-
Include your OS, adapter type, and the error popup text.
-
On Linux, attach the diagnostics bundle:
scripts/linux/can_diag.sh
-
If port 8000 is stuck, show:
sudo lsof -i TCP:8000 -sTCP:LISTEN -n -P
Thanks!