Skip to content

Can bus

Neil Bajorin edited this page Jun 6, 2018 · 3 revisions

Learning the B-CAN Bus Codes

A CAN bus is used to network a modern car's inputs and functions together (Wikipedia). Honda uses multiple buses, and the B-CAN handles the majority of the non-critical functions including headlights and instrument panel (IP) dimmer.

A message on a CAN bus has two parts: an ID up to 29 bits in length and up to 8 bytes of data. We are looking to learn first which IDs are involved with each function. Then, we will try to decode the data to read the function’s state.

Reading the CAN BUS

The B-CAN has a connection point on the driver's side fuse panel. "Optional Connector B" is an unused 3-pin connector at the top of the fuse panel. CAN-H is pin 2 and CAN-L is pin 3 (passenger side). From here, connect CAN-H and CAN-L to the shield. More documentation for the shield is available on the Seeed Wiki.

Connector B

Optional Connector B. The green wire is CAN-H, white is CAN-L.

The example program receive_check was modified to run at 125 kbps and to handle extended IDs. It is available as can_logger.

Using can_logger, collect five seconds of codes in the Arduino Serial Monitor while the car is running. Copy the output into Excel to identify the differences in the codes when a new function is enabled, such as turning on the headlights. If each run is in a different sheet in the same workbook, a function such as =COUNTIF(Sheet1!D:D,D2) will return 0 if the code in D2 of the current sheet is not among any of the codes in column D of Sheet1. Note, we need to concatenate the ID and data to identify the unique combinations. For example, =CONCAT(B2, ": ", C2), where column B is the CAN ID and column C is the data packet.

Light Codes

The following codes were identified using the Excel method. The table shows three IDs and their data payloads for six states of the car’s lights. All numbers are written in hexadecimal.

State AF81110 AF87010 EF87372
E-Brake 80 00 00 00 00 00 (none) 04 44
Off 00 00 00 00 00 00 (none) 04 44
Parking 40 40 00 00 00 00 40 00 04 4F
Low Beam 42 40 00 00 00 00 50 00 04 89
High Beam 43 40 00 00 00 00 54 00 04 59
Front Fog 42 C0 00 00 00 00 50 20 04 91

We only need to focus on one ID since 0xAF81110 provides comprehensive state data.

Dimmer Codes

Excel identified 0x12F85450 as the ID which varied with the dimmer. The 1st and 6th bytes in the data packet match. Values vary from 0x41 to 0x55 before jumping to 0xD6 when the max/no-dimmer setting is reached.

Writing to the CAN Bus

Initially, I wrote lights_control in hopes of illuminating the rear fog indicator light on the IP by sending the correct code. Testing all possible data values for ID 0xAF81110 did reveal a headlight error indicator at 00 00 00 00 00 40, but no rear fog. This is actually a good thing, since the program also revealed another problem with writing to the bus: the codes are overwritten by the original codes causing the indicator lights to flash. However, lights_control is valuable in that it confirms our understanding of the codes.