Menu
andipanda.dev

CAN Box: Exploring CAN Messages and Emulating a Car on the Bench

In the first part, I explained what a CAN Box is, how it works, and why such a device can be useful when developing a custom car head unit.

Now it's time to move from theory to practice.

My initial goal was fairly simple: determine which messages need to be transmitted over the vehicle's CAN bus to make a CAN Box operate without being connected to a car.

At first, I was interested in just a few functions: enabling ACC, controlling illumination, and switching to the reversing camera.

However, the experiments revealed considerably more.

The result was a small software emulator capable of reproducing basic vehicle events directly on a workbench.

How It All Started

As a reminder, I received a G-VW-RZ-58 CAN Box with a Chinese Android head unit. This decoder is intended for Volkswagen, Skoda, and Seat vehicles.

Normally, devices like this connect to the vehicle's wiring, receive messages from the CAN bus, and translate them into commands understood by the head unit.

Finding information about CAN Box output protocols is relatively straightforward. UART protocol descriptions, command examples, and even ready-made implementations for certain head units are available online.

But I was interested in the other side of the communication.

Which CAN messages does the decoder actually receive?

Which identifiers control ACC, illumination, the reversing camera, and other functions?

And could I reproduce these messages myself without having a car nearby?

Those were the questions I set out to answer.

First Experiments

For the experiments, I used a Raspberry Pi with a CAN module based on the MCP2515 controller.

CAN communication was handled through the standard Linux SocketCAN interface, which supports transmitting and receiving CAN frames.

The device under investigation was the G-VW-RZ-58 CAN Box.

The head unit was connected to the decoder and used to verify the results.

This setup allowed me to transmit CAN messages and directly observe how the hardware responded.

The first task was ACC control.

For a car head unit, this signal is particularly important because it normally determines when the device should turn on or begin shutting down.

After a series of experiments, I managed to activate ACC through the CAN bus.

But before controlling the head unit, I had to understand how the CAN Box itself wakes up.

Waking Up the CAN Box

After power is applied, the CAN Box initially remains inactive and does not transmit any messages onto the CAN bus.

The first experiments showed that the device responds to activity on the bus.

As soon as I transmitted a CAN frame, the CAN Box began sending the following message:

439#1912010400000000

The transmission interval was approximately 270 ms.

Initially, I assumed that waking the device required a specific frame:

635#0000FD

However, further experiments showed that the CAN Box also responded to other messages:

635#000000
575#00000000
123#00000000

This demonstrated that different CAN frames could trigger an initial response from the device, regardless of their intended purpose.

Most likely, the CAN Box responds to the presence of CAN bus activity itself. It may use hardware wake-up capabilities of the CAN transceiver, although this cannot be confirmed without examining the circuit and firmware.

But there was an interesting detail.

Waking up the CAN Box and fully powering on the head unit turned out to be two different processes.

If the required message exchange does not follow the initial bus activity, the CAN Box stops transmitting its periodic 0x439 frame after approximately 11 seconds.

Fully starting the device and enabling ACC requires a particular sequence of messages.

Enabling ACC and Keeping the Device Active

During the manual experiments, I identified a sequence that reliably started the CAN Box after power was applied.

First, the following message must be transmitted several times:

635#000000

Then periodic transmission of this frame begins:

575#C7200020

With a transmission interval of 200 ms, the CAN Box activates ACC and the head unit turns on.

Further experiments showed that, once the device has started successfully, periodically transmitting 575#C7200020 is sufficient to keep ACC active.

The 0x635 identifier is also used to control the head unit's button illumination.

When I moved from manual experiments to writing the software emulator, I decided not to implement a separate startup procedure.

Instead, I arranged for all the required CAN messages to be transmitted periodically.

As a result, after applying power, simply starting the emulator is enough for the CAN Box to enter its operating state and activate ACC.

I verified this behavior on the actual hardware, including after completely disconnecting and restoring power to the CAN Box.

The experiments identified the following main CAN frames:

CAN ID Default payload Interval Purpose
0x635 00 00 00 200 ms Button illumination control
0x575 C7 20 00 20 200 ms Enable and maintain ACC
0x351 00 00 00 00 00 00 00 00 100 ms Reverse gear state
0x470 00 00 33 33 20 00 00 16 100 ms Door and trunk states
0x3C3 22 00 00 00 80 00 00 00 100 ms Dynamic parking guidelines

These are the identified messages, not the minimum set required to keep ACC active.

