openpilot Port: CAN Bus Hacking + HIL Testing
Case Studies / Hi-Z Labs
Hi-Z Labs, LLC
Hi-Z Labs is a boutique software and electronics engineering company in Cleveland, Ohio, developing embedded devices, IoT prototypes, apps and systems integrations.
What problem did you solve?
I wanted openpilot, the open-source driver-assistance system, on a 2023 Jeep Renegade. Nobody had ported it to that car or to anything else on its platform. This was a self-funded engineering project to add support for a vehicle openpilot did not support.
The signals openpilot needs are spread over several CAN buses, and the bus that carries cruise-control state does not reach the driver-assistance camera. I had to reverse-engineer several buses at once and then test a gateway I built to bridge them, with an AI coding agent (Claude Code) running the instruments.
How did you solve it?
In the car, the CANsub.4 USB to CAN interface went on a harness at an inline connector near the radar. It recorded the main vehicle bus and the private radar-to-camera link on test drives, next to the openpilot device's own log. Its 1 µs hardware timestamps let us fit the two recordings to one clock within about 2.5 ms. One 60-minute drive produced 9.86 million frames, and every frame that carries a checksum passed it. The car's 41-message DBC file came out of those drives.
On the bench, the CANsub did hardware-in-the-loop (HIL) testing of the gateway. It stood in for the car on three channels, replayed captured traffic into the gateway at full vehicle rate and timed each frame through it. All 349,913 frames crossed, with a median latency of 390 µs. That let us test and prove safety figures for each gateway build before it went in the car. One of them is how long the gateway takes to hand the bus back to the car when openpilot's heartbeat stops, which measured 5.1 seconds. Everything ran through python-can over USB, in tools the coding agent wrote.
Before that, I tapped the OBD2 port with the CANsub.4 via a custom OBD2-to-DB25 cable, but it only carried UDS diagnostic requests, as the car's security gateway filters it. The gateway board itself has no hardware timestamps, so latency measurement was the CANsub's job. I have written the whole project up in a public worklog.
The replay above is host-controlled TX, where python-can schedules every frame on the PC and sends it via the CANsub's WebSocket API. The send times therefore inherit the PC's scheduling jitter, which is fine for a replay at vehicle rate. The latency figures are not affected, as both channels use 1 µs hardware timestamps.
For precise cyclic TX, the CANsub's on-device 'transmit sequences' achieve 10 µs edge-based precision, independent of the host and network. They are limited in e.g. the number of frames per sequence, though, so a full-drive replay stays host-controlled. Learn more in our CAN + Ethernet article.
Gateway latency, timed between two CANsub.4 channels
Claude Code ran the HIL test and reported 24 min later
"It is honestly wild how much I was able to accomplish with the CANsub.4 - despite knowing very little about how to actually use it"
The CANsub.4 on the bench with its harness and the gateway
What benefit has this led to?
The car went from no usable data to steering itself on the highway. The work was a handful of days spread over about eight weeks, and the car has dozens of engaged hours on it since. The agent drove the CANsub via python-can using the CANsub 'Docs for AI', so my time went to the car and the bench.
Why did you choose the CANsub.4?
Four CAN channels recorded at once with hardware timestamps, and full control from Python. It worked well both for listening to a live car and for driving a device under test on the bench.
— Aaron Heise, Embedded Systems Engineer, Hi-Z Labs
Ready to reverse engineer + test your CAN buses?
Get your CANsub.4 today!