askvity

How to Read CAN Bus Data

Published in CAN Bus Communication 4 mins read

Reading CAN bus data primarily involves decoding the raw, non-human-readable messages into meaningful physical values.

Raw CAN bus data, as it appears directly from the bus, is not human-readable. It consists of binary or hexadecimal values representing various signals and parameters. To interpret this data, you need to decode the CAN frames into scaled engineering values, also known as physical values (like km/h, degrees Celsius, engine RPM, etc.).

The Decoding Process

The process of making raw CAN data understandable typically involves two main components:

  1. A DBC File: A Database CAN file (.dbc) is a standard text file format used in the automotive industry and other sectors utilizing CAN. It acts as a dictionary for your specific CAN network. A DBC file contains definitions for:

    • CAN Message IDs: Unique identifiers for each message on the bus.
    • Signals: What data is contained within a specific message ID (e.g., vehicle speed, engine temperature).
    • Scaling and Offset: How to convert the raw data bits for a signal into a real-world physical value (e.g., physical_value = raw_value * scale + offset).
    • Units: The units for the physical value (e.g., km/h, °C).
    • Value Descriptions: Mapping raw integer values to specific states (e.g., 0=Off, 1=On).
  2. Software Tool: You need a software application or tool that can read the raw CAN data stream and apply the decoding rules defined in the corresponding DBC file. These tools can range from simple logging software to complex analysis platforms.

Steps to Read and Interpret CAN Data

Here's a general outline of how to go from raw CAN data to understandable information:

  1. Connect a CAN Interface: Use a hardware interface (like a USB-to-CAN adapter) to physically connect your computer or data logger to the CAN bus.
  2. Capture Raw Data: Use software compatible with your interface to capture the raw CAN messages flowing on the bus. This data will typically be displayed in a format like: Timestamp | CAN ID | Data Length Code (DLC) | Data (Hex).
    • Example Raw Data Line: 123.456 | 18F00400 | 8 | 01 8C 2A FF FE 00 00 00 (This line alone tells you little about what's happening).
  3. Load the DBC File: Open the captured raw data or configure your real-time monitoring tool to use the appropriate DBC file for the network you are reading.
  4. Decode the Data: The software uses the DBC file to look up each incoming or captured CAN ID. For each ID, it finds the defined signals within that message and applies the scaling, offset, and unit information to convert the raw data bytes into physical values.
  5. View Interpreted Data: The software will then display the data in a human-readable format, showing the signal name, its physical value, and units.
    • Example Interpreted Data: For the raw data above, after decoding with a DBC, the software might show: Timestamp: 123.456, Message: Engine Status, Signal: Engine Speed, Value: 2256 RPM and Signal: Vehicle Speed, Value: 45.2 km/h.

Why is Decoding Necessary?

Without decoding using a DBC file, raw CAN data is just a stream of numbers. You would not know:

  • Which message ID corresponds to which system (engine, brakes, etc.).
  • Which bytes within a message represent a specific signal (speed, temperature, pressure).
  • How to convert the raw integer value of a signal into a meaningful unit (e.g., converting a value of 8C hex to 140 decimal, and then knowing that 140 should be scaled to 45.2 km/h).

Therefore, having the correct DBC file and a suitable software tool is essential for reading and understanding CAN bus data.

Related Articles