The other frames are used to control additional functions and reproduce vehicle events.

A more sophisticated solution might analyze the CAN Box's response messages and determine when the device is ready, rather than continuously transmitting a predefined set of frames.

However, since this was an experimental project, I decided not to complicate the software with additional communication logic.

The main objective was to achieve stable operation of the head unit on the workbench, without connecting it to a vehicle.

And that objective was achieved.

What Happens When CAN Traffic Stops

I also wanted to find out how the CAN Box behaves when CAN message transmission stops completely.

It turned out that the device does not disable ACC immediately.

Even after CAN traffic stops, the head unit continues running, and the CAN Box remains active for some time.

After approximately 10 minutes without communication, the device enters sleep mode and disables ACC, causing the head unit to turn off.

This differs from the behavior observed during a brief wake-up, when the CAN Box stops transmitting the 0x439 message after approximately 11 seconds if the required communication is absent.

Based on these observations, several states can be distinguished:

  1. Inactive state after power is applied.
  2. Brief wake-up triggered by CAN bus activity.
  3. Full operating mode with ACC enabled.
  4. Transition to sleep mode after an extended period without communication.

The emulator also provides a way to disable ACC directly, without waiting for the CAN Box to enter sleep mode.

ACC Control

ACC is controlled using a message with the identifier 0x575.

Enable:

575#C7200020

Disable:

575#10200000

During operation, the emulator periodically transmits the message corresponding to the current ACC state.

When the state changes, the payload is updated and the new frame is immediately transmitted onto the CAN bus.

Additionally, when the simulation stops, the program sends the ACC-off command three times at 10 ms intervals.

This makes it possible to control the head unit's power state independently of the CAN Box's automatic transition to sleep mode.

Illumination Control

The next task was to simulate switching on the vehicle's lighting.

This is handled by message 0x635.

The emulator supports two states.

Illumination off:

635#000000

Illumination on:

635#640164

When the state changes, the payload of the corresponding periodic message is updated.

The CAN Box responds to the change and passes the lighting state information to the head unit.

This makes it possible to test the head unit's button illumination without connecting it to a vehicle.

Reversing Camera

Another important function is switching to the reversing camera.

This uses a message with identifier 0x351.

Interestingly, only a single bit needs to be changed.

In my case, it is bit 1 of the first payload byte, corresponding to the 0x02 mask when counting bits from zero.

Reverse gear disengaged:

351#0000000000000000

Reverse gear engaged:

351#0200000000000000

When this bit is set, the CAN Box recognizes that reverse gear is engaged, and the head unit switches to the reversing camera view.

Clearing the bit returns the head unit to its normal mode.

This allowed me to fully reproduce reversing camera switching through the CAN bus.

Door and Trunk States

After verifying the basic functions, I decided to go a little further.

It turned out that the CAN bus could also be used to simulate opening and closing the vehicle's doors.

This functionality uses message 0x470.

The second payload byte contains bit flags corresponding to individual doors and the trunk.

I verified the following values:

Component Second-byte mask
Front left door 0x01
Front right door 0x02
Rear left door 0x04
Rear right door 0x08
Trunk 0x20

Changing a state only requires setting or clearing the corresponding bit.

These flags can also be combined.

For example, the front left and rear right doors can be opened simultaneously.

This makes it possible to reproduce different combinations of door states without physically opening any doors.

All these functions were tested with the connected head unit.

Dynamic Parking Guidelines

Another interesting task was controlling dynamic parking guidelines.

Unlike ordinary static guidelines, dynamic guidelines change their position according to steering wheel movement, helping the driver estimate the vehicle's expected path.

It turned out that the CAN Box could reproduce this behavior without being connected to a car.

This functionality uses CAN ID 0x3C3.

The emulator's default message looks like this:

3C3#2200000080000000

The second payload byte controls the position of the parking guidelines, counting bytes from zero.

During the experiments, I identified the following ranges:

Direction Second-byte values
Left 0x00 – 0x22
Right 0x80 – 0xA2

Controlling the guidelines only requires changing the second byte while leaving the remaining payload unchanged.

For example:

3C3#2200000080000000
3C3#220A000080000000
3C3#228A000080000000

The first message represents the initial position, the second moves the guidelines to the left, and the third moves them to the right.

In the emulator, the value changes step by step when the corresponding control keys are pressed.

The range is limited to experimentally verified values, and the most significant bit of the second byte selects the direction.

