/// DTC maps for S300 and KPro ECU protocols, transcribed from the "DTC map" /// sections of hvbt_protocol.pdf. /// /// Key format: 'ERRxx_bity' where xx = ERR byte index (00-based), y = bit /// number (0=LSB). Value: ' — description'. Bits the PDF leaves /// undocumented ("???") use 'ERRxx.y' as the code so the raw bit is still /// visible on screen. library; /// S300 DTC map (ERR00–ERR03 = frame bytes 37–40). Descriptions include the /// Honda blink code and sensor abbreviation from the PDF. const Map s300DtcMap = { // ERR00 'ERR00_bit0': 'P0130 — Oxygen Sensor #1 (O2A, code 1)', 'ERR00_bit1': 'P0150 — Oxygen Sensor #2 (O2B, code 2)', 'ERR00_bit2': 'P0105 — Manifold Absolute Pressure Sensor (MAP, code 3)', 'ERR00_bit3': 'P0335 — Crank Position Sensor (CKP, code 4)', 'ERR00_bit4': 'P0105 — Manifold Absolute Pressure Sensor (MAP, code 5)', 'ERR00_bit5': 'P0106 — Engine Coolant Sensor (ECT, code 6)', 'ERR00_bit6': 'P0123 — Throttle Position Sensor (TPS, code 7)', 'ERR00_bit7': 'P1362 — Top Dead Center Sensor (TDC, code 8)', // ERR01 'ERR01_bit0': 'P0340 — Cylinder/Cam Sensor (CYL, code 9)', 'ERR01_bit1': 'P0113 — Intake Air Temperature Sensor (IAT, code 10)', 'ERR01_bit2': 'P0217 — Engine Overheating (OH, code 11)', 'ERR01_bit3': 'P0403 — EGR Lift Valve (EGR, code 12)', 'ERR01_bit4': 'P1106 — Atmospheric Pressure Sensor (BARO, code 13)', 'ERR01_bit5': 'P0505 — Idle Air Control Valve (IAC, code 14)', 'ERR01_bit6': 'P0350 — Ignition Control Module (IGM, code 15)', 'ERR01_bit7': 'P0200 — Fuel Injectors (INJ, code 16)', // ERR02 'ERR02_bit0': 'P0500 — Vehicle Speed Sensor (VSS, code 17)', 'ERR02_bit1': 'ERR02.1 — Undocumented code', 'ERR02_bit2': 'P0700 — Automatic Transmission Lockup Control Valve (code 19)', 'ERR02_bit3': 'P1298 — Electrical Load Detector (ELD, code 20)', 'ERR02_bit4': 'P2649 — VTEC Solenoid (VTS, code 21)', 'ERR02_bit5': 'P2647 — VTEC Pressure Valve (VTP, code 22)', 'ERR02_bit6': 'P0325 — Knock Sensor (code 23)', 'ERR02_bit7': 'P1324 — Knock Sensor (code 24)', // ERR03 'ERR03_bit0': 'P0750 — Automatic Transmission A Signal (ATA, code 30)', 'ERR03_bit1': 'P0755 — Automatic Transmission B Signal (ATB, code 31)', 'ERR03_bit2': 'P0135 — Primary Oxygen Sensor Heater (PO2H, code 41)', 'ERR03_bit3': 'P0135 — Oxygen Sensor Heater', 'ERR03_bit4': 'P0169 — Fuel Supply System (code 43)', 'ERR03_bit5': 'ERR03.5 — Undocumented code', 'ERR03_bit6': 'ERR03.6 — Undocumented code', 'ERR03_bit7': 'ERR03.7 — Undocumented code', }; /// KPro DTC map (ERR00–ERR17 = frame bytes 62–79). const Map kproDtcMap = { // ERR00 'ERR00_bit0': 'ERR00.0 — Unknown error 0', 'ERR00_bit1': 'P1607 — Internal Circuit Malfunction (check calibration type)', 'ERR00_bit2': 'P0131 — O2 Sensor Voltage Low', 'ERR00_bit3': 'P0132 — O2 Sensor Voltage High', 'ERR00_bit4': 'P0107 — MAP Sensor Low Voltage', 'ERR00_bit5': 'P0108 — MAP Sensor High Voltage', 'ERR00_bit6': 'P0335 — CRK Sensor No Signal', 'ERR00_bit7': 'P0336 — CRK Sensor Intermittent Interruption', // ERR01 'ERR01_bit0': 'P1128 — MAP Sensor Signal Lower Than Expected', 'ERR01_bit1': 'P1129 — MAP Sensor Signal Higher Than Expected', 'ERR01_bit2': 'P0117 — ECT Sensor Low Voltage', 'ERR01_bit3': 'P0118 — ECT Sensor High Voltage', 'ERR01_bit4': 'P0122 — TPS Low Voltage', 'ERR01_bit5': 'P0123 — TPS High Voltage', 'ERR01_bit6': 'P1121 — TPS Signal Lower Than Expected', 'ERR01_bit7': 'P1122 — TPS Signal Higher Than Expected', // ERR02 'ERR02_bit0': 'P0176 — Ethanol Sensor Input Error', 'ERR02_bit1': 'ERR02.1 — No description available', 'ERR02_bit2': 'ERR02.2 — No description available', 'ERR02_bit3': 'ERR02.3 — No description available', 'ERR02_bit4': 'P1362 — TDC Sensor No Signal', 'ERR02_bit5': 'P1361 — TDC Sensor Intermittent Signal Interruption', 'ERR02_bit6': 'P0112 — IAT Sensor Low Voltage', 'ERR02_bit7': 'P0113 — IAT Sensor High Voltage', // ERR03 'ERR03_bit0': 'P1213 — IMA Sensor Voltage Low', 'ERR03_bit1': 'P1214 — IMA Sensor Voltage High', 'ERR03_bit2': 'ERR03.2 — EGR Lift Sensor Voltage Error', 'ERR03_bit3': 'ERR03.3 — EGR F/B Error', 'ERR03_bit4': 'P1107 — Barometric Pressure Low Voltage', 'ERR03_bit5': 'P1108 — Barometric Pressure High Voltage', 'ERR03_bit6': 'P1106 — Barometric Pressure Sensor Range/Performance', 'ERR03_bit7': 'ERR03.7 — Unknown error 37', // ERR04 'ERR04_bit0': 'P0505 — Idle Control System Malfunction', 'ERR04_bit1': 'P1519 — Idle Air Control Valve Circuit Malfunction', 'ERR04_bit2': 'P0500 — VSS Malfunction', 'ERR04_bit3': 'ERR04.3 — VSP', 'ERR04_bit4': 'P1297 — ELD Circuit Low Voltage', 'ERR04_bit5': 'P1298 — ELD Circuit High Voltage', 'ERR04_bit6': 'P1253 — VTEC Solenoid Drive Time Abnormality', 'ERR04_bit7': 'ERR04.7 — Unknown error 47', // ERR05 'ERR05_bit0': 'P1259 — VTEC System Malfunction (Oil Pressure Switch)', 'ERR05_bit1': 'ERR05.1 — Unknown error 51', 'ERR05_bit2': 'P0325 — Knock Sensor Circuit Malfunction', 'ERR05_bit3': 'P1324 — Knock Sensor Circuit Failure', 'ERR05_bit4': 'P0563 — VBU Voltage High', 'ERR05_bit5': 'ERR05.5 — Unknown error 55', 'ERR05_bit6': 'ERR05.6 — Unknown error 56', 'ERR05_bit7': 'ERR05.7 — Unknown error 57', // ERR06 'ERR06_bit0': 'P1162 — Air Fuel Ratio Sensor Circuit Malfunction', 'ERR06_bit1': 'ERR06.1 — LAF Sensor AFV1 Short', 'ERR06_bit2': 'ERR06.2 — LAF Sensor AFC1 Short', 'ERR06_bit3': 'ERR06.3 — Unknown error 63', 'ERR06_bit4': 'ERR06.4 — Daughter Board Communication Error (battery voltage low when cranking)', 'ERR06_bit5': 'ERR06.5 — Unknown error 65', 'ERR06_bit6': 'P0600 — Multiplexer Not Present (for engine swaps disable in misc parameters)', 'ERR06_bit7': 'ERR06.7 — Unknown error 67', // ERR07 'ERR07_bit0': 'P1505 — PCV Negative Pressure', 'ERR07_bit1': 'ERR07.1 — Unknown error 71', 'ERR07_bit2': 'ERR07.2 — Unknown error 72', 'ERR07_bit3': 'ERR07.3 — Idle Valve', 'ERR07_bit4': 'P0135 — Primary HO2S Circuit Malfunction', 'ERR07_bit5': 'P1166 — Primary HO2S Heater Circuit Malfunction', 'ERR07_bit6': 'P1167 — Primary LAF HO2S Heater System Malfunction', 'ERR07_bit7': 'P0134 — Air/Fuel Ratio Sensor No Activity Detected', // ERR08 'ERR08_bit0': 'P0172 — Fuel System Too Rich', 'ERR08_bit1': 'P0171 — Fuel System Too Lean', 'ERR08_bit2': 'P1162 — Air/Fuel Ratio (A/F) Sensor Slow Response', 'ERR08_bit3': 'ERR08.3 — Unknown error 83', 'ERR08_bit4': 'P0010 — VTC Oil Control Solenoid Valve Malfunction', 'ERR08_bit5': 'P0011 — VTC System Malfunction', 'ERR08_bit6': 'P0340 — CMP Sensor No Signal', 'ERR08_bit7': 'P0344 — CMP Sensor Intermittent Interruption', // ERR09 'ERR09_bit0': 'P0341 — Variable Valve Timing (VTC) Phase Gap', 'ERR09_bit1': 'ERR09.1 — Unknown error 91', 'ERR09_bit2': 'ERR09.2 — Undocumented code', 'ERR09_bit3': 'P1163 — Air Fuel Ratio Sensor Slow Response', 'ERR09_bit4': 'P1164 — Air Fuel Ratio Sensor Range/Performance Problem', 'ERR09_bit5': 'ERR09.5 — Undocumented code', 'ERR09_bit6': 'P0137 — Secondary O2 Circuit Low Voltage', 'ERR09_bit7': 'P0138 — Secondary O2 Circuit High Voltage', // ERR10 'ERR10_bit0': 'P0139 — Secondary O2 Circuit Slow Response', 'ERR10_bit1': 'ERR10.1 — Unknown error 101', 'ERR10_bit2': 'P0141 — Secondary O2 Circuit Heater Circuit Malfunction', 'ERR10_bit3': 'ERR10.3 — Unknown error 103', 'ERR10_bit4': 'P0420 — Catalyst System Efficiency Below Threshold', 'ERR10_bit5': 'ERR10.5 — Catalyst / Secondary O2 Sensor', 'ERR10_bit6': 'ERR10.6 — Unknown error 106', 'ERR10_bit7': 'ERR10.7 — Unknown error 107', // ERR11 'ERR11_bit0': 'P0301 — Cylinder #1 Misfire', 'ERR11_bit1': 'ERR11.1 — Unknown error 111', 'ERR11_bit2': 'P0302 — Cylinder #2 Misfire', 'ERR11_bit3': 'ERR11.3 — Undocumented code', 'ERR11_bit4': 'P0303 — Cylinder #3 Misfire', 'ERR11_bit5': 'ERR11.5 — Unknown error 115', 'ERR11_bit6': 'P0304 — Cylinder #4 Misfire', 'ERR11_bit7': 'ERR11.7 — Unknown error 117', // ERR12 'ERR12_bit0': 'P0300 — Random Misfire', 'ERR12_bit1': 'ERR12.1 — Unknown error 121', 'ERR12_bit2': 'ERR12.2 — EGR Flow', 'ERR12_bit3': 'ERR12.3 — Unknown error 123', 'ERR12_bit4': 'P0116 — ECT Sensor Range/Performance Problem', 'ERR12_bit5': 'ERR12.5 — Unknown error 125', 'ERR12_bit6': 'P0128 — Cooling System Malfunction (Thermostat)', 'ERR12_bit7': 'ERR12.7 — VTC Solenoid', // ERR13 'ERR13_bit0': 'P1456 — EVAP Control System Leakage (Fuel Tank)', 'ERR13_bit1': 'P1457 — EVAP Control System Leakage (Canister System)', 'ERR13_bit2': 'P0452 — Fuel Tank Pressure Sensor Low Voltage', 'ERR13_bit3': 'P0453 — Fuel Tank Pressure Sensor High Voltage', 'ERR13_bit4': 'P0451 — Fuel Tank Pressure Sensor Range/Performance', 'ERR13_bit5': 'ERR13.5 — Undocumented code', 'ERR13_bit6': 'P0443 — EVAP Purge Valve Circuit', 'ERR13_bit7': 'ERR13.7 — Unknown error 137', // ERR14 'ERR14_bit0': 'ERR14.0 — PF2 Low', 'ERR14_bit1': 'ERR14.1 — PF2 High', 'ERR14_bit2': 'ERR14.2 — PF2 Monitor', 'ERR14_bit3': 'ERR14.3 — Undocumented code', 'ERR14_bit4': 'ERR14.4 — TF2 Low', 'ERR14_bit5': 'ERR14.5 — TF2 High', 'ERR14_bit6': 'ERR14.6 — PF0 Low', 'ERR14_bit7': 'ERR14.7 — PF0 High', // ERR15 'ERR15_bit0': 'ERR15.0 — TF0 Low', 'ERR15_bit1': 'ERR15.1 — TF0 High', 'ERR15_bit2': 'ERR15.2 — 3rd O2 Sensor Voltage Low', 'ERR15_bit3': 'ERR15.3 — 3rd O2 Sensor Voltage High', 'ERR15_bit4': 'ERR15.4 — 3rd O2 Sensor Response', 'ERR15_bit5': 'ERR15.5 — Unknown error 155', 'ERR15_bit6': 'ERR15.6 — 3rd O2 Sensor Heater Current Abnormality', 'ERR15_bit7': 'ERR15.7 — Unknown error 157', // ERR16 'ERR16_bit0': 'ERR16.0 — NOx Ability Monitor', 'ERR16_bit1': 'ERR16.1 — Unknown error 161', 'ERR16_bit2': 'P1077 — Intake Manifold Runner Control System Malfunction (low rpm)', 'ERR16_bit3': 'P1078 — Intake Manifold Runner Control System Malfunction (high rpm)', 'ERR16_bit4': 'P0661 — Intake Manifold Runner Control Low Voltage', 'ERR16_bit5': 'P0662 — Intake Manifold Runner Control High Voltage', 'ERR16_bit6': 'ERR16.6 — P1 Switch Abnormality', 'ERR16_bit7': 'ERR16.7 — Unknown error 167', // ERR17 'ERR17_bit0': 'P0219 — Engine Over-Rev', 'ERR17_bit1': 'P0217 — Engine Over-Heating', 'ERR17_bit2': 'ERR17.2 — Undocumented code', 'ERR17_bit3': 'ERR17.3 — Undocumented code', 'ERR17_bit4': 'ERR17.4 — Undocumented code', 'ERR17_bit5': 'ERR17.5 — Undocumented code', 'ERR17_bit6': 'ERR17.6 — Undocumented code', 'ERR17_bit7': 'ERR17.7 — Undocumented code', }; /// True if any of [bits] — (ERR byte index, bit number) pairs — is set. /// Used to derive sensor-error flags (IAT/CLT/O2) from the stored codes. bool anyDtcBit(List errBytes, List<(int, int)> bits) { for (final (byte, bit) in bits) { if (byte < errBytes.length && (errBytes[byte] >> bit) & 1 == 1) { return true; } } return false; } // Sensor-error flag sources, per the DTC maps above. const s300IatErrorBits = [(1, 1)]; // P0113 const s300EctErrorBits = [(0, 5)]; // P0106 const s300O2ErrorBits = [(0, 0), (0, 1), (3, 2), (3, 3)]; // O2A/B, heaters const kproIatErrorBits = [(2, 6), (2, 7)]; // P0112/P0113 const kproEctErrorBits = [(1, 2), (1, 3), (12, 4)]; // P0117/P0118/P0116 const kproO2ErrorBits = [ (0, 2), (0, 3), // O2 voltage low/high (6, 0), (6, 1), (6, 2), // A/F (LAF) sensor circuit (7, 4), (7, 5), (7, 6), (7, 7), // HO2S / LAF heater, no activity (9, 3), (9, 4), // A/F slow response, range ]; /// Returns a list of active DTC descriptions from the given raw error bytes /// using the provided map. List decodeDtcs(List errBytes, Map dtcMap) { final List active = []; for (int byteIdx = 0; byteIdx < errBytes.length; byteIdx++) { final int b = errBytes[byteIdx]; if (b == 0) continue; for (int bit = 0; bit < 8; bit++) { if ((b >> bit) & 1 == 1) { final String key = 'ERR${byteIdx.toString().padLeft(2, '0')}_bit$bit'; final String? desc = dtcMap[key]; if (desc != null) active.add(desc); } } } return active; }