- README.md with full project documentation, architecture, setup guide - Automotive/industrial dark theme (theme.py) inspired by Vector CANoe - Dark blue-black background with amber/orange accents - Styled buttons (green Start, red Stop), orange hover effects - Custom scrollbars, tooltips, group box titles, tree widget headers - Updated highlight colors to match theme palette Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
187 lines
8.3 KiB
Markdown
187 lines
8.3 KiB
Markdown
# LIN Simulator
|
|
|
|
A cross-platform GUI tool for simulating LIN master nodes using **BabyLIN-RC-II** devices by Lipowsky. Built in two parallel implementations — **Python (PyQt6)** and **C++ (Qt6)** — maintained in feature parity.
|
|
|
|
**Owner:** TeqanyLogix LTD
|
|
**Developer:** Mohamed Salem
|
|
|
|
---
|
|
|
|
## Features
|
|
|
|
- **LDF Loading** — Parse LIN Description Files, auto-reload on file change
|
|
- **Tx Panel** — Expandable tree view of master frames with editable signal values
|
|
- **Rx Panel** — Real-time slave frame display with timestamps and change highlighting
|
|
- **Bit Packing** — Signal value edits automatically update frame bytes (and vice versa)
|
|
- **Hex/Dec Toggle** — Switch all values between hexadecimal and decimal display
|
|
- **Schedule Tables** — Select and run LDF schedule tables with start/stop/pause
|
|
- **Mock Rx Simulation** — Simulated slave responses for testing without hardware
|
|
- **Connection Panel** — Serial port discovery, connect/disconnect with status indicator
|
|
- **BabyLIN Backend** — Wraps Lipowsky's BabyLIN DLL for hardware communication
|
|
- **Baud Rate Detection** — Automatically extracted from LDF's LIN_speed field
|
|
- **FreeFormat Entries** — Support for raw diagnostic/configuration schedule entries
|
|
- **Automotive Dark Theme** — Industrial UI inspired by Vector CANoe and ETAS INCA
|
|
|
|
## Screenshots
|
|
|
|
*(Launch the app and load an LDF to see the automotive dark theme in action)*
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
LIN_Control_Tool/
|
|
├── python/ # Python implementation
|
|
│ ├── src/
|
|
│ │ ├── main.py # Entry point
|
|
│ │ ├── main_window.py # GUI layout and logic
|
|
│ │ ├── ldf_handler.py # LDF parsing adapter (wraps ldfparser)
|
|
│ │ ├── connection_manager.py # Serial port state machine
|
|
│ │ ├── babylin_backend.py # BabyLIN DLL wrapper
|
|
│ │ ├── scheduler.py # QTimer-based schedule execution
|
|
│ │ └── theme.py # Automotive dark theme stylesheet
|
|
│ ├── tests/ # pytest test suite (182 tests)
|
|
│ └── requirements.txt
|
|
├── cpp/ # C++ implementation
|
|
│ ├── src/
|
|
│ │ ├── main.cpp # Entry point
|
|
│ │ ├── main_window.h/.cpp # GUI layout and logic
|
|
│ │ ├── ldf_parser.h/.cpp # Custom LDF parser (regex-based)
|
|
│ │ ├── connection_manager.h/.cpp # QSerialPort state machine
|
|
│ │ └── scheduler.h/.cpp # QTimer-based schedule execution
|
|
│ ├── tests/ # QTest test suite (124 tests)
|
|
│ └── CMakeLists.txt
|
|
├── resources/
|
|
│ ├── sample.ldf # Sample LIN 2.1 LDF for testing
|
|
│ ├── logo.svg # Application logo (SVG source)
|
|
│ └── logo.png # Application logo (512x512 PNG)
|
|
└── docs/ # Step-by-step documentation
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
### Python
|
|
|
|
```bash
|
|
cd python
|
|
pip install -r requirements.txt
|
|
cd src && python main.py
|
|
```
|
|
|
|
### C++
|
|
|
|
```bash
|
|
cd cpp
|
|
mkdir build && cd build
|
|
cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix qt@6) # macOS
|
|
# cmake .. # Linux/Windows
|
|
cmake --build .
|
|
./lin_simulator
|
|
```
|
|
|
|
## Running Tests
|
|
|
|
### Python (pytest)
|
|
|
|
```bash
|
|
cd python
|
|
python -m pytest tests/ -v # all tests
|
|
python -m pytest tests/test_ldf_handler.py -v # single file
|
|
```
|
|
|
|
### C++ (QTest / CTest)
|
|
|
|
```bash
|
|
cd cpp/build
|
|
ctest --output-on-failure -V # all tests
|
|
./test_main_window # single test executable
|
|
```
|
|
|
|
## Dependencies
|
|
|
|
### Python
|
|
| Package | Version | Purpose |
|
|
|---------|---------|---------|
|
|
| PyQt6 | >= 6.5.0 | GUI framework |
|
|
| ldfparser | >= 0.25.0 | LDF file parsing |
|
|
| pyserial | >= 3.5 | Serial port communication |
|
|
| pytest | >= 7.0.0 | Test framework |
|
|
|
|
### C++
|
|
| Library | Purpose |
|
|
|---------|---------|
|
|
| Qt6 Widgets | GUI framework |
|
|
| Qt6 SerialPort | Serial port communication |
|
|
| Qt6 Test | Test framework |
|
|
| CMake >= 3.16 | Build system |
|
|
|
|
## BabyLIN Hardware Support
|
|
|
|
The tool communicates with **BabyLIN-RC-II** devices using Lipowsky's official BabyLIN DLL.
|
|
|
|
| Platform | Status |
|
|
|----------|--------|
|
|
| **Linux** | Full hardware support via `libBabyLIN.so` |
|
|
| **Windows** | Full hardware support via `BabyLIN.dll` |
|
|
| **macOS** | Mock mode (development/testing only — no native DLL) |
|
|
|
|
### Hardware Setup
|
|
|
|
1. Install LinWorks from Lipowsky
|
|
2. Compile your LDF into an SDF file using LinWorks
|
|
3. Connect the BabyLIN-RC-II via USB
|
|
4. Launch the LIN Simulator → Refresh → Connect → Load SDF → Start
|
|
|
|
### Mock Mode
|
|
|
|
When the BabyLIN DLL is not available, the tool operates in **mock mode**:
|
|
- All GUI features work normally
|
|
- The scheduler generates simulated Rx data
|
|
- Useful for GUI development and testing without hardware
|
|
|
|
## Architecture
|
|
|
|
```
|
|
┌─────────────────────────────────────────────────────────────────────┐
|
|
│ MainWindow (GUI) │
|
|
│ ┌──────────┐ ┌──────────────────────────┐ ┌──────────────────┐ │
|
|
│ │Connection│ │ Tx Tree │ Rx Tree │ │ Control Bar │ │
|
|
│ │ Panel │ │ (editable) │ (live) │ │ Start/Stop/Pause│ │
|
|
│ └────┬─────┘ └──────┬─────┴──────┬──────┘ └────────┬─────────┘ │
|
|
│ │ │ │ │ │
|
|
├───────┴───────────────┴────────────┴───────────────────┴────────────┤
|
|
│ Application Logic │
|
|
│ ┌────────────────┐ ┌─────────────┐ ┌────────────────────────┐ │
|
|
│ │ LDF Handler │ │ Scheduler │ │ Connection Manager │ │
|
|
│ │ (parse LDF) │ │ (QTimer) │ │ (serial port state) │ │
|
|
│ └────────────────┘ └──────┬──────┘ └───────────┬────────────┘ │
|
|
│ │ │ │
|
|
├─────────────────────────────┴─────────────────────┴─────────────────┤
|
|
│ Hardware Layer │
|
|
│ ┌──────────────────────────────────────────────────────────────┐ │
|
|
│ │ BabyLIN Backend (wraps Lipowsky DLL / mock mode) │ │
|
|
│ │ → libBabyLIN.so (Linux) / BabyLIN.dll (Windows) │ │
|
|
│ └──────────────────────────────────────────────────────────────┘ │
|
|
└─────────────────────────────────────────────────────────────────────┘
|
|
```
|
|
|
|
## LDF File Support
|
|
|
|
The tool parses standard LIN 2.0/2.1 LDF files and extracts:
|
|
- Protocol/language version and baud rate
|
|
- Master and slave node definitions
|
|
- Frame definitions with signal mappings (bit offset, width, initial value)
|
|
- Schedule tables (including FreeFormat diagnostic entries)
|
|
- Node attributes
|
|
|
|
### Sample LDF
|
|
|
|
A test LDF (`resources/sample.ldf`) is included with:
|
|
- 1 master node (ECU_Master), 2 slave nodes
|
|
- 4 frames (2 Tx, 2 Rx), 9 signals
|
|
- 2 schedule tables (NormalSchedule, FastSchedule)
|
|
- 19200 baud
|
|
|
|
## License
|
|
|
|
Copyright 2026 TeqanyLogix LTD. All rights reserved.
|