All these changes were tested with the connected head unit.

When the corresponding CAN messages were transmitted, the parking guidelines visibly changed position on the screen.

I did not attempt to establish an exact relationship between the transmitted values and the actual steering wheel angle.

For testing the CAN Box and head unit, reproducing guideline movement in both directions was sufficient.

Software Emulator

Once I had identified the main messages, I decided to combine them into a small program.

I wrote a Python script that communicates through SocketCAN on Linux.

Its primary purpose is to periodically transmit the required CAN messages while allowing individual states to be changed during operation.

The program supports selecting the CAN interface through a command-line argument and optionally displaying transmitted messages.

Internally, it uses a scheduler that can transmit multiple CAN messages at different intervals.

Timing is based on a monotonic clock, while the message queue is managed using heapq.

This makes it possible to maintain regular background transmissions while responding to user commands.

When a state changes, the corresponding CAN frame is transmitted immediately, after which its normal periodic transmission continues.

The emulator is controlled directly from the keyboard.

Key Action
1 ACC ON/OFF
2 Front left door
3 Front right door
4 Rear left door
5 Rear right door
6 Trunk
7 Illumination ON/OFF
8 Parking guidelines left
9 Parking guidelines right
r Reverse gear ON/OFF
0 Stop simulation
q Quit program

When a key is pressed, the program updates the relevant payload and continues transmitting the periodic messages.

For example, I can enable ACC, open a door, turn on illumination, activate the reversing camera, and change the position of the parking guidelines.

All of this works without connecting the equipment to a real car.

When the simulation stops, the program sends the ACC-off command and enters an idle state.

Pressing 1 again restarts the simulation.

I plan to publish the emulator's source code separately on GitHub once I have time to organize the repository and prepare the necessary documentation.

What I Achieved

The experiments allowed me to identify a set of CAN messages sufficient to simulate several basic vehicle events.

I verified:

  • Waking the CAN Box through CAN bus activity.
  • The startup sequence using messages 0x635 and 0x575.
  • Periodic transmission of the 0x439 response message.
  • The termination of 0x439 transmission when the required communication is absent.
  • The CAN Box entering sleep mode and disabling ACC approximately 10 minutes after CAN traffic stops.
  • Enabling and disabling ACC.
  • Continuous head unit operation through periodic CAN transmissions.
  • Switching illumination on and off.
  • Switching to the reversing camera.
  • Opening and closing all four doors.
  • Opening and closing the trunk.
  • Controlling dynamic parking guidelines.

All functions implemented in the emulator were tested on real hardware.

However, this investigation should not be considered a complete reverse engineering of the vehicle's CAN protocol.

I identified only the messages and values required for my particular objectives.

Furthermore, these results primarily apply to my G-VW-RZ-58 CAN Box and the hardware configuration used during testing.

Different vehicles, firmware versions, or decoders may behave differently.

A Note on Safety

When working with a vehicle's CAN bus, it is important to remember that transmitted messages may be processed not only by the head unit but also by other electronic control modules.

Therefore, transmitting arbitrary CAN frames directly onto a vehicle's network requires caution.

The emulator described here is intended primarily for bench testing a CAN Box and connected equipment.

The discovered messages should not be transmitted onto the CAN bus of a moving vehicle without understanding their purpose and potential consequences.

Conclusion

When I first opened the CAN Box enclosure, it seemed like an ordinary adapter between a car and a Chinese head unit.

But the investigation showed that its capabilities were considerably broader.

First, I figured out ACC control, then illumination and reversing camera switching, and later door states and dynamic parking guidelines.

I also discovered how the CAN Box wakes up after power is applied, which messages enable ACC, and how the device behaves when communication stops.

One particularly interesting finding was that the device does not disable ACC immediately when CAN traffic stops. Instead, it keeps ACC active for approximately another 10 minutes.

The result is a working software emulator capable of reproducing basic vehicle events on a workbench.

Of course, it could be extended further: additional CAN messages could be investigated, response analysis could be implemented, and more simulated events could be added.

But for my purposes, none of that is necessary anymore.

The main objective has been achieved: I can control the CAN Box and test the head unit without connecting it to a vehicle.

And perhaps the most interesting conclusion is that all it takes is a Raspberry Pi with a CAN module, a few correctly constructed messages, and a small program to transmit them periodically.

Now I have not only a better understanding of how the CAN Box works, but also a concrete set of verified commands that I can use in future experiments with CaRadio and other electronics projects.