Repository navigation
Expand file tree
/
Copy pathvehicle-profiles.ts
More file actions
454 lines (440 loc) · 18.8 KB
/
Copy pathvehicle-profiles.ts
File metadata and controls
454 lines (440 loc) · 18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
// ─────────────────────────────────────────────────────────────────────────────
// Vehicle connection profiles
// ─────────────────────────────────────────────────────────────────────────────
//
// A profile describes which ELM327 protocols to attempt for a given car,
// plus any vehicle-specific hints the UI can surface (expected PIDs, known
// weak modes, etc.). Profiles are pure data — the ELM327 state machine
// consumes them when negotiating a connection.
import type { OBDProtocol } from "./types";
/** ELM327 `ATSP<n>` numeric protocol IDs. */
export const PROTOCOL_NUMBERS: Record<OBDProtocol, string | null> = {
auto: "0",
SAE_J1850_PWM: "1",
SAE_J1850_VPW: "2",
ISO_9141_2: "3",
ISO_14230_4_KWP: "4",
ISO_14230_4_KWP_FAST: "5",
ISO_15765_4_CAN_11bit_500k: "6",
ISO_15765_4_CAN_29bit_500k: "7",
ISO_15765_4_CAN_11bit_250k: "8",
ISO_15765_4_CAN_29bit_250k: "9",
SAE_J1939_CAN: "A",
USER1_CAN: "B",
USER2_CAN: "C",
unknown: null,
};
export const PROTOCOL_LABELS: Record<OBDProtocol, string> = {
auto: "Auto",
SAE_J1850_PWM: "J1850 PWM",
SAE_J1850_VPW: "J1850 VPW",
ISO_9141_2: "ISO 9141-2",
ISO_14230_4_KWP: "KWP2000 (5-baud init)",
ISO_14230_4_KWP_FAST: "KWP2000 Fast",
ISO_15765_4_CAN_11bit_500k: "CAN 11-bit 500k",
ISO_15765_4_CAN_29bit_500k: "CAN 29-bit 500k",
ISO_15765_4_CAN_11bit_250k: "CAN 11-bit 250k",
ISO_15765_4_CAN_29bit_250k: "CAN 29-bit 250k",
SAE_J1939_CAN: "J1939 CAN",
USER1_CAN: "User1 CAN",
USER2_CAN: "User2 CAN",
unknown: "Unknown",
};
/** Broad protocol family — used for mode-availability decisions. */
export type ProtocolFamily = "can" | "kline" | "j1850" | "unknown";
export function protocolFamily(p: OBDProtocol): ProtocolFamily {
if (p.startsWith("ISO_15765_4_CAN") || p === "SAE_J1939_CAN" || p.endsWith("_CAN")) {
return "can";
}
if (p === "ISO_9141_2" || p.startsWith("ISO_14230_4_KWP")) return "kline";
if (p === "SAE_J1850_PWM" || p === "SAE_J1850_VPW") return "j1850";
return "unknown";
}
/** A vehicle profile describes what to expect from a specific car/family. */
export interface VehicleProfile {
id: string;
name: string;
description: string;
/**
* Ordered list of ELM327 protocols to try when auto-detect fails.
* The connection layer attempts each in order until one produces a valid
* `0100` response.
*/
protocolStrategy: OBDProtocol[];
/** Supported-PID discovery bases to interrogate. */
supportedPidBases: number[];
/**
* PIDs that are expected to work well on this vehicle family. Used as a
* starter fast-tier set and for post-connect smoke tests.
*/
expectedPids: number[];
/**
* Additional PIDs that are plausible but not guaranteed — probed, warned
* about, but never relied on.
*/
optionalPids: number[];
/**
* PIDs known to be missing / unreliable on this vehicle family. Not probed
* by default and hidden from the quick-pick UI.
*/
unreliablePids: number[];
/** Modes known to be unreliable or unsupported. */
weakModes: number[];
/**
* Adapter-init hints: extra AT commands to send after protocol selection.
* Useful for K-line cars that need slower timings or specific header setups.
*/
postInitCommands?: string[];
/** Human-readable guidance shown in Setup / Diagnostics pages. */
notes: string[];
}
// ── Profiles ────────────────────────────────────────────────────────────────
/** Generic fallback profile — no vehicle-specific bias. */
export const GENERIC_PROFILE: VehicleProfile = {
id: "generic",
name: "Generic OBD-II",
description:
"Standard SAE J1979 auto-detect. Use for unknown vehicles or modern CAN-based cars.",
protocolStrategy: [
"auto",
"ISO_15765_4_CAN_11bit_500k",
"ISO_15765_4_CAN_29bit_500k",
"ISO_15765_4_CAN_11bit_250k",
"ISO_15765_4_CAN_29bit_250k",
"ISO_14230_4_KWP_FAST",
"ISO_14230_4_KWP",
"ISO_9141_2",
"SAE_J1850_VPW",
"SAE_J1850_PWM",
],
supportedPidBases: [0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0],
expectedPids: [0x0c, 0x0d, 0x05, 0x11, 0x04, 0x10, 0x42],
optionalPids: [],
unreliablePids: [],
weakModes: [],
notes: [],
};
/**
* 2005 Peugeot 206 1.6 16V petrol (TU5JP4 / NFU, ~110 hp).
*
* Evidence sources:
* - pinoutguide.com Peugeot OBD-II compatibility list: "Peugeot 206 1.6 16v
* Gasoline (110HP) 2003 onwards — KWP FAST".
* - French-car community threads: generic ELM327 tools frequently fail on
* PSA auto-detect because K-line timing is sensitive; manual protocol
* selection is usually more reliable.
* - Engine strategy: MAP-based, no MAF on TU5JP4/NFU.
*/
export const PEUGEOT_206_1_6_16V_PROFILE: VehicleProfile = {
id: "peugeot-206-1.6-16v-2005",
name: "Peugeot 206 1.6 16V (2005)",
description:
"TU5JP4 / NFU engine. K-line diagnostics — KWP2000 Fast typical. No MAF; MAP-based.",
protocolStrategy: [
"auto",
"ISO_14230_4_KWP_FAST",
"ISO_14230_4_KWP",
"ISO_9141_2",
],
supportedPidBases: [0x00, 0x20, 0x40],
expectedPids: [
0x01, // Monitor status / MIL
0x04, // Calculated engine load
0x05, // Coolant temperature
0x06, // Short-term fuel trim bank 1
0x07, // Long-term fuel trim bank 1
0x0b, // Intake manifold pressure (MAP)
0x0c, // Engine RPM
0x0d, // Vehicle speed
0x0e, // Ignition timing advance
0x0f, // Intake air temperature
0x11, // Throttle position
0x13, // Oxygen sensors present
0x1c, // OBD standard
0x42, // Control module voltage (often works on this era)
],
optionalPids: [
0x14, 0x15, 0x16, 0x17, // O2 sensor voltage/trim
0x2f, // Fuel level
0x46, // Ambient air temperature
],
unreliablePids: [
0x10, // MAF — TU5JP4 is MAP-based, usually absent
0x5c, // Engine oil temp — rare on this ECU
0x5e, // Engine fuel rate
],
weakModes: [
0x05, // O2 monitor test — spotty on older PSA K-line
0x06, // On-board monitor results — inconsistent exposure on this ECU
0x08, // Bidirectional control — not generically available
0x0a, // Permanent DTCs — introduced post-this-era on most ECUs
],
postInitCommands: [
"ATAT1", // Enable adaptive timing (mode 1) — helps flaky K-line
"ATST64", // ~400 ms response timeout (64 * 4 ms)
],
notes: [
"This ECU is K-line, not CAN. Use a quality ELM327 v1.5+ adapter — many cheap clones drop K-line frames.",
"If auto-detect fails, force protocol 5 (KWP Fast) from the profile dropdown.",
"Ignition must be in position 2 (running or key-on) before connecting.",
"Mode 08 / Mode 0A are generally not supported. Deep diagnostics require PSA-specific tooling (DiagBox / Lexia).",
],
};
/**
* 2008 Ford Ranger PJ 2.2 petrol — South Africa / Europe spec
* (single-cab LWB workhorse, 2184 cc, 68 kW @ 4500 / 160 Nm @ 2000,
* SOHC 12V, naturally aspirated, electronic injection).
*
* Evidence / reasoning:
* - PJ-generation international Ranger (2006-2009) is a Mazda-derived
* platform (shared with the Mazda B-series / BT-50). SA-market base
* petrol variant uses the Mazda F2-family 2.2 L petrol engine with a
* Mazda/Ford PCM.
* - This platform predates CAN-as-diagnostic-bus in the ROW market;
* engine diagnostics are K-line based (ISO 14230-4 KWP / ISO 9141-2),
* not ISO 15765-4 CAN. Ford NA J1850 PWM is not used on SA-spec.
* - Base workhorse spec (no ABS, no airbags per SA specsheet) — the
* generic EOBD surface is thin: expect PID range 0x00–0x20 coverage,
* very limited or absent Mode 05 / 06 / 08 / 0A support.
* - Engine is speed-density (MAP) with a throttle-based air model;
* MAF (PID 0x10) is typically not present on this engine.
*/
export const FORD_RANGER_PJ_2_2_PETROL_PROFILE: VehicleProfile = {
id: "ford-ranger-pj-2.2-petrol-2008",
name: "Ford Ranger PJ 2.2 Petrol (2008, SA)",
description:
"Mazda F2-family 2.2 L petrol (Ranger PJ / BT-50 platform). K-line diagnostics — KWP2000 Fast or ISO 9141-2. MAP-based, no MAF.",
protocolStrategy: [
"auto",
"ISO_14230_4_KWP_FAST",
"ISO_14230_4_KWP",
"ISO_9141_2",
],
supportedPidBases: [0x00, 0x20],
expectedPids: [
0x01, // Monitor status / MIL
0x03, // Fuel system status
0x04, // Calculated engine load
0x05, // Coolant temperature
0x06, // Short-term fuel trim bank 1
0x07, // Long-term fuel trim bank 1
0x0b, // Intake manifold pressure (MAP)
0x0c, // Engine RPM
0x0d, // Vehicle speed
0x0e, // Ignition timing advance
0x0f, // Intake air temperature
0x11, // Throttle position
0x13, // Oxygen sensors present
0x1c, // OBD standard
],
optionalPids: [
0x14, 0x15, // O2 sensor bank 1 voltage/trim
0x21, // Distance with MIL on
0x2f, // Fuel level
0x42, // Control module voltage — occasionally present on the higher base
],
unreliablePids: [
0x10, // MAF — this engine is speed-density / MAP-based
0x22, // Fuel rail pressure (manifold vac reference) — diesel-oriented
0x23, // Fuel rail pressure (direct) — diesel-oriented
0x2c, // Commanded EGR — unlikely on this base petrol spec
0x2d, // EGR error
0x5c, // Engine oil temp
0x5e, // Engine fuel rate
],
weakModes: [
0x05, // O2 monitor test — K-line era, rarely exposed generically
0x06, // On-board monitor results — weak on K-line platforms
0x08, // Bidirectional control — not generically available
0x0a, // Permanent DTCs — post-dates this ECU
],
postInitCommands: [
"ATAT1", // Enable adaptive timing — helps on K-line
"ATST64", // ~400 ms response timeout (64 * 4 ms)
],
notes: [
"SA-market PJ Ranger 2.2 petrol is K-line, not CAN. Use a quality ELM327 v1.5+ adapter.",
"If auto-detect fails, force protocol 5 (KWP Fast), then 4 (KWP 5-baud), then 3 (ISO 9141-2).",
"Base workhorse spec — expect a thin generic PID set. MAF, fuel-rate and EGR PIDs are usually not populated.",
"Modes 05 / 06 / 08 / 0A are generally unavailable. Deeper ABS / body / PCM diagnostics require Ford IDS / FoCOM-class tooling.",
"If the adapter sees voltage but refuses to negotiate, check pins 4/5 (ground), 7 (K-line) and 16 (+12V) — the OBD-II socket on PJ Rangers is notorious for corroded contacts.",
],
};
/**
* 2014 Tata Indica 1.4 petrol (Indica eV2 / Vista "Safire" — 475SI 56 MPFI).
*
* Evidence / reasoning:
* - The Indica 1.4 petrol has used a Tata 475SI MPFI engine since the
* early 2000s; by 2014 the eV2 facelift is still on that engine with a
* Hitachi-family ECU. Vista / Indigo CS "Safire" variants use a Bosch
* management system but share the same MPFI architecture.
* - This platform is K-line based — ISO 14230-4 (KWP2000) or ISO 9141-2
* over pin 7. CAN is not used for engine diagnostics on this generation.
* - Community reports (esp. on Indian / SA OBD forums) consistently note
* that generic ELM327 auto-detect frequently fails on the Indica; manual
* protocol selection (KWP Fast or ISO 9141-2) is usually required.
* - Base-spec MPFI — expect a thin generic PID set, MAP-based (no MAF),
* and no support for Mode 05 / 06 / 08 / 0A.
* - Known gotcha: the Indica's OBD-II port is behind the passenger
* footwell trim (not near the steering column) on many trims, and the
* ground pin is famously noisy — a flaky ELM327 clone will stall on
* initialisation even when the protocol is correct.
*/
export const TATA_INDICA_1_4_PETROL_PROFILE: VehicleProfile = {
id: "tata-indica-1.4-petrol-2014",
name: "Tata Indica 1.4 Petrol (2014, SA)",
description:
"Tata 475SI / Safire 1.4 MPFI (Indica eV2 / Vista). K-line diagnostics — KWP2000 Fast or ISO 9141-2. MAP-based, thin base-spec PID set.",
protocolStrategy: [
"auto",
"ISO_14230_4_KWP_FAST",
"ISO_14230_4_KWP",
"ISO_9141_2",
],
supportedPidBases: [0x00, 0x20],
expectedPids: [
0x01, // Monitor status / MIL
0x03, // Fuel system status
0x04, // Calculated engine load
0x05, // Coolant temperature
0x06, // Short-term fuel trim bank 1
0x07, // Long-term fuel trim bank 1
0x0b, // Intake manifold pressure (MAP)
0x0c, // Engine RPM
0x0d, // Vehicle speed
0x0e, // Ignition timing advance
0x0f, // Intake air temperature
0x11, // Throttle position
0x13, // Oxygen sensors present
0x1c, // OBD standard
],
optionalPids: [
0x14, 0x15, // O2 sensor bank 1 voltage / short-term trim
0x1f, // Run time since engine start
0x21, // Distance travelled with MIL on
0x2f, // Fuel level
],
unreliablePids: [
0x10, // MAF — Indica is speed-density / MAP-based
0x22, 0x23, // Fuel rail pressure — diesel/GDI oriented
0x2c, 0x2d, // EGR commanded / error — not on this base petrol spec
0x33, // Absolute barometric pressure
0x42, // Control module voltage — rarely populated on this ECU
0x46, // Ambient air temperature
0x5c, // Engine oil temperature
0x5e, // Engine fuel rate
],
weakModes: [
0x05, // O2 monitor test — not exposed generically on this ECU
0x06, // On-board monitor results — K-line era, typically empty
0x08, // Bidirectional control — not generically available
0x0a, // Permanent DTCs — post-dates this ECU's implementation
],
postInitCommands: [
"ATAT1", // Adaptive timing — essential for flaky K-line init
"ATST96", // ~600 ms timeout — Tata ECU is slow to first-byte
],
notes: [
"K-line only — do not waste time forcing CAN on this car.",
"Auto-detect is unreliable here. If 'Auto' fails, try protocol 5 (KWP Fast), then 4 (KWP 5-baud), then 3 (ISO 9141-2) from the dropdown.",
"Ignition must be in position 2 (key-on, engine on or off) before connecting — this ECU will not wake on accessory.",
"Base MPFI spec. Expect a thin PID list and no Mode 05 / 06 / 08 / 0A — that is normal, not a bug.",
"The OBD-II socket on Indicas is often behind the passenger footwell trim, not at the steering column. Check there before assuming the adapter is faulty.",
],
};
/**
* 2024 Hyundai H100 2.6 diesel (D4BB / D4BH) — South Africa spec.
*
* Evidence / reasoning:
* - The SA-market H100 ("bakkie") is still sold new in 2024 running the
* long-serving Hyundai 2.6 L D4BB / D4BH indirect-injection turbo-diesel
* — a Mitsubishi-derived architecture dating back to the 1980s, lightly
* updated for current emissions but still fundamentally pre-CRDi.
* - As a light commercial vehicle in SA, the H100 is **not required** to
* meet full EOBD. It has a 16-pin J1962 connector but, in the field,
* generic ELM327 adapters frequently fail to establish communication
* at all — Hyundai-specific tooling (HiCOM / HiScan / GDS) is often
* required for any real diagnostics.
* - Where generic communication *does* succeed, it is K-line based
* (Hyundai KWP2000 variants), not CAN, and the exposed PID set is very
* thin — core engine speed/temperature/load only.
* - Diesel semantics: no oxygen sensors, no fuel trims — those PIDs are
* permanently marked unreliable, not merely absent.
*
* Treat this profile as best-effort. Expect failures, and do not promise
* users that clearing DTCs or live data will work.
*/
export const HYUNDAI_H100_DIESEL_PROFILE: VehicleProfile = {
id: "hyundai-h100-2.6-diesel-2024",
name: "Hyundai H100 2.6 Diesel (2024, SA)",
description:
"D4BB / D4BH 2.6 L IDI turbo-diesel. Light commercial — limited EOBD compliance. K-line if it talks at all. Hyundai-specific tooling (HiCOM) often required for real work.",
protocolStrategy: [
"auto",
"ISO_14230_4_KWP_FAST",
"ISO_14230_4_KWP",
"ISO_9141_2",
],
supportedPidBases: [0x00, 0x20],
expectedPids: [
0x01, // Monitor status / MIL
0x04, // Calculated engine load
0x05, // Coolant temperature
0x0b, // Intake manifold pressure (MAP)
0x0c, // Engine RPM
0x0d, // Vehicle speed
0x0f, // Intake air temperature
0x1c, // OBD standard
],
optionalPids: [
0x11, // Throttle position — sometimes populated on electronically-
// governed diesels, sometimes not
0x1f, // Run time since engine start
0x21, // Distance travelled with MIL on
0x2f, // Fuel level
0x33, // Absolute barometric pressure
],
unreliablePids: [
// Petrol-era closed-loop PIDs — diesel does not expose these
0x03, // Fuel system status (diesel ECU rarely reports this meaningfully)
0x06, 0x07, 0x08, 0x09, // Short/long-term fuel trims (petrol only)
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, // O2 sensors
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, // Wide-range O2
0x10, // MAF — D4BB is MAP/speed-density, not MAF metered
0x22, 0x23, // Common-rail pressure — D4BB is IDI, not CRDi
0x2c, 0x2d, // EGR — not exposed on base H100 spec
0x42, // Control module voltage — unreliable on this ECU
0x46, // Ambient temperature
0x5c, // Engine oil temperature
0x5e, // Engine fuel rate
],
weakModes: [
0x02, // Freeze-frame — often returns no data even if Mode 03 works
0x05, // O2 monitor — diesel has no O2 sensors to test
0x06, // On-board monitor results — not exposed generically
0x08, // Bidirectional control — Hyundai-proprietary only
0x0a, // Permanent DTCs — not implemented on this ECU
],
postInitCommands: [
"ATAT1", // Adaptive timing — K-line is always fussy
"ATST96", // ~600 ms timeout — older diesel ECUs reply slowly
],
notes: [
"⚠ Generic ELM327 tools frequently cannot establish communication with the H100 at all. If the adapter refuses to negotiate on every protocol, it is not necessarily the adapter or this app — the H100 is not a fully EOBD-compliant vehicle.",
"For real diagnostics on this truck, consider Hyundai-specific tooling (HiCOM / HiScan / GDS) rather than generic OBD-II.",
"Engine must be running or key in position 2. Many H100s will not wake the diagnostic bus on accessory alone.",
"This is a diesel — no oxygen sensors, no fuel trims, no catalyst monitors. PIDs in those ranges are hidden by default; re-enable from Live Data if you specifically need to probe them.",
"If nothing responds, try forcing protocol 5 (KWP Fast), then 4 (KWP 5-baud), then 3 (ISO 9141-2) explicitly from the protocol dropdown.",
],
};
export const VEHICLE_PROFILES: VehicleProfile[] = [
GENERIC_PROFILE,
PEUGEOT_206_1_6_16V_PROFILE,
FORD_RANGER_PJ_2_2_PETROL_PROFILE,
TATA_INDICA_1_4_PETROL_PROFILE,
HYUNDAI_H100_DIESEL_PROFILE,
];
export function getProfile(id: string | null | undefined): VehicleProfile {
if (!id) return GENERIC_PROFILE;
return VEHICLE_PROFILES.find((p) => p.id === id) ?? GENERIC_PROFILE;
}