This project involves developing a comprehensive user interface for an electrical test board that interfaces with CAN (Controller Area Network) communication. The system serves as a tester board for electrical members to mock and read signals over CAN networks, displaying real-time telemetry data received from CAN networks and providing the ability to mock CAN inputs.
Link to docs https://www.waveshare.com/wiki/RS485_CAN_HAT#Install_Library
CAN Messages: https://docs.google.com/spreadsheets/d/12O2UPdM_fqUVKd0IXZ638wb1obtBXQp11giv7swfWM4/edit?gid=575020774#gid=575020774
can-snooper/
├── api/ # WebSocket server for real-time CAN data
│ ├── __init__.py
│ └── main.py # WebSocket server with real CAN bus
├── can_utils/ # Utility modules for CAN operations
│ ├── __init__.py
│ ├── data_classes.py # Data structures for CAN messages
│ ├── read_can_messages.py # Enhanced CAN message reader with parsing
│ └── send_messages.py # CAN message transmission utilities
├── frontend/ # React web dashboard
│ ├── src/
│ ├── package.json
│ └── ... # React/Vite frontend files
├── sc1-data-format/ # Git submodule for CAN signal definitions
├── mock_messages.py # WebSocket server with simulated CAN data
├── read_can_messages.py # Simple CAN message listener
├── send_messages.py # Simple CAN message sender
├── requirements.txt # Python dependencies
└── README.md
This project uses git submodules. After cloning, initialize them with:
git submodule update --init --recursiveCreate virtual environment using:
- Windows:
virtualenv -p python3 .env - Linux/MacOS:
python3 -m venv .env
Activate the virtual environment you created:
- Windows:
.env\Scripts\activate - Linux/MacOS:
source .env/bin/activate
Install the required Python libraries:
pip install -r requirements.txtListen to CAN messages and print decoded values to console:
python read_can_messages.py- Connects to
can0by default - Displays decoded signal names and values
- Press
Ctrl+Cto stop
Start WebSocket server that broadcasts real CAN data to connected clients:
python api/main.py- Listens on CAN bus
can0 - WebSocket server runs on
ws://localhost:8765 - Broadcasts parsed CAN messages as JSON to all connected clients via Websocket server
Start WebSocket server with simulated CAN data for testing:
python mock_messages.py- Generates fake CAN messages every 2 seconds
- WebSocket server runs on
ws://localhost:8765 - Useful for frontend development without real CAN hardware
Send custom CAN messages interactively:
python send_messages.py <channel>Example:
python send_messages.py can0The script will prompt you for:
- Message ID: Enter hex ID (e.g.,
0x123) - Data bytes: Enter hex bytes separated by spaces (e.g.,
11 22 33 44)
Navigate to the frontend directory and install dependencies:
cd frontend
npm installStart the React development server:
npm run dev- Frontend runs on
http://localhost:5173 - Connects to WebSocket server for real-time CAN data
- Development & Testing: Use
mock_messages.py+ frontend for UI development - Real Vehicle Testing: Use
api/main.py+ frontend for live CAN monitoring - Debugging CAN Issues: Use
read_can_messages.pyfor quick console output - Sending Test Messages: Use
send_messages.pyto inject test CAN messages
- Hardware: CAN interface (e.g., Waveshare RS485 CAN HAT)
- OS: Linux with SocketCAN support (for real CAN bus)
- Python: 3.7+ with
python-canandwebsocketslibraries - Node.js: For frontend development