# log-analyzer **Repository Path**: xiaowine/log-analyzer ## Basic Information - **Project Name**: log-analyzer - **Description**: No description available - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-15 - **Last Updated**: 2026-06-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # log-analyzer Skill LIN (Local Interconnect Network) BLF (Binary Logging Format) data analysis skill for Qoder with LDF support, HOD capacitor thermal drift analysis, and signal visualization. ## What This Skill Does This skill helps you analyze automotive LIN bus communication data stored in BLF format files with advanced features: - **LDF (LIN Description File) parsing** for automatic signal decoding - **HOD (Hands On Detection) capacitor thermal drift analysis** - detect temperature-induced sensor drift - Frame distribution analysis - Timing and periodicity verification - Bus load calculation - Anomaly detection (missing frames, timing gaps) - **Raw value curve generation** with matplotlib - Diagnostic communication analysis - Data export to CSV with decoded physical values ## When to Use The agent will automatically apply this skill when you: - Mention "LIN BLF" or "LIN log" files - Ask to analyze LIN communication data - Need to parse LDF files for signal definitions - Want to visualize signal values over time - Need to debug automotive network issues - Request analysis of BLF files from Vector tools ## Quick Start ### Option 1: Basic BLF Analysis (without LDF) ```bash cd ~/.qoder-cn/skills/log-analyzer/scripts python analyze_lin.py /path/to/file.blf -o report.txt ``` ### Option 2: Advanced Analysis with LDF (Recommended) ```bash python analyze_lin_advanced.py data.blf --ldf network.ldf \ --plot VehicleSpeed EngineRPM \ --plot-output signals.png \ --csv decoded_data.csv \ -o report.txt ``` ### Option 3: Interactive Analysis Just tell the agent: - "Analyze this LIN BLF file with the LDF" - "Plot the VehicleSpeed signal curve" - "Decode signals using the LDF file" - "Check the timing of these LIN messages" ## File Structure ``` log-analyzer/ ├── SKILL.md # Main skill instructions ├── LIN_SPEC.md # LIN protocol reference ├── BLF_FORMAT.md # BLF format documentation ├── LDF_FORMAT.md # LDF format reference ├── examples.md # Analysis examples ├── README.md # This file └── scripts/ ├── analyze_lin.py # Basic analyzer ├── analyze_lin_advanced.py # Advanced analyzer with LDF └── analyze_hod_drift.py # HOD thermal drift analyzer (NEW) ``` ## Requirements For full functionality: ```bash pip install python-can ldfparser numpy pandas matplotlib ``` **Key packages:** - `python-can`: Read BLF files - `ldfparser`: Parse LDF files and decode signals - `matplotlib`: Generate signal value curves - `numpy/pandas`: Data processing **Note**: BLF is a proprietary Vector format. If `python-can` cannot read your BLF file: 1. Use Vector CANoe/CANalyzer to export to ASCII/CSV first 2. Or install Vector's official libraries ## Usage Examples ### Basic BLF Analysis ```bash python analyze_lin.py lin_data.blf ``` ### With LDF Signal Decoding ```bash python analyze_lin_advanced.py data.blf --ldf network.ldf ``` ### Generate Signal Curves ```bash # Plot single signal python analyze_lin_advanced.py data.blf --ldf network.ldf \ --plot VehicleSpeed --plot-output speed_curve.png # Plot multiple signals on same graph python analyze_lin_advanced.py data.blf --ldf network.ldf \ --multi-plot VehicleSpeed EngineRPM ThrottlePos \ --plot-output engine_signals.png ``` ### Complete Analysis with Export ```bash python analyze_lin_advanced.py data.blf --ldf network.ldf \ --csv decoded.csv \ -o report.txt \ --plot WindowPosition DoorStatus ``` ### Custom Baud Rate ```bash python analyze_lin.py lin_data.blf -b 9600 ``` ### HOD Capacitor Thermal Drift Analysis ```bash # Analyze HOD sensor drift from BLF with LDF python scripts/analyze_hod_drift.py hod_data.blf \ --ldf network.ldf \ --signal HOD_Capacitance \ --hands-on-threshold 50.0 \ --settling-time 2.0 \ --pre-window 5.0 \ --post-window 5.0 \ --plot hod_drift.png \ --csv hod_results.csv \ --output hod_report.txt # Analyze from CSV file python scripts/analyze_hod_drift.py hod_data.csv \ --signal HOD_Capacitance \ --plot hod_drift.png ``` ## Command Line Options ### analyze_lin_advanced.py | Option | Description | |--------|-------------| | `blf_file` | Path to BLF file (required) | | `--ldf LDF` | Path to LDF file for signal decoding | | `-o, --output` | Output report file | | `-b, --baud-rate` | LIN baud rate (default: 19200) | | `--csv CSV` | Export decoded signals to CSV | | `--plot SIG [SIG ...]` | Signal names to plot individually | | `--plot-output FILE` | Output file for plots | | `--multi-plot SIG [SIG ...]` | Multiple signals on same graph | | `--threshold VAL` | Anomaly detection threshold (default: 2.0) | ### analyze_hod_drift.py | Option | Description | |--------|-------------| | `input_file` | Path to BLF or CSV file (required) | | `--signal SIGNAL` | HOD signal name to analyze (required) | | `--ldf LDF` | Path to LDF file (required for BLF) | | `--hands-on-threshold VAL` | Threshold to detect hands-on (default: 50.0) | | `--settling-time SEC` | Wait time after hands-off (default: 2.0s) | | `--pre-window SEC` | Baseline window before hands-on (default: 5.0s) | | `--post-window SEC` | Drift measurement window (default: 5.0s) | | `-o, --output FILE` | Output report file | | `--plot FILE` | Output file for drift plot | | `--csv FILE` | Export detailed results to CSV | ## Common Use Cases 1. **LDF-Based Decoding**: Automatically decode raw bytes to physical values using LDF database 2. **HOD Thermal Drift Analysis**: Detect temperature-induced drift in capacitive sensors 3. **Signal Visualization**: Generate curves showing how sensor values change over time 4. **Verify LIN Schedule**: Check if frames are transmitted at correct intervals 5. **Debug Communication Issues**: Find missing frames or timing anomalies 6. **Bus Load Analysis**: Ensure bus utilization is within limits (<70%) 7. **Diagnostic Testing**: Analyze master/slave diagnostic communication 8. **Data Export**: Export decoded signal data to CSV for Excel/MATLAB analysis ## Example Workflow ### Step 1: Load and Decode ```python from ldfparser import parse_ldf from can import BLFReader ldf = parse_ldf('network.ldf') messages = list(BLFReader('data.blf')) ``` ### Step 2: Analyze Frame Distribution ```bash python analyze_lin_advanced.py data.blf --ldf network.ldf ``` ### Step 3: Generate Plots ```bash python analyze_lin_advanced.py data.blf --ldf network.ldf \ --multi-plot Speed RPM Temperature \ --plot-output dashboard.png ``` ### Step 4: Export and Review ```bash python analyze_lin_advanced.py data.blf --ldf network.ldf \ --csv results.csv -o report.txt ``` ## Related Documentation - For detailed usage examples, see [examples.md](examples.md) - For LIN protocol details, see [LIN_SPEC.md](LIN_SPEC.md) - For BLF format information, see [BLF_FORMAT.md](BLF_FORMAT.md) - For LDF file format, see [LDF_FORMAT.md](LDF_FORMAT.md) ## Troubleshooting ### Cannot read BLF file - Verify file is not corrupted - Check if you have the correct BLF library installed - Try converting to ASCII format using Vector tools first ### LDF parsing errors - Validate LDF syntax: `python -c "from ldfparser import parse_ldf; parse_ldf('file.ldf')"` - Check for matching braces and semicolons - Ensure LIN version is declared ### Signal decoding fails - Verify signal names in LDF match frame structure - Check signal offsets and widths don't overlap - Ensure frame IDs in LDF match BLF data ### Plot generation fails - Install matplotlib: `pip install matplotlib` - Check signal name spelling (case-sensitive) - Verify signal exists in decoded data ## Tips 1. **Always use LDF when available** - Manual bit extraction is error-prone 2. **Validate LDF early** - Test LDF before deploying to hardware 3. **Plot key signals** - Visual inspection reveals hidden patterns 4. **Compare with spec** - Verify ranges match design documents 5. **Automate repetitive tasks** - Save analysis scripts for reuse 6. **Version control** - Track changes to both LDF and analysis scripts ## License This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details. ## Contributing Contributions are welcome! Please feel free to submit a Pull Request. ## Author - **xiaowine** - Initial work ## Acknowledgments - Built with Qoder AI coding assistant - Uses python-can library for BLF file reading - Uses ldfparser library for LIN signal decoding