Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-114043

QCanDbcFileParser incorrectly parses 29-bit (extended) CAN IDs

    XMLWordPrintable

Details

    • 42cbbe9b6 (dev), 733cb6267 (6.5), 2b09ab3ee (6.6)
    • Foundation Sprint 83, Foundation Sprint 84

    Description

      Sample input
      Copied from "J1939 DBC Demo Example" at https://www.csselectronics.com/pages/can-dbc-file-database-intro

       

      Save this as "j1939.dbc"

      VERSION ""
      
      
      NS_ : 
          CM_
          BA_DEF_
          BA_
          BA_DEF_DEF_
      
      BS_:
      
      BU_:
      
      
      BO_ 2364540158 EEC1: 8 Vector_XXX
       SG_ EngineSpeed : 24|16@1+ (0.125,0) [0|8031.875] "rpm" Vector_XXX
      
      BO_ 2566844926 CCVS1: 8 Vector_XXX
       SG_ WheelBasedVehicleSpeed : 8|16@1+ (0.00390625,0) [0|250.996] "km/h" Vector_XXX
      
      
      CM_ BO_ 2364540158 "Electronic Engine Controller 1";
      CM_ SG_ 2364540158 EngineSpeed "Actual engine speed which is calculated over a minimum crankshaft angle of 720 degrees divided by the number of cylinders....";
      CM_ BO_ 2566844926 "Cruise Control/Vehicle Speed 1";
      CM_ SG_ 2566844926 WheelBasedVehicleSpeed "Wheel-Based Vehicle Speed: Speed of the vehicle as calculated from wheel or tailshaft speed.";
      BA_DEF_ SG_  "SPN" INT 0 524287;
      BA_DEF_ BO_  "VFrameFormat" ENUM  "StandardCAN","ExtendedCAN","reserved","J1939PG";
      BA_DEF_  "BusType" STRING ;
      BA_DEF_  "ProtocolType" STRING ;
      BA_DEF_DEF_  "SPN" 0;
      BA_DEF_DEF_  "VFrameFormat" "J1939PG";
      BA_DEF_DEF_  "BusType" "";
      BA_DEF_DEF_  "ProtocolType" "";
      BA_ "ProtocolType" "J1939";
      BA_ "BusType" "CAN"	;
      BA_ "VFrameFormat" BO_ 2364540158 3;
      BA_ "VFrameFormat" BO_ 2566844926 3;
      BA_ "SPN" SG_ 2364540158 EngineSpeed 190;
      BA_ "SPN" SG_ 2566844926 WheelBasedVehicleSpeed 84;
      

       

      Code

      QCanDbcFileParser fileParser;
      fileParser.parse(":/j1939.dbc");
      for (const auto& desc : fileParser.messageDescriptions())
          qDebug() << "CAN ID:" << QString::number(static_cast<quint32>(desc.uniqueId()), 16) << "Name:" << desc.name();
      

       

      Expected output

      CAN ID: "18fef1fe" Name: "CCVS1"
      CAN ID: "cf004fe" Name: "EEC1"
      

      Expected IDs can be seen at https://www.csselectronics.com/pages/dbc-editor-can-bus-database

       

      Actual output

      CAN ID: "98fef1fe" Name: "CCVS1"
      CAN ID: "8cf004fe" Name: "EEC1"
      

      These IDs are clearly invalid since they exceed 29 bits

       

      Notes
      According to https://www.csselectronics.com/pages/can-dbc-file-database-intro, "For extended 29-bit CAN IDs, a mask (0x1FFFFFFF) needs to be applied to the 32-bit DBC ID to get the 29-bit CAN ID"

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ivan.solovev Ivan Solovev
            skoh-qt Sze Howe Koh
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes