{
  "$schema": "./schema/dtc.schema.json",
  "spec": "smongrot.dtc",
  "spec_version": "1.0.0-phase1",
  "level": 1,
  "status": "beta",
  "summary": "Honda PGM-FI stored fault codes: send three 72 05 74 0x reads, cut the payload out of each reply, decode (code, sub) pairs as Honda blink codes.",
  "status_reason": "The 72 05 74 0x frames answer on real boxes, and one bench run with two induced faults (Keihin K03-H01, 2026-11-04) gave 07 01 / 08 01. The code meaning of those bytes (Honda blink code, plain binary) is INFERRED, no box with a naturally stored fault has been read, and only the Keihin layout was ever seen. Treat output as beta.",
  "authority": "Reference implementation (fault-code read frames, decoder and scan result rules).",
  "requires": "An open diagnostic session (spec/kline.json session, StartDiag sent).",
  "read": {
    "requests": [
      {"sub": 1, "request": "72 05 74 01 14"},
      {"sub": 2, "request": "72 05 74 02 13"},
      {"sub": 3, "request": "72 05 74 03 12"}
    ],
    "gap_ms": 60,
    "reply": "02 0C 74 <sub> <7-byte payload> <ck>",
    "bench_replies": {
      "74 01 (ECT knob at max temp + TPS knob at 0)": "02 0C 74 01 00 07 01 08 01 00 00 6C",
      "74 02": "02 0C 74 02 00 00 00 00 00 00 00 7C",
      "74 03": "02 0C 74 03 00 00 00 00 00 00 00 7B"
    }
  },
  "payload_extraction": {
    "summary": "Payload of one reply (per sub) over an echo-stripped reply.",
    "steps": [
      "Scan i from len(R)-5 down to 0 (the LAST matching frame wins).",
      "Skip i unless R[i] == 0x02 and R[i+2] == 0x74, and (when sub is given) R[i+3] == sub.",
      "L = R[i+1]; skip unless L >= 6 and i + L <= len(R).",
      "Skip unless R[i .. i+L-1] sums to 0 mod 256.",
      "payload = R[i+4 .. i+L-2]."
    ],
    "none": "No such frame → that reply is unreadable."
  },
  "payload_decode": {
    "summary": "Decode one payload. payload = [lead byte][code, sub] pairs.",
    "rules": [
      "Unreadable (null) if the payload is empty or its length is even (must be 1 + 2n).",
      "Unreadable if payload[0] != 0x00 (0x00 is the only value ever seen; its meaning is unknown).",
      "For each pair (c, s): 00 00 = empty slot, skip; exactly one of them 0 = unreadable; else code c-s.",
      "Codes are de-duplicated, first-seen order kept."
    ],
    "encoding": "Plain binary, not BCD: 0x07 0x01 = blink code 7-1, 0x15 0x01 = 21-1 (INFERRED from the K03-H01 ROM code table).",
    "label": "\"<code>-<sub>\", e.g. 7-1"
  },
  "read_decode": {
    "summary": "Decode all replies of one scan (replies + subs).",
    "rules": [
      "No replies → unreadable.",
      "If subs is given it must have one entry per reply, and reply k must carry sub subs[k].",
      "Any reply unreadable (no frame, or payload unreadable) → the WHOLE read is unreadable. Never guess.",
      "Else the union of all codes, de-duplicated in order. Empty list = clean."
    ]
  },
  "maker_rule": {
    "summary": "Scan result rule: only Keihin boxes (part code 38770-) are decoded. Shindengen / unknown makers answer the same frames but any non-zero payload is reported 'unreadable' until bench-confirmed.",
    "outcomes": {
      "faults": "Keihin, read_decode gives at least one code",
      "clean": "every 74 reply answered and all payloads are zero",
      "unreadable": "a reply does not parse, or a non-Keihin box returned non-zero payload",
      "failed": "no reply (or only NAK) to any request"
    },
    "nak": "A reply containing byte 0x7F is treated as a NAK (no answer) by the board's classifier."
  },
  "codes": {
    "summary": "Generic Honda PGM-FI blink codes the app names. Best-known reference, NOT bench-proven except where bench_confirmed. Meanings translated from the app's Thai names; unknown codes are shown as their label only.",
    "voltage_split": {"codes": [1, 7, 8, 9, 54], "sub_1": "signal too low", "sub_2": "signal too high"},
    "critical": {"codes": [12, 33, 52], "meaning": "the engine may not run right; stop and get it checked soon"},
    "bench_confirmed": ["7-1", "8-1"],
    "list": [
      {"code": 1, "meaning_en": "intake manifold pressure (MAP) sensor"},
      {"code": 7, "meaning_en": "engine temperature sensor"},
      {"code": 8, "meaning_en": "throttle position sensor"},
      {"code": 9, "meaning_en": "intake air temperature sensor"},
      {"code": 11, "meaning_en": "vehicle speed sensor"},
      {"code": 12, "meaning_en": "injector"},
      {"code": 21, "meaning_en": "O2 sensor"},
      {"code": 23, "meaning_en": "O2 sensor heater"},
      {"code": 29, "meaning_en": "idle air control valve"},
      {"code": 33, "meaning_en": "ECU memory"},
      {"code": 52, "meaning_en": "crank position sensor"},
      {"code": 54, "meaning_en": "bank angle (fall) sensor"}
    ]
  },
  "not_included": [
    "An older OBD-style P-code packing in the reference implementation: a best-guess legacy mapping, never used on a real Honda reply.",
    "DTC clear (72 05 60 0x): changes ECU state and resets learned values; not level 1."
  ]
}
