feat: KSUDP parser fix, warnings system, shift point rewrite, code quality (v0.5.1)

Bug Fixes:
- Fixed KSUDP binary parser offsets from packed (323B) to natural C
  alignment (328B) — 3 bytes padding after char identifier, 2 bytes
  after 6 bools
- Fixed setup_terminal() leaving terminal in raw mode on early exit

New Features:
- Thread-safe warning buffer (warnings.rs) with TUI bar + stderr fallback
- Rewrote shift point analysis per AC forum methodology: per-gear
  acceleration curves, crossover detection, same-gear merging
- UseCase::guidance() — step-by-step recording instructions
- Recording metadata enrichment in analysis responses
- recording_id field on sessions

Code Quality:
- Extracted finalize_run() helper (session.rs)
- Extracted execute_and_store_analysis() helper (api.rs)
- Extracted lerp_search<T>() generic helper (analysis.rs)

Breaking API Changes:
- GET /api/use-cases: string[] -> [{id, name, guidance}[]]
- Shift point analysis: gear_ranges/shift_events -> gear_curves/crossover_points

Updated README.md with new API response examples and TUI warning bar.
This commit is contained in:
Jan-Peter von Hunnius 2026-06-05 21:12:57 +02:00
parent 090ab7e559
commit e3aa511ac7
9 changed files with 696 additions and 312 deletions

View file

@ -119,6 +119,7 @@ The terminal UI shows one panel per active feed:
│ ╚ PCARS Port :5606 ╝ │
├──────────────────────────────────────────────────────────┤
│ Recording: 550e8400-… Ctrl+C Quit │
│ ⚠ Handshake response timed out (5s) — 12s ago │
└──────────────────────────────────────────────────────────┘
```
@ -239,18 +240,52 @@ All fields are optional.
}
```
### Use Cases Response
```json
[
{ "id": "shift_points", "name": "ShiftPoints", "guidance": "1. Drive to a long straight..." },
{ "id": "track_map", "name": "TrackMap", "guidance": "1. Drive a complete lap..." }
]
```
Each object contains:
- `id` — use case identifier (use in session creation)
- `name` — human-readable name
- `guidance` — step-by-step instructions for the use case
### Shift Point Analysis Response
```json
{
"gear_ranges": [
{ "gear": 2, "gear_display": "1", "min_rpm": 3200, "max_rpm": 8500, "avg_rpm": 6100, "sample_count": 1200 },
{ "gear": 3, "gear_display": "2", "min_rpm": 5800, "max_rpm": 8400, "avg_rpm": 7200, "sample_count": 900 }
"gear_curves": [
{
"gear": 2,
"gear_display": "1",
"run_label": "Run 1, Run 2 (2 runs)",
"data_points": [
{ "speed_kmh": 45.2, "rpm": 3200, "acceleration_g": 0.85 },
{ "speed_kmh": 55.8, "rpm": 4100, "acceleration_g": 0.82 }
],
"min_rpm": 3200,
"max_rpm": 8500,
"min_speed_kmh": 45.0,
"max_speed_kmh": 120.0,
"sample_count": 1200
}
],
"shift_events": [
{ "from_gear": 2, "to_gear": 3, "rpm_before_shift": 8400, "rpm_after_shift": 6100, "rpm_drop": 2300, "speed_kmh": 95.0 }
"crossover_points": [
{
"from_gear": 2,
"to_gear": 3,
"from_gear_display": "1",
"to_gear_display": "2",
"crossover_speed_kmh": 95.0,
"crossover_rpm": 7500
}
],
"recommended_shift_rpm": 8400.0,
"recommended_shift_rpm": 7500.0,
"runs_analyzed": 3,
"total_frames_analyzed": 2100
}
```
@ -295,7 +330,8 @@ src/
├── parser_ksudp.rs AC KSUDP binary parser (RTCarInfo, 6 tests)
├── parser_telemetry_tool.rs AC Telemetry Tool binary parser (357-byte driver struct, 7 tests)
├── parser_pcars.rs PCARS 1 & 2 binary parser with auto-detection (5 tests)
└── ui.rs Ratatui TUI rendering
├── ui.rs Ratatui TUI rendering
└── warnings.rs Thread-safe warning buffer with TUI bar + stderr fallback
```
## License