This commit is contained in:
leviathan
2026-02-13 22:00:42 -05:00
parent b306ff0574
commit 655f019469
35 changed files with 768 additions and 52 deletions
+43
View File
@@ -0,0 +1,43 @@
# Subaru Protocol
**Rust module:** `src/protocols/subaru.rs`
**Reference:** `REFERENCES/ProtoPirate/protocols/subaru.c`
## Overview
Subaru uses PWM: 800 µs HIGH = 1, 1600 µs HIGH = 0; LOW is 800 µs after each bit. 64 bits total (8 bytes MSB first: button(4) + serial(24) + counter-related). Preamble: 79 full 1600 µs pairs + 80th HIGH only; then gap 2800 µs, sync 2800 µs HIGH + 1600 µs LOW. Complex counter decoding from bytes 47.
## Timing
| Parameter | Value | Notes |
|-----------|---------|---------|
| Short (1) | 800 µs | ±200 µs |
| Long (0) | 1600 µs | ±200 µs |
| Gap | 2800 µs | |
| Sync | 2800 µs HIGH + 1600 µs LOW | |
| Min bits | 64 | |
## Encoding
PWM: duration of HIGH = bit value (800 = 1, 1600 = 0); LOW 800 µs after each bit.
## Frame Layout (64 bits = 8 bytes)
- 4 bits button, 24 bits serial, counter-related in bytes 47 (decode_counter in code).
## Decoder Steps
1. **Reset** — Wait for long HIGH (preamble).
2. **CheckPreamble** — Count 79 long pairs + 80th HIGH; then expect gap 2800 µs.
3. **FoundGap** — Gap seen → look for sync (2800 HIGH, 1600 LOW).
4. **FoundSync** — Sync seen → SaveDuration.
5. **SaveDuration** — On HIGH: store duration, → CheckDuration. On end marker → return decode if 64 bits.
6. **CheckDuration** — On LOW: pair (te_last, duration) → shortshort = 1, longlong = 0; add bit, → SaveDuration.
## Encoder
Supported; builds preamble, gap, sync, then 64 PWM bits.
## Frequencies
433.92 MHz (and/or 315 MHz as in reference).