CAN Configuration from a DBC File

General A DBC file

Start from the C++ CAN demo and fill its CAN configuration from a DBC file, using the Control Extension's Create from DBC.

Watch video walkthrough

The Ahsoka.CPP.CAN demo is a C++ project that sends and receives CAN messages through the Control Extension. Its CAN configuration — the messages, signals and nodes — is kept in a CANServiceConfiguration.json file. If your CAN network is already described in a DBC file, Create from DBC builds that configuration from it, so you don't enter each message by hand. This example does it with a small DBC file, TestFile.dbc, that has messages such as DRIVER_HEARTBEAT, MOTOR_CMD and SENSOR_SONARS.

The CAN Setup panel after loading TestFile.dbc: the DBC file's messages are listed
The CAN Setup panel after loading TestFile.dbc: the DBC file's messages are listed

Download the DBC file used here (can-dbc.zip)

Before you start:

  • The toolkit set up and signed in — see Quick Start.
  • A DBC file for your CAN network — here, TestFile.dbc from the download above, saved as C:\Projects\OpenPV\Demo\TestFile.dbc.
  • On a PC with no .NET SDK, the DbcParserLib 1.8.0 package, added by hand — see the first step of Create the CAN Configuration from the DBC File.

Create the Project

  1. On the toolbar, click New.... Under Control, select Ahsoka.CPP.CAN (C++, "Project demonstating CAN usage in C++") and click Next.

    Ahsoka.CPP.CAN selected under Control in Create New Project
    Ahsoka.CPP.CAN selected under Control in Create New Project
  2. On Configure Project, click Choose Path... and pick where to create the project — here, C:\Projects\OpenPV\Demo. Folder Name matches the template, Ahsoka.CPP.CAN.

    Configure Project, with the project path set
    Configure Project, with the project path set
  3. Open Selected Platform and choose the platform you want — here, Ahsoka.CPP.CAN.Select. Then click Create.

    The Selected Platform choices, and the Create button
    The Selected Platform choices, and the Create button
  4. If SDK Update Needed appears, click Yes, so the project builds against the current SDK.

    SDK Update Needed
    SDK Update Needed
  5. A Project Created message confirms the folder — here, C:\Projects\OpenPV\Demo\Ahsoka.CPP.CAN. Click Ok.

    Project Created
    Project Created

Create the CAN Configuration from the DBC File

  1. If your PC has no .NET SDK, add the DBC parser by hand before you use Create from DBC. The Control Extension needs the DbcParserLib 1.8.0 package, and a PC with no SDK can't fetch it for you:

    1. Download dbcparserlib.1.8.0.nupkg from nuget.org — click Download package on that page.
    2. A .nupkg file is a zip file. Unzip it into %USERPROFILE%\.nuget\packages\dbcparserlib\1.8.0\, creating the folders if they don't exist. If Windows won't open the file, rename it to .zip first.
  2. Click the Extensions tab. The demo already has the Control Service Extension, which provides CAN and IO.

    The Extensions tab, with the Control Service Extension listed
    The Extensions tab, with the Control Service Extension listed
  3. Click Control Service Extension to select it, then click Configure Extension....

    The Control Service Extension selected, and the Configure Extension button
    The Control Service Extension selected, and the Configure Extension button
  4. CAN Setup opens with the demo's starter configuration, including a TestMessage. CAN Actions, on the right, works on the whole configuration. Click Create from DBC....

    CAN Setup, with the Create from DBC button
    CAN Setup, with the Create from DBC button
  5. Pick DBC Calibration opens in the Demo folder, C:\Projects\OpenPV\Demo, where the DBC file is. Select the DBC file — here, TestFile.dbc — and click Open.

    Pick DBC Calibration, with TestFile.dbc selected and the Open button
    Pick DBC Calibration, with TestFile.dbc selected and the Open button
  6. The toolkit opens the Console and builds the configuration. Create Completed at CANServiceConfiguration.json means it's done.

    Note: The configuration replaces the starter one, in the CANServiceConfiguration.json in the folder of the project's target platform — here, Platform_OpenView, for Ahsoka.CPP.CAN.Select, whose target platform is OpenViewLinux (S70).
    The Console reporting that the configuration was created
    The Console reporting that the configuration was created

See the New Configuration

  1. CAN Setup keeps showing the old configuration until the project is loaded again. Close the CAN Setup window with its X, then click Close on the toolbar. When the toolkit asks Do you want to save package changes before closing?, click Close — the new configuration is already saved.

    Save Package, with the Close button
    Save Package, with the Close button
  2. Click Open.... In Recent Packages, select the project — here, Ahsoka.CPP.CAN.Select — and click Open Package Info.

    Recent Packages, with the project selected and the Open Package Info button
    Recent Packages, with the project selected and the Open Package Info button
  3. Click the Extensions tab, select Control Service Extension, and click Configure Extension... again. CAN Setup now lists the messages from the DBC file — DRIVER_HEARTBEAT, IO_DEBUG, IO_DEBUG2, MOTOR_CMD, MOTOR_STATUS, SENSOR_SONARS and TSC1 — and its nodes below them. Click a message to see its CAN ID and options.

    CAN Setup, listing the messages from TestFile.dbc
    CAN Setup, listing the messages from TestFile.dbc
Note: Create from DBC replaces the CAN configuration for the project's target platform. To keep an existing one, copy its CANServiceConfiguration.json first.