feat: redesign bench calibration (factor/offset), add Ttank/P2 displays, fix sensor calibration

- Replace P1-P6 rational transfer function with factor/offset model for bench params
- Add explicit rx/tx direction flags in bench XML configuration
- Add T.Tank (BenchTemp) and P2 (AnalogSensor2) to temperature/pressure display
- Apply SensorConfiguration calibration to pressure channels, fix empty sensors.xml fallback
- Add live value labels to flowmeter charts
- Hide pump live values and PSG encoder standalone label
- Add K-Line connection state model, improve KWP service and status displays
- Restructure .claude/skills into subdirectory format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-14 21:25:30 +02:00
parent 4964806de1
commit 4891eb6812
20 changed files with 881 additions and 185 deletions

View File

@@ -0,0 +1,74 @@
# VP44 Protocol Reference
Quick reference for hardware protocol constants used in HC_APTBS. Consult this before modifying any protocol-related code.
---
## DFI encoding (EEPROM address 0x0044 on VP44 ECU)
**Read (raw byte → DFI value):**
```csharp
dfi = (sbyte)raw * 3.0 / 256.0
```
**Write (DFI value → raw byte):**
```csharp
raw = (sbyte)((dfi * 256.0f) / 3.0f)
// If raw == 0, use 1 — the ECU rejects zero
```
**Checksum:**
```csharp
checksum = (byte)(0 - (byte)rawValue)
```
---
## IIR low-pass filter (PcanAdapter.PassFilterUpdate)
```csharp
result = Math.Round(prev + alpha * (value - prev), 4)
```
Used to smooth CAN bus sensor readings. The `alpha` coefficient controls responsiveness vs. noise rejection.
---
## OEM legitimation (PcanAdapter.Connect)
```csharp
token = (20120378UL << 32) | 21200UL
```
Sent as a CAN frame to authenticate with the bench controller. Without this, the bench ignores all commands.
---
## K-Line / KWP timing
**Inter-byte delay** (`KW1281Connection.SendPacket`):
```csharp
Thread.Sleep(5) // after each byte — KWP protocol requirement, NOT a workaround
```
**5-baud slow-init** (`KwpCommon.WakeUp`):
- Bit-bangs the ECU address at 5 baud on the K-Line
- Sleep durations in WakeUp are protocol-mandated — do not change
**Session lifetime**:
- One `FtdiInterface` open/close per KWP operation
- ECU expects a fresh session per dialog — do not pool connections
---
## CAN bus (PCAN-Basic, 500 kbps)
- Channel: `PCAN_USBBUS1`
- Baud: `PCAN_BAUD_500K`
- Read thread polls with `Thread.Sleep(2)` in `DrainMessageQueue` (known debt)
---
## Caution
Do not change any of these values without understanding the hardware protocol specification. Incorrect values can cause ECU communication failures or bench malfunction.