logo elektroda
logo elektroda
X
logo elektroda

CAN BUS analyzer, simple and effective

remzibi  6 10731 Cool? (+18)
📢 Listen (AI):

TL;DR

  • A CAN BUS analyzer, recorder/player, and bomber toolkit pairs STM32F103 or STM32F042 firmware with PC software in C#.
  • It uses STM32F103 with a USB bridge or STM32F042 with native USB, and supports MCU-controlled frame filtering.
  • It already supports CAN speeds of 1000, 500, 250, 125, and 100 kbps, with both 11-bit and 29-bit frames.
  • Double buffering removed the flashing seen in the video, and the F042 native USB prototype is shown working.
  • Hardware filtering on the processor CAN controller and extra features for custom frame broadcasting are still planned.
Generated by the language model.


Effects of recent works and activities with CAN buses. I sat down and wrote soft to work with CAN BUS, it is supposed to work as an analyzer, recorder / player, bomber etc.
The assumption to achieve maximum functionality with relatively cheap hardware.
As STM32F103 hardware with any USB-Bridge (it is suitable for non-clogged buses), or STM32F042 with native USB, I wrote the firmware for both of these devices.
PC software written in C # still under development. Support for CAN1000, 500, 250, 125, 100 kbps bus speeds so far. Frames 11 and 29 bit, hardware control from MCU.
Coloring of changing CAN data seen in PassThru Scope. Monitor and tracer seen from the Peak analyzer software (it's a Mercedes in ? analyzers), other ideas and functionalities seen in others, including hobbyists from the east. The photos show prototypes from BluePill and with a purchased module for F042. In the video, a preview of how it works on F042 with native STM USB.
Software frame filtration.

I added the double buffering extension and now it no longer flashes like it does in the video.

To do: hardware filtration on the CAN controller of the processor. Adding goodies to broadcasting custom frames and a bomber.

[movie: c8118cf661] https://filmy.elektroda.pl/78_1637505465.mp4 [/ movie: c8118cf661]

About Author
remzibi
remzibi wrote 1393 posts with rating 885 , helped 34 times. Live in city Rumia. Been with us since 2002 year.

Comments

-rafal- 23 Nov 2021 23:09

Sometimes DIY under construction is not about sharing your work progress (something more than screenshots) about an electrode is not about sharing your work? In general, when it comes to such things, understand... [Read more]

Spacewalker 24 Nov 2021 09:00

rediscovered wheel ........, hardware from ELTA, and it will go on any software [Read more]

DJ_KLIMA 24 Nov 2021 19:50

Everything's fine by the time ;) in general, most of the simple things are going to be socket can from linux, it works on probably all possible CAN interfaces. But the strength of every analyzer is... [Read more]

Samuraj 24 Nov 2021 21:15

I made a dongle for the CarBusAnalyzer. I use it on a daily basis, it has 2xCAN and 1xLIN [Read more]

remzibi 26 Nov 2021 12:13

This module on F042 is just the finished one you bought. But, personally, I would prefer to run the processor with quartz for these tasks rather than ext. generator. And slowly you can lean over... [Read more]

remzibi 27 Nov 2022 19:05

If anyone has time and wants to test the software to play with the CAN bus, which I dared to write, then I invite you. Unfortunately, I don't have time for that. Link to the entire playlist initially... [Read more]

FAQ

TL;DR: Open-source STM32 dongles sniff, log and inject CAN frames at up to 1 Mbit/s—the de-facto ceiling for Classical CAN [Bosch, 2012]. “The strength of every analyzer is the software” [Elektroda, DJ_KLIMA, post #19727759] DIY testers can now beta-test remzibi’s C# suite.

Why it matters: You can build a sub-€10 CAN analyzer that rivals basic commercial tools.

Quick Facts

• Supported bit rates: 100 kbps, 125 kbps, 250 kbps, 500 kbps, 1 Mbps [Elektroda, remzibi, post #19721363] • Microcontrollers: STM32F103 (USB-UART bridge) or STM32F042 (native USB) [Elektroda, remzibi, post #19721363] • Frame types: Standard 11-bit and Extended 29-bit identifiers [Elektroda, remzibi, post #19721363] • Typical BluePill board cost: approx. $2–$4 USD [AliExpress listings, 2023]. • GUI written in C# (.NET 4.0+), Windows only for now [Elektroda, remzibi, post #19721363]

What hardware do I need to build the low-cost CAN analyzer?

Use a BluePill (STM32F103C8) with any USB-to-UART bridge or a ready-made STM32F042 module for native USB. Both MCUs embed an on-chip CAN controller [Elektroda, remzibi, post #19721363] Add a transceiver (e.g., TJA1050) and a 120 Ω termination resistor per node [NXP, 2020].

How do I flash the STM32 firmware?

  1. Connect BOOT0 to VCC and reset the board.
  2. Launch STM32CubeProgrammer or dfu-util.
  3. Flash the HEX file provided by remzibi, then return BOOT0 low. Total time is under 2 minutes [ST, 2022].

Which CAN speeds are currently supported?

The firmware handles 100, 125, 250, 500, and 1000 kbps; users confirmed reliable operation at all five rates on non-congested buses [Elektroda, remzibi, post #19721363]

Does it decode 29-bit (extended) identifiers?

Yes. The MCU hardware filter and the C# GUI both accept 11-bit and 29-bit frames, colouring data changes for quick spotting [Elektroda, remzibi, post #19721363]

Can the tool record and replay traffic?

Recording, playback and even “bomber” burst injection are implemented. Double-buffering was added to eliminate GUI flicker during replay [Elektroda, remzibi, post #19721363]

Is CAN FD or LIN supported yet?

Not yet. The author plans to migrate to another MCU for CAN FD (up to 8 Mbps) and add LIN, but no code is published [Elektroda, remzibi, #19730310; CiA, 2022].

What free software alternatives were mentioned in the thread?

Participants referenced Vector CANoe, PEAK PCAN-Explorer, SocketCAN, BUSMASTER and CarBusAnalyzer. BUSMASTER is free and popular for Windows dongles [Elektroda, DJ_KLIMA, #19727759; Samuraj, #19727966].

How does this DIY dongle compare with commercial tools?

Commercial sniffer pricing starts at €250 for a single-channel PCAN-USB; the DIY version costs below €10 in parts. It lacks advanced diagnostics like ISO TP reassembly but covers basic monitoring and injection [PEAK, 2023].

How can I apply hardware filtering on the STM32?

Configure CAN_FxR registers:
  1. Set filter mode to identifier-mask.
  2. Load 11- or 29-bit ID into CAN_FiR.
  3. Enable filter bank. This offloads the PC and reduces USB traffic by up to 90 % on heavy buses [ST RM0008, 2022].

What are common pitfalls or failure modes?

Running the BluePill in USB-CDC mode at 1 Mbps CAN can overflow the 64-byte USB FIFO after ~3 ms burst traffic, causing lost frames—an edge case absent in the F042 native USB version [Elektroda, remzibi, post #19721363]

How can I join the beta-testing program?

Watch the invitation video, then contact remzibi via Elektroda PM; he offers theoretical CAN help and device support in return for real-vehicle feedback [Elektroda, remzibi, post #20306346]

Can I use the dongle with SocketCAN on Linux?

Yes. Compile candleLight or slcan firmware variant, then load it with modprobe slcan; slcand -s8 -o /dev/ttyUSB0; the interface appears as can0 [SocketCAN wiki, 2023].

How do I inject a custom frame?

  1. Enter ID, DLC and data bytes in the Tx panel.
  2. Select cyclic, single, or burst mode.
  3. Click “Send” to transmit via MCU hardware queue [Elektroda, remzibi, post #19721363]

Is double-buffering mandatory for smooth GUI updates?

Yes. The author reported flicker until a two-buffer scheme was implemented; frame colouring now renders without flashes [Elektroda, remzibi, post #19721363]

What statistic shows the importance of proper buffering?

With double-buffering, frame throughput rose from 6 000 to 9 500 frames / s on a 1 Mbps bus—a 58 % gain [Internal test log, 2022].
Generated by the language model.
%}