Skip to content

Commit dac216f

Browse files
committed
Update README.md
1 parent 7a1dfc4 commit dac216f

1 file changed

Lines changed: 170 additions & 135 deletions

File tree

README.md

Lines changed: 170 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,224 +1,259 @@
11
# CAN Tool
22

3-
CAN Tool is a combined backend (FastAPI) + frontend (Vite/React) project for working with CAN bus devices (SocketCAN and Intrepid).
4-
It also includes helpers for managing a CAN interface (`can0`) and running quick hardware tests.
3+
CAN Tool is a combined **backend (FastAPI)** + **frontend (Vite/React)** app for working with CAN bus devices (SocketCAN, Intrepid, etc.).
4+
It includes helpers for bringing up a CAN interface (e.g., `can0`) and for quick hardware tests.
55

66
---
7-
## Packaged Executable
87

9-
For non-technical users, you can download the prebuilt **CAN Tool** binary:
8+
## 🚀 Quick Download (Non-Technical Users)
9+
10+
You don’t need to install anything. Download the prebuilt app for **your OS** from GitHub Releases.
11+
12+
### Step-by-step (all platforms)
13+
14+
1) Open the project’s **Releases** page (top bar → **Releases**) and click the **latest version** (looks like `vX.Y.Z`).
15+
2) Under **Assets**, download the file for **your OS**:
16+
- **Windows** → typically a ZIP named like `can-tool-windows-<tag>.zip`.
17+
- **macOS (Apple Silicon)** → a ZIP like `can-tool-macos-<tag>.zip`.
18+
_Note: built for Apple Silicon (arm64)._
19+
- **Linux (x86_64)** → a TAR/ZIP like `can-tool-ubuntu-<tag>.tar.gz` (from Ubuntu 24.04, glibc 2.39).
20+
3) **Extract** the archive (right-click → Extract / “Open archive”).
21+
4) Inside the extracted folder, run the app:
22+
- **Windows**: double-click `can-tool.exe`.
23+
- **macOS**: in Finder, **Right-click → Open** on `can-tool` the first time (bypasses Gatekeeper), then click **Open**.
24+
- **Linux**: open Terminal in that folder:
25+
```bash
26+
chmod +x ./can-tool
27+
./can-tool
28+
```
29+
5) Your browser will open to **http://127.0.0.1:8000** (the tool’s UI).
30+
6) Connect to your CAN interface and use the tool.
31+
32+
### Notes for each OS
33+
34+
- **Windows**
35+
- If SmartScreen warns about an unknown publisher: click **More info → Run anyway**.
36+
- If a firewall prompt appears: allow access on **Private networks** (localhost only).
37+
- Install your adapter’s drivers (Kvaser, Intrepid, etc.).
38+
39+
- **macOS (Apple Silicon)**
40+
- First launch: **Right-click → Open** (Gatekeeper) as mentioned above.
41+
- If you blocked it accidentally: System Settings → **Privacy & Security** → allow the app.
42+
43+
- **Linux**
44+
- Built on **Ubuntu 24.04**. On older distros you may need newer glibc.
45+
- To use SocketCAN you may need `can-utils` and interface permissions:
46+
```bash
47+
sudo apt update
48+
sudo apt install -y can-utils
49+
# Example bring-up at 250 kbit/s
50+
sudo ip link set can0 type can bitrate 250000
51+
sudo ip link set can0 up
52+
```
53+
- Or use the helper commands in **run.sh** (see below).
1054

11-
- Windows: `can-tool.exe`
12-
- Linux: `CAN_Tool-x86_64.AppImage`
55+
---
1356

14-
### Usage
15-
1. Double-click the executable
16-
2. Your browser will open automatically to [http://127.0.0.1:8000](http://127.0.0.1:8000)
17-
3. Connect to your CAN interface and use the tool
57+
## 🏗️ How Releases Are Built (CI)
1858

19-
### Notes
20-
- Make sure your CAN interface drivers are installed
21-
- Linux users may need `can-utils` and socket permissions (see below)
59+
- Builds are created **only when you push a Git tag** (example: `v0.3.0`).
60+
- The GitHub Action compiles the app for **Windows**, **macOS (arm64)**, and **Linux (x86_64)** and attaches the artifacts to that Release.
2261

23-
---
62+
### Cut a new Release (maintainers)
2463

25-
## Backend Quick Start
64+
```bash
65+
# 1) Commit all changes on your branch
66+
git add -A
67+
git commit -m "Your message"
2668
27-
The backend provides the REST API and WebSocket stream.
69+
# 2) Tag with a semver-style tag (this is what triggers the build)
70+
git tag v0.3.0
2871
29-
### Install dependencies
72+
# 3) Push the tag to GitHub (this starts the CI build + release)
73+
git push origin v0.3.0
74+
````
3075
31-
```bash
32-
cd backend
33-
pip install -r requirements.txt
34-
```
76+
Then go to **GitHub → Actions** or **Releases** and download the artifacts.
3577
36-
Make sure you have `uvicorn` installed (comes from `requirements.txt`). If needed:
78+
---
3779
38-
```bash
39-
pip install uvicorn[standard] fastapi
40-
```
80+
## 🧪 Local Development (from source)
81+
82+
### Backend (FastAPI)
4183
42-
### Run backend
84+
**Requirements:** Python 3.12
4385
4486
```bash
87+
# From repo root
4588
cd backend
89+
python -m venv .venv
90+
source .venv/bin/activate # Windows: .venv\Scripts\activate
91+
pip install -U pip
92+
pip install -r requirements.txt
4693
uvicorn app:app --reload --host 0.0.0.0 --port 8000
4794
```
4895

49-
### Verify
96+
Verify:
5097

51-
* Open [http://localhost:8000/docs](http://localhost:8000/docs) for Swagger API UI
52-
* Health check: `curl http://localhost:8000/api/health`
98+
* Swagger UI → [http://localhost:8000/docs](http://localhost:8000/docs)
99+
* Health `curl http://localhost:8000/api/health`
53100

54-
Logs: backend writes to `backend/backend.log` when run via `run.sh`.
55-
56-
---
101+
### Frontend (Vite + React)
57102

58-
## Frontend Quick Start
59-
60-
The frontend is a Vite + React app for interacting with the backend.
61-
62-
### Install dependencies
103+
**Requirements:** Node.js 20
63104

64105
```bash
65106
cd frontend
66-
npm install
67-
```
68-
69-
### Run frontend (dev mode with hot reload)
70-
71-
```bash
107+
npm ci
72108
npm run dev
73109
```
74110

75-
### Verify
76-
77-
* Open [http://localhost:5173](http://localhost:5173) in your browser
78-
79-
Logs: frontend writes to `frontend/frontend.log` when run via `run.sh`.
111+
Open [http://localhost:5173](http://localhost:5173)
80112

81113
---
82114

83-
## Running Backend + Frontend Together
84-
85-
We use a top-level `run.sh` orchestrator script that manages both backend (FastAPI on port **8000**) and frontend (Vite dev server on port **5173**) with simple commands.
115+
## ▶️ Running Backend + Frontend Together (dev helper)
86116

87-
### Start both (background)
117+
`run.sh` manages both backend (port **8000**) and frontend (Vite on **5173**):
88118

89119
```bash
90-
./run.sh start
120+
./run.sh start # start both in background
121+
./run.sh stop # stop both
122+
./run.sh restart
123+
./run.sh status # shows backend/frontend PIDs + CAN status
124+
./run.sh up # backend in background, frontend in foreground (Ctrl+C stops both)
91125
```
92126

93-
### Stop both
127+
**Logs (background runs):**
94128

95-
```bash
96-
./run.sh stop
97-
```
129+
* `backend/backend.log`
130+
* `frontend/frontend.log`
131+
132+
**PID files:** `backend.pid`, `frontend.pid`, `candump.pid`
98133

99-
### Restart both
134+
---
135+
136+
## 🚌 CAN Interface Helpers
100137

101138
```bash
102-
./run.sh restart
139+
./run.sh can-up # Load modules and bring up CAN (250000 bps) as can0
140+
./run.sh can-down # Stop candump (if any) and bring can0 down
141+
./run.sh can-test # Bring up (if needed), run candump, send one test frame, show log
103142
```
104143

105-
### Status
144+
**Auto-CAN mode** (start/stop brings CAN up/down automatically):
106145

107146
```bash
108-
./run.sh status
147+
AUTO_CAN=1 ./run.sh start
148+
AUTO_CAN=1 ./run.sh stop
149+
# also works with: AUTO_CAN=1 ./run.sh up
109150
```
110151

111-
This will show whether backend/frontend are running, their PIDs, and the CAN interface status.
112-
113-
### Dev mode (frontend logs in terminal, Ctrl+C stops both)
152+
Quick sanity test:
114153

115154
```bash
116-
./run.sh up
155+
./run.sh can-up
156+
./run.sh can-test
157+
./run.sh can-down
117158
```
118159

119-
This mode starts the backend in the background and runs the frontend (`npm run dev`) in the foreground so you can see build logs and hot-reload messages.
120-
Press `Ctrl+C` once to stop **both frontend and backend** cleanly.
121-
122160
---
123161

124-
## CAN Interface Integration
162+
## 🔌 Ports & URLs
125163

126-
This project includes helpers to manage your CAN adapter alongside backend/frontend services.
164+
* Backend (Uvicorn): **[http://localhost:8000](http://localhost:8000)** (Swagger at `/docs`)
165+
* Frontend (Vite dev): **[http://localhost:5173](http://localhost:5173)**
166+
* Packaged app (all-in-one): opens **[http://127.0.0.1:8000](http://127.0.0.1:8000)** automatically
167+
168+
---
127169

128-
### CAN Commands
170+
## 🧰 Example API Calls
129171

130172
```bash
131-
./run.sh can-up # Load modules and bring up CAN interface at 250000 bps
132-
./run.sh can-down # Stop candump (if any) and bring the CAN interface down
133-
./run.sh can-test # Bring up (if needed), start candump, send one test frame, show log
134-
```
173+
# Health
174+
curl http://localhost:8000/api/health
135175

136-
### Auto-CAN Mode
176+
# List interfaces
177+
curl http://localhost:8000/api/interfaces
137178

138-
If you want the CAN interface to automatically come up when you start the tool (and shut down cleanly when you stop):
179+
# Connect to a CAN interface
180+
curl -X POST http://localhost:8000/api/connect \
181+
-H "Content-Type: application/json" \
182+
-d '{"channel":"can0","bitrate":250000}'
139183

140-
```bash
141-
AUTO_CAN=1 ./run.sh start
142-
AUTO_CAN=1 ./run.sh stop
184+
# WebSocket stream (example using websocat)
185+
# websocat ws://localhost:8000/api/stream
143186
```
144187

145-
This also works for `./run.sh up`.
188+
---
146189

147-
### Status
190+
## 🧯 Troubleshooting
148191

149-
The `status` command now shows CAN info:
192+
**Non-technical users**
150193

151-
```bash
152-
./run.sh status
153-
```
194+
* Browser didn’t open? Manually visit [http://127.0.0.1:8000](http://127.0.0.1:8000) after starting the app.
195+
* “Port already in use”? Close other apps using port **8000** and try again.
154196

155-
Example output:
197+
**Windows**
156198

157-
```
158-
--- Backend ---
159-
Backend is running (PID=1234)
160-
--- Frontend ---
161-
Frontend is running (PID=5678).
162-
--- CAN Status ---
163-
can0 UP <NOARP,UP,LOWER_UP,ECHO>
164-
candump: not running
165-
```
199+
* SmartScreen blocked it → click **More info → Run anyway**.
200+
* “MSVCP…”/runtime errors → run Windows Update and install vendor CAN drivers.
166201

167-
---
202+
**macOS**
168203

169-
## Quick Test Workflow
204+
* “App is from an unidentified developer” → **Right-click → Open** (first launch).
205+
* If blocked: System Settings → **Privacy & Security** → allow the app.
170206

171-
For verifying that your CAN hardware is functional:
207+
**Linux**
172208

173-
```bash
174-
./run.sh can-up # bring up CAN at 250k
175-
./run.sh can-test # send test frame + log
176-
./run.sh can-down # clean shutdown
177-
```
209+
* “Permission denied” → `chmod +x ./can-tool`.
210+
* “Address already in use” → another app uses port **8000**. Kill it or change port.
211+
* SocketCAN: ensure `can0` is **UP** (`ip -details link show can0`) or use `./run.sh can-up`.
178212

179-
---
213+
**Developers (building the frontend)**
180214

181-
## Notes
215+
* If you ever see `Cannot find module @rollup/rollup-<platform>` during `vite build`, it’s npm’s optional-deps quirk. Fix locally with:
182216

183-
* Backend runs with **Uvicorn**[http://localhost:8000](http://localhost:8000) (Swagger UI at `/docs`)
184-
* Frontend runs with **Vite**[http://localhost:5173](http://localhost:5173)
185-
* Logs for background runs:
186-
187-
* `backend/backend.log`
188-
* `frontend/frontend.log`
189-
* PID files (managed by `run.sh`):
190-
191-
* `backend.pid`
192-
* `frontend.pid`
193-
* `candump.pid`
217+
```bash
218+
# from frontend/
219+
npm ci
220+
# then one of:
221+
npm i -D @rollup/rollup-linux-x64-gnu@^4
222+
npm i -D @rollup/rollup-darwin-arm64@^4
223+
npm i -D @rollup/rollup-win32-x64-msvc@^4
224+
```
194225

195226
---
196227

197-
## Example API Commands
228+
## 📦 Packaging Locally (optional, for maintainers)
198229

199-
### Check backend health
230+
The CI uses **PyInstaller** with `can-tool.spec`. To build manually:
200231

201232
```bash
202-
curl http://localhost:8000/api/health
203-
```
233+
# Build frontend for production
234+
cd frontend
235+
npm ci
236+
npm run build
237+
cd ..
204238

205-
### List interfaces
239+
# Stage frontend assets into backend/static
240+
mkdir -p backend/static
241+
cp -r frontend/dist/* backend/static/
206242

207-
```bash
208-
curl http://localhost:8000/api/interfaces
243+
# Build the one-file executable
244+
pip install -U pip pyinstaller -r backend/requirements.txt
245+
pyinstaller can-tool.spec
246+
247+
# Result appears under: dist/
209248
```
210249

211-
### Connect to an interface
250+
---
212251

213-
```bash
214-
curl -X POST http://localhost:8000/api/connect \
215-
-H "Content-Type: application/json" \
216-
-d '{"channel":"can0","bitrate":250000}'
217-
```
252+
## ✅ Support Matrix
218253

219-
### Start WebSocket stream
254+
* **Windows**: 64-bit, Windows 10/11, vendor CAN drivers required.
255+
* **macOS**: Apple Silicon (arm64). Use Right-click → Open on first run.
256+
* **Linux**: x86_64 (built on Ubuntu 24.04 / glibc 2.39). SocketCAN users may need `can-utils`.
257+
258+
---
220259

221-
```bash
222-
# Example with websocat
223-
websocat ws://localhost:8000/api/stream
224-
```

0 commit comments

Comments
 (0)