ICM2
The ICM2 is the Infotainment Control Module in the 2003-2006 9-3 (9440). It sits between the two CAN buses, the dash top SID and the MOST optical ring, so it's the only thing in the car that talks to the radio side at all.
Everything below is read out of the factory GlobalTIS firmware, vip_icm2.gbf, SW part number 12782531 AA, build VIP405_ICM2-2.1.5.RC1. The CAN IDs, DLCs, periods and timeouts come straight from the message tables in the binary. The bit level stuff comes from the code that packs and unpacks the frames. Where a bit is only known as "this customization option goes here" the name is my guess, so treat the CustomOpt ones as placeholders.
Buses
The VIP (Vehicle Interface Processor) is a little endian NEC V850/SF1 running a cooperative task loop on a 10 ms tick.
| Interface | Physical | Speed | Role |
|---|---|---|---|
| Channel 0, P-bus | 2-wire HS CAN (ISO 11898) | 500 kbit/s | 26 RX IDs of powertrain and chassis data, 0x740 TX, and the diagnostic gateway to the MOST nodes |
| Channel 1, I-bus | Single wire CAN (GMLAN SWCAN) | 33.333 kbit/s | 67 RX IDs, 11 TX IDs: dimmer, buttons, customizations, clock set, network management, security |
| SID-HPD | UART on CAN wiring | 115200 baud | The dash top SID, 384x64 green LCD plus a 64x64 orange icon area. Checksum is the MSB of all the non-DLC bytes |
| O-bus (MOST25) | Plastic optical fibre ring | 22.5 MHz | Ring master for EHU, AMP1/AMP2, CD/CDC, DVD, CU/PU and the chimes and clicks |
In the firmware tables the 11-bit ID is shifted left 2 in the upper halfword of a 32-bit entry, so id = (word >> 18) & 0x7FF if you go digging yourself.
What the ICM2 sends
P-bus, 23 handles
Only one of them is a real message. The other 22 are diagnostic responses.
| Handle | ID | DLC | Period | Min delay | What |
|---|---|---|---|---|---|
| 0x00 | 0x740 | 6 | 3000 ms | 100 ms | Menu/aux status, same frame goes out on the I-bus as handle 0x17 |
| 0x01-0x0A | 0x65A-0x651 | 8 | event | USDT responses for the MOST nodes, answering 0x25A-0x251 | |
| 0x0B | 0x647 | 8 | event | ICM2's own USDT response, answering 0x247 | |
| 0x0C-0x15 | 0x55A-0x551 | 8 | event | UUDT responses for the MOST nodes, DTC and DPID streaming | |
| 0x16 | 0x547 | 8 | event | ICM2's own UUDT response |
I-bus, 11 handles
| Handle | ID | DLC | Period | Min delay | What |
|---|---|---|---|---|---|
| 0x17 | 0x740 | 6 | 3000 ms | 100 ms | Menu/aux status, mirrors the P-bus one |
| 0x18 | 0x670 | 8 | event | 100 ms | Clock and date write command to the BCM |
| 0x19 | 0x647 | 8 | event | USDT diagnostic response, answering 0x247 | |
| 0x1A | 0x627 | 8 | 3000 ms | GMLAN virtual network management, node 0x07 | |
| 0x1B | 0x547 | 8 | event | UUDT diagnostic response | |
| 0x1C | 0x460 | 5 | 1000 ms + event | 100 ms | Illumination, dimmer, ambient light, night panel |
| 0x1D | 0x310 | 8 | 3000 ms + event | 100 ms | ESP button, service reset, customizations |
| 0x1E | 0x200 | 5 | event | 200 ms | Aux status/command |
| 0x1F | 0x135 | 1 | 100 ms | 50 ms | Variant switch status, 0x00 on a plain sedan |
| 0x20 | 0x100 | 0 | event | SWCAN high voltage wakeup, empty frame | |
| 0x21 | 0x045 | 8 | event | 50 ms | Infotainment security / marriage response to the CIM's 0x040 |
What the ICM2 listens for
P-bus, 26 handles
| ID | DLC | Timeout | Used for |
|---|---|---|---|
| 0x742 | 8 | event | Transport RX |
| 0x741 | 8 | event | Transport RX |
| 0x518 | 2 | 2500 ms | b1 |
| 0x510 | 2 | 2500 ms | b1 |
| 0x380 | 8 | 250 ms | (b7 & 0x1F) >> 4 |
| 0x320 | 6 | 250 ms | b5[7:2], b3[0] is a SID warning |
| 0x301 | 1 | 250 ms | b0[3] SID warning |
| 0x300 | 2 | 250 ms | b1[7] driving state |
| 0x2F0 | 3 | 250 ms | b0[0] and b2[4] driving lockout, b0[1], b1[5], b2[5] SID warnings |
| 0x290 | 8 | 250 ms | Four 14-bit ESP/chassis values, ((hi & 0x3F) << 8) | lo, valid bit is hi[7] |
| 0x280 | 8 | 50 ms | Four 15-bit wheel speeds, ((hi & 0x7F) << 8) | lo, valid bit is hi[7] |
| 0x25A-0x251 | 0 | Physical diagnostic requests, bridged to the MOST nodes | |
| 0x247 | 0 | ICM2's own physical diagnostic request | |
| 0x180 | 4 | 30 ms | 16-bit BE (b2 << 8) | b3, valid bit b0[6] |
| 0x120 | 3 | 30 ms | 12-bit (b1 << 4) | (b2 >> 4), valid bit b0[7] |
| 0x110 | 4 | 30 ms | 16-bit BE (b1 << 8) | b2, valid bit b0[7]. b3 > 204 is a driving lockout |
| 0x101 | 8 | Functional diagnostic broadcast |
I-bus, 67 handles
| ID | DLC | Timeout | Used for |
|---|---|---|---|
| 0x75B, 0x74E, 0x745, 0x741 | 8 | Multiframe / extended data | |
| 0x700, 0x690 | 8 | ASCII VIN. 0x690 is characters 2-9, 0x700 is 10-17 | |
| 0x680 | 8 | Extended vehicle configuration | |
| 0x582-0x570 | 1 | 19 node alive monitors. Healthy is (b0 >> 5) == 1, so 0x20 | |
| 0x535 | 3 | 2500 ms | Fuel level and warnings |
| 0x532 | 3 | 2500 ms | b0[4] and b0[3] SID warnings |
| 0x530 | 7 | 2500 ms | TPMS, four 3-bit corner states in b0 and b1. 2 is low, 3 is flat |
| 0x520 | 6 | 2500 ms | BCM clock. b0 year +2000, b1 month, b2 day, b3 hour, b4 minute, b5[6:0] second, b5[7] set means not set |
| 0x500 | 3 | 7500 ms | b0[1] SPA / external audio mute request |
| 0x490 | 2 | 7500 ms | Five door/trunk/hood ajar bits. FL and FR swap on the LHD/RHD bit from 0x210 |
| 0x481 | 1 | 7500 ms | Security / anti theft status |
| 0x480 | 1 | 7500 ms | b0[0] immobilizer / key not accepted |
| 0x470 | 1 | 7500 ms | Body status, 0x00 idle |
| 0x450 | 5 | 2500 ms | Odometer and trip, feeds the service interval counter |
| 0x445 | 4 | 2500 ms | Outside temperature |
| 0x440 | 3 | 7500 ms | 13 body, alarm and lighting warning bits across b0-b2 |
| 0x430 | 1 | 3000 ms | b0[3], gated on the powertrain |
| 0x400 | 3 | 2500 ms | Climate / ACC status |
| 0x390 | 4 | 7500 ms | b0[1], gated on ignition |
| 0x380 | 6 | 7500 ms | b0[5] (0x20) brake switch, b1-b3 bulb and body warnings |
| 0x370 | 3 | 7500 ms | b1[7] (0x80) parking lights or headlights on, this is the dimmer gate. b0[3], b1[2:0], b2[7:5] reverse, fog and bulb out |
| 0x350 | 3 | 7500 ms | b2[5] |
| 0x340 | 3 | 7500 ms | b2[5] |
| 0x330 | 2 | 7500 ms | b0[1] |
| 0x320 | 6 | 7500 ms | BCM lock and door status, b5[6] warning |
| 0x300 | 2 | 2500 ms | Light switch, 00 10 / 00 20 / 00 00. b1[3] warning |
| 0x290 | 5 | 2500 ms | Turn signal stalk, b4 & 0x40 left, b4 & 0x80 right |
| 0x247 | 0 | ICM2 physical diagnostic request, this is where Tech 2 and SPS come in on the I-bus | |
| 0x230 | 1 | 7500 ms | b0[7] warning, b0[6:4] gear/shift display |
| 0x220 | 8 | 7500 ms | Steering wheel angle and status, b0[1] and b0[3] |
| 0x211 | 4 | Turn signal click trigger. b2 & 0xC0, 0xA8 left and 0x54 right, b3 >> 1 is the on time in 10 ms ticks | |
| 0x210 | 8 | 7500 ms | b5[7] LHD/RHD, b4[6:3] == 3 variant button mode, b0/b1/b5/b7 SID warnings |
| 0x190 | 1 | 2500 ms | b0[7] and b0[6] |
| 0x183 | 3 | b0[7:6] == 1 and b0[5] gate the b0[4:2] warnings | |
| 0x180 | 5 | 2500 ms | Transmission / drivetrain |
| 0x170 | 3 | 7500 ms | Coolant temp and service flags. b0[3:0], and b2 == 0xFF is the service reset ack |
| 0x160 | 1 | 2500 ms | b0[0] and b0[4] |
| 0x140 | 5 | 2500 ms | Ignition / crank status |
| 0x108 | 6 | 2500 ms | Powertrain gate. b0[0] engine running, b0[2:1] of 1 or 2 gates the oil and coolant alerts |
| 0x101 | 0 | Functional diagnostic broadcast | |
| 0x091 | 4 | 2500 ms | b1[7] (0x80) brake switch, b0[3:2], b1[4,1,0] and b3[7:5,1] warnings |
| 0x090 | 1 | 2500 ms | ISM status, b0[6] warns after a 100 tick ignition settle |
| 0x070 | 2 | 2500 ms | b0[7] and b0[5] |
| 0x060 | 3 | 2500 ms | Ignition and battery. b0:b1 is 0000 off, 4000 key in, 0020 lock/acc, 0060 on, 00A0 run. b2 is battery voltage |
| 0x040 | 8 | CIM security / marriage challenge, answered on 0x045 |
Frame layouts
0x460, illumination and night panel, I-bus, DLC 5
Every 1000 ms, and right away on any change with 100 ms minimum between frames.
| Byte | Bits | Signal | Notes |
|---|---|---|---|
| 0 | 7 (0x80) | AmbientInvalid | 0 means b3 is good, 1 means the sensor is faulty |
| 0 | 6 (0x40) | NightPanelActive | 1 is night panel on |
| 0 | 5:0 | 0 | |
| 1 | 7:0 | ClusterBrightness | 0x00-0xFF. Forced to 0x00 when the exterior lights are off, 0x370 b1[7] clear |
| 2 | 7:0 | SwitchBrightness | 0x00-0xFF. Follows b1 at night, scaled down in night panel, 0x00 with the lights off |
| 3 | 7:0 | AmbientLightLevel | Filtered reading off the dash phototransistor |
| 4 | 7:0 | DisplayBrightness | LCD and SID-HPD. Rheostat plus ambient through a LUT, hysteresis on every change except dropping to 0x00 |
Full brightness, night panel off: 00 FF FF 03 FC. Dimmed with night panel on: 40 40 20 03 40.
0x310, ESP button, service reset and customizations, I-bus, DLC 8
Every 3000 ms, and right away on a button edge or a menu change, 100 ms minimum.
| Byte | Bits | Signal | Notes |
|---|---|---|---|
| 0 | 7 (0x80) | AuxToggleInvalid | Validity for b5[5], 0 is valid |
| 0 | 6 (0x40) | AuxFlagInvalid | Validity for b5[4], 0 is valid |
| 0 | 5:4 (0x30) | UnitConfig | 1 or 2, the display and climate unit system |
| 0 | 3 (0x08) | CustomOpt_0 | 0 or 1 |
| 0 | 2:1 (0x06) | CustomOpt_1 | 0b00 or 0b11 |
| 0 | 0 (0x01) | ServiceResetReq | 1 asks for a service reset, cleared when 0x108 is online and 0x170 b2 reads 0xFF |
| 1 | 5 (0x20) | CustomOpt_2 | Speed warning / alarm option |
| 1 | 4 (0x10) | CustomOpt_3 | 0 or 1, default 0 |
| 1 | 2 (0x04) | CustomOpt_4 | 0 or 1 |
| 1 | 0 (0x01) | EspOffButton | Live state of the dash ESP/TCS OFF switch, 1 while held |
| 2 | 7:0 | 0x00 | |
| 3 | 7:6 (0xC0) | CustomOpt_5 | 0 or 1, factory 1 so 0x40 |
| 3 | 4:2 (0x1C) | CustomOpt_6 | 0, 1 or 4, default 0 |
| 3 | 1:0 (0x03) | CustomOpt_7 | 1 or 2, factory 2 |
| 4 | 6 (0x40) | CustomOpt_8 | 0 or 1, factory 1 |
| 4 | 5 (0x20) | CustomOpt_9 | 0 or 1, default 0 |
| 4 | 4:2 (0x1C) | CustomOpt_10 | 2, 3 or 4 |
| 5 | 5 (0x20) | AuxBtnToggle | Latched by the secondary dash switch when 0x210 b4[6:3] != 3 and ignition is on. Clears when the ignition goes off |
| 5 | 4 (0x10) | AuxFlag | Paired with the b0[6] validity bit |
| 5 | 3:2 (0x0C) | AuxMode2Bit | 2-bit mode request 0-3, holds VN 0x0B awake 6 s on a change |
| 6 | 7:4 (0xF0) | DoorLockMask | 3-bit XOR customization mask, default 0x00 |
| 7 | 7:4 (0xF0) | AuxStatusFlags | Two value/validity pairs, b7[7]/b7[6] and b7[5]/b7[4] |
Factory default idle payload: 00 00 00 42 40 00 00 00.
0x670, set the clock, I-bus, DLC 8
Event only, 100 ms minimum.
| Byte | Bits | Field | Encoding |
|---|---|---|---|
| 0 | 7:5 | CommandMode | (cmd & 0x07) << 5, 1 sets clock and date |
| 0 | 4:0 | 0x00 for a normal set | |
| 1 | 7:3 | 0x00 for a normal set | |
| 2 | 7:0 | Year | Years since 2000, so 2026 is 0x1A |
| 3 | 7:4 | Month | (month & 0x0F) << 4, December is 0xC0 |
| 4 | 7:3 | Day | (day & 0x1F) << 3 |
| 5 | 7:3 | Hour | (hour & 0x1F) << 3 |
| 6 | 7:2 | Minute | (minute & 0x3F) << 2 |
| 7 | 7:2 | Second | (second & 0x3F) << 2 |
| 7 | 1 (0x02) | InvalidFlag | 0 is valid |
0x627, network management, I-bus, DLC 8
One frame with b0 = 0x01 the moment a virtual network goes active, then b0 = 0x00 every 3000 ms while it stays active. Stops on sleep so the bus times out after 8000 ms.
| Byte | Value | Meaning |
|---|---|---|
| 0 | 0x01 / 0x00 | 0x01 initial activation, 0x00 keep alive |
| 1 | bitmask | Virtual networks 0-7 the ICM2 (node 0x07) wants up |
| 2 | bitmask | Virtual networks 8-11 |
| 3-7 | 0x00 | Padding |
0x045, marriage response, I-bus, DLC 8
Event only, 50 ms minimum, sent in answer to the CIM's 0x040 whenever that frame has b1 & 0x40 set.
| Byte | Field | Values |
|---|---|---|
| 0 | Status | 0x01 married / code present, 0x02 blank |
| 1 | NodeMask | 0x40, the ICM2 |
| 2:3 | ResponseCode | 16-bit BE stored response code, 0x0000 if blank |
| 4 | 0x00 | |
| 5 | SubStatus | 0x00 married and verified, 0x01 married flag set but codes blank, 0x02 unmarried with a code present, 0x03 unmarried and blank |
| 6:7 | 0x00 0x00 |
The rest
- 0x740, both buses, DLC 6, 3000 ms plus event. Menu and aux. Idle is all zeroes.
- 0x135, I-bus, DLC 1, 100 ms. Only does anything on
0x210 b4[6:3] == 3variants, b0[6] and b0[5]. Idle is 0x00. - 0x200, I-bus, DLC 5, event. b1[5:4] is a 2-bit status, b2 and b3 are parameters.
- 0x100, I-bus, DLC 0, event. Empty high voltage wakeup frame to wake a sleeping I-bus.
How it behaves
Ignition and sleep
The CIM walks 0x060 b0:b1 through 00 00 off, 40 00 key in, 00 20 lock/acc, 00 60 on, 00 A0 run. On wake the ICM2 fires the wakeup frame 0x100, sends 0x627 with b0 = 0x01, then keeps it alive with 0x00 every 3000 ms. When 0x060 goes back to 00 00 and all the virtual networks clear it stops sending 0x627, 0x460, 0x310 and 0x135, and the I-bus sleeps 8000 ms later.
Dimming and night panel
It watches 0x370 b1[7] for the exterior lights along with its own phototransistor, rheostat and the night panel switch. With the lights off the cluster and switch brightness bytes go to 0x00 but the display brightness keeps running off the daytime ambient LUT. 0x460 goes out every second and immediately on any change, and that's what drives the MIU, the interior switches, the SID and the MOST displays.
The clock
The BCM owns the clock and is the only thing sending 0x520, once a second. After a battery disconnect it starts ticking from 2000-01-01 00:00:01 with b5[7] set to say it's never been set. The ICM2 never sends 0x520. When you set the time it sends one 0x670, the BCM takes it, clears b5[7] and broadcasts the new time.
Buttons
It scans the front button matrix, the steering wheel resistor ladder and the rotary encoders. ESP OFF held sets 0x310 b1[0]. A customization menu change gets written to NVM and broadcast on 0x310. A service reset holds 0x310 b0[0] until 0x108 is live and 0x170 b2 reads 0xFF.
Turn signal click
0x211 from the CIM/BCM carries b2 = 0xA8 for left, 0x54 for right, 0x00 for off, and b3 is the blink half period. Click on when b2 & 0xC0 is non zero, then count down b3 >> 1 ticks at 10 ms each and click off, so 0x43 is 330 ms. Nothing goes back out on CAN, the click is audio only, over MOST on a factory car. 0x500 b0[1] is the mute request for SPA and chimes.
SID warnings
There are 92 warning conditions in there, all gated on the ignition state and on 0x108 b0[0] for engine running. The inputs are 0x490 for the five door, trunk and hood bits with front left and right swapped by the LHD/RHD bit, 0x530 for the four TPMS corners, 0x440, 0x380 and 0x370 for lighting and body faults, and 0x570-0x582 for the 19 node alive monitors that each want b0 >> 5 == 1. Output is text and icons on the local LCD and the SID, plus the chimes.
Marriage, 0x040 to 0x045
On key insert or unlock the CIM broadcasts an 8-byte challenge on 0x040: b0 is the command, 0x00 verify and 0x03 divorce, b1 is the target mask with 0x40 meaning the ICM2, and b2:b3 is the 16-bit vehicle secret.
If the secret matches what the ICM2 has stored it clears its mismatch flag, passes the security DTC and answers 01 40 <RespHi> <RespLo> 00 00 00 00. If it doesn't match it sets the mismatch flag, logs a DTC and ignores 0x040 for 60 seconds (6000 ticks). If it's unmarried or blank it processes the incoming code and answers with b5 set to 0x01, 0x02 or 0x03.
Diagnostics, 0x247 to 0x647 and 0x547
Plain ISO 15765-2: 0x0N single frame, 0x1N first frame, 0x2N consecutive, 0x30/0x31 flow control. Max payload is 255 bytes on the I-bus and 266 on the P-bus. The session times out after 5.04 s (504 ticks) without a 0x3E.
The interesting part is that the write and security services are blocked on the I-bus. They only work from the P-bus or from MOST.
| SID | Service | Allowed on |
|---|---|---|
| 0x04 | ClearDiagnosticInformation | P, I, O |
| 0x10 | InitiateDiagnosticOperation | P, I, O |
| 0x1A | ReadDataByIdentifier | P, I, O |
| 0x20 | ReturnToNormalMode | P, I, O |
| 0x23 | ReadMemoryByAddress | P and O only |
| 0x27 | SecurityAccess | P and O only |
| 0x28 | DisableNormalCommunication | P, I, O |
| 0x34 / 0x36 | RequestDownload / TransferData | P and O only |
| 0x3B | WriteDataByIdentifier | P and O only |
| 0x3E | TesterPresent | P, I, O |
| 0xA2 | ReportProgrammedState | P and O only |
| 0xA5 | ProgrammingMode | P, I, O |
| 0xA9 | ReadDiagnosticInformation | P, I, O |
| 0xAA | ReadDataByPacketIdentifier | P, I, O |
| 0xAE | DeviceControl | P and O only |
There are 64 DTC slots with an active/history mask of 0x7E. On a 0xA9 each matching DTC streams on 0x547 as 81 <DTC hi> <DTC lo> <symptom> <status> and the list ends with 81 00 00 00 7E. Periodic count updates come as 82 00 <count>.
Replacing the ICM2
The minimum to keep the car happy
| Bus | ID | When | What it has to do |
|---|---|---|---|
| I-bus | 0x460, DLC 5 | 1000 ms + change | Dimmer, ambient and night panel. Gate b1 and b2 to 0x00 when 0x370 b1[7] is clear |
| I-bus | 0x310, DLC 8 | 3000 ms + change | 00 00 00 42 40 00 00 00 or the user's settings, b1[0] for ESP OFF, b0[0] for a service reset |
| I-bus | 0x627, DLC 8 | 3000 ms while awake | 01 00 ... on wake then 00 00 ... every 3 s while 0x060 isn't 00 00. Has to stop with the ignition off or the bus never sleeps |
| I-bus | 0x670, DLC 8 | event | One frame to set the BCM clock when 0x520 b5[7] is set or the user edits the time. Never send 0x520 yourself |
| I-bus | 0x045, DLC 8 | on 0x040 | 01 40 <RespHi> <RespLo> 00 00 00 00 when b1 & 0x40 and the secret matches |
| I-bus | 0x211, RX | event | Make the turn signal click yourself from b2 & 0xC0 and b3 >> 1 if the factory MOST audio is gone |
| P-bus | listen only | No powertrain module needs anything from the ICM2 to start or run the car. Keep it passive unless you want Tech 2 diagnostics or the virtual O-bus |
Marrying and unmarrying
You can grab your car's pair without a Tech 2. Log 0x040 and 0x045 on the I-bus once with the factory ICM2 still married in the car. The 16-bit vehicle secret is 0x040 b2:b3 when b1 & 0x40 is set, the response code is 0x045 b2:b3. Store both with married = true.
For the real thing, listen on P-bus 0x247 and answer on 0x647 and 0x547, and support 0x10, 0x3E, 0x27, 0x1A, 0x3B, 0xAE, 0xA9 and 0x04. Tech 2's Remove, or a 0x040 with b0 = 0x03, clears married and zeroes both codes so the unit goes back to delivery state, 0x045 b0 = 0x02 and b5 = 0x03.
Faking the whole MOST ring
Nothing else in the car is on the optical ring. Not the CIM, not the BCM, the MIU, the T8, the TCM or the ABS. The ICM2 is the only gateway to it, so if you pull the ring, the EHU and the amps you can make the car and a Tech 2 believe there's a healthy ring in there purely in software.
Two things to get right. Never set a ring break or missing slave DTC in your own DTC table, always answer 0xA9 with 81 00 00 00 7E. And when Tech 2 scans the infotainment modules it sends normal GMLAN requests to P-bus 0x251-0x25A, so instead of bridging those to fibre, answer them yourself on 0x651-0x65A (USDT) and 0x551-0x55A (UUDT) for whichever nodes the CIM's module list says the car has.
Code
The packing for 0x460, 0x310, 0x627 and 0x670 is just the bit tables above, so here's only the two bits with actual logic in them.
/* I-bus 0x040 -> 0x045 marriage handler */
typedef struct {
bool married;
uint16_t vehicle_secret; /* expected in 0x040 b2:b3 */
uint16_t response_code; /* sent in 0x045 b2:b3 */
} icm2_marriage_t;
static bool icm2_handle_0x040(icm2_marriage_t *m, const uint8_t rx[8],
uint8_t tx[8]) {
if ((rx[1] & 0x40u) == 0u) return false; /* not for us */
uint8_t cmd = rx[0];
uint16_t rx_secret = (uint16_t)((rx[2] << 8) | rx[3]);
bool codes_ok = m->vehicle_secret != 0x0000u && m->vehicle_secret != 0xFFFFu &&
m->response_code != 0x0000u && m->response_code != 0xFFFFu;
if (cmd == 0x03u) { /* divorce */
m->married = false;
m->vehicle_secret = 0x0000u;
m->response_code = 0x0000u;
return false;
}
if (cmd != 0x00u) return false;
memset(tx, 0, 8);
tx[1] = 0x40u;
if (m->married && codes_ok) {
if (rx_secret != m->vehicle_secret) return false; /* 60 s lockout, no reply */
tx[0] = 0x01u;
tx[2] = (uint8_t)(m->response_code >> 8);
tx[3] = (uint8_t)(m->response_code & 0xFFu);
return true;
}
tx[0] = codes_ok ? 0x01u : 0x02u;
tx[2] = codes_ok ? (uint8_t)(m->response_code >> 8) : 0x00u;
tx[3] = codes_ok ? (uint8_t)(m->response_code & 0xFFu) : 0x00u;
tx[5] = m->married ? 0x01u : (codes_ok ? 0x02u : 0x03u);
return true;
}/* P-bus 0x251-0x25A -> 0x651-0x65A / 0x551-0x55A
* Answers for virtual MOST nodes with no ring in the car.
* node_mask bit (id - 0x251) enables that node. */
static bool icm2_virtual_obus(uint16_t id, const uint8_t rx[8],
uint16_t node_mask, uint16_t *out_id,
uint8_t out[8]) {
if (id < 0x251u || id > 0x25Au) return false;
uint8_t slot = (uint8_t)(id - 0x251u);
if ((node_mask & (1u << slot)) == 0u) return false; /* car doesn't have it */
if ((rx[0] & 0xF0u) != 0x00u) return false; /* single frames only */
uint8_t sid = rx[1];
memset(out, 0, 8);
if (sid == 0xA9u) { /* ReadDTC, always say zero DTCs */
*out_id = (uint16_t)(0x551u + slot);
out[0] = 0x81u;
out[4] = 0x7Eu;
return true;
}
*out_id = (uint16_t)(0x651u + slot);
switch (sid) {
case 0x3Eu: out[0] = 0x01u; out[1] = 0x7Eu; return true; /* TesterPresent */
case 0x10u: out[0] = 0x01u; out[1] = 0x50u; return true; /* InitiateDiag */
case 0x20u: out[0] = 0x01u; out[1] = 0x60u; return true; /* ReturnToNormal */
case 0x04u: out[0] = 0x01u; out[1] = 0x44u; return true; /* ClearDTC */
case 0x28u: out[0] = 0x01u; out[1] = 0x68u; return true; /* DisableNormalComm */
default:
out[0] = 0x03u; out[1] = 0x7Fu; out[2] = sid; out[3] = 0x11u;
return true;
}
}A 0x1A read gets 0x5A <DID> <data>, or 7F 1A 31 for a DID you haven't implemented.