update doxygen with last cahnges
This commit is contained in:
1 parent
1163277b17
commit
6cd99768ae
286 files changed
+10735
-3471
No files matched your search
+228
-180
@@ -1,9 +1,9 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.4"/>
|
||||
<meta name="generator" content="Doxygen 1.9.8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>DBC Framework: DBC Parser and Runtime Decode Module Documentation</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -34,10 +34,10 @@
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.4 -->
|
||||
<!-- Generated by Doxygen 1.9.8 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
|
||||
var searchBox = new SearchBox("searchBox", "search/",'.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript" src="menudata.js"></script>
|
||||
@@ -77,19 +77,27 @@ $(document).ready(function(){initNavTree('md_README.html',''); initResizable();
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<iframe src="javascript:void(0)" frameborder="0"
|
||||
name="MSearchResults" id="MSearchResults">
|
||||
</iframe>
|
||||
<div id="MSearchResults">
|
||||
<div class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div id="SRResults"></div>
|
||||
<div class="SRStatus" id="Loading">Loading...</div>
|
||||
<div class="SRStatus" id="Searching">Searching...</div>
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div><div class="header">
|
||||
<div class="headertitle"><div class="title">DBC Parser and Runtime Decode Module Documentation </div></div>
|
||||
<div class="headertitle"><div class="title">DBC Parser and Runtime Decode Module Documentation</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="textblock"><h1><a class="anchor" id="autotoc_md1"></a>
|
||||
<div class="textblock"><p><a class="anchor" id="autotoc_md0"></a> </p>
|
||||
<h1><a class="anchor" id="autotoc_md1"></a>
|
||||
Overview</h1>
|
||||
<p >This module provides a minimal but extensible DBC parser and runtime decode foundation for the <b>FrameTap</b> project.</p>
|
||||
<p >Its purpose is to:</p>
|
||||
<p>This module provides a minimal but extensible DBC parser and runtime decode foundation for the <b>FrameTap</b> project.</p>
|
||||
<p>Its purpose is to:</p>
|
||||
<ul>
|
||||
<li>parse DBC files</li>
|
||||
<li>store parsed frame and signal metadata</li>
|
||||
@@ -98,27 +106,27 @@ Overview</h1>
|
||||
<li>decode live CAN frames</li>
|
||||
<li>decode CAN trace records using the same decoder</li>
|
||||
</ul>
|
||||
<p >The implementation follows a simple and practical design:</p>
|
||||
<p>The implementation follows a simple and practical design:</p>
|
||||
<ul>
|
||||
<li>parser logic is separated from UI logic</li>
|
||||
<li>runtime decode structures are separated from tree structures</li>
|
||||
<li>Qt is not required at the parser or decoder level</li>
|
||||
<li>the same decode engine can be reused for live traffic and trace replay</li>
|
||||
</ul>
|
||||
<p >This is <b>not a full production-grade DBC implementation yet</b>, but it is a strong architectural base.</p>
|
||||
<p>This is <b>not a full production-grade DBC implementation yet</b>, but it is a strong architectural base.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md3"></a>
|
||||
High-Level Architecture</h1>
|
||||
<p >The module is divided into two main paths.</p>
|
||||
<p>The module is divided into two main paths.</p>
|
||||
<h2><a class="anchor" id="autotoc_md4"></a>
|
||||
1. Parse and UI path</h2>
|
||||
<p >Used for:</p>
|
||||
<p>Used for:</p>
|
||||
<ul>
|
||||
<li>browsing frames and signals</li>
|
||||
<li>later integration with Qt <code>Model/View</code></li>
|
||||
<li>displaying metadata</li>
|
||||
</ul>
|
||||
<p >Pipeline:</p>
|
||||
<p>Pipeline:</p>
|
||||
<div class="fragment"><div class="line">DBC file</div>
|
||||
<div class="line"> ↓</div>
|
||||
<div class="line">DbcParser</div>
|
||||
@@ -132,13 +140,13 @@ High-Level Architecture</h1>
|
||||
<div class="line">future Qt UI</div>
|
||||
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md5"></a>
|
||||
2. Runtime decode path</h2>
|
||||
<p >Used for:</p>
|
||||
<p>Used for:</p>
|
||||
<ul>
|
||||
<li>live CAN decoding</li>
|
||||
<li>CAN trace decoding</li>
|
||||
<li>fast lookup by CAN ID</li>
|
||||
</ul>
|
||||
<p >Pipeline:</p>
|
||||
<p>Pipeline:</p>
|
||||
<div class="fragment"><div class="line">DBC file</div>
|
||||
<div class="line"> ↓</div>
|
||||
<div class="line">DbcParser</div>
|
||||
@@ -152,86 +160,89 @@ High-Level Architecture</h1>
|
||||
<div class="line">DbcDecoder</div>
|
||||
<div class="line"> ↓</div>
|
||||
<div class="line">Decoded values</div>
|
||||
</div><!-- fragment --><p >This separation is intentional.</p>
|
||||
<p >The tree is useful for UI, but it is <b>not</b> the main data structure for runtime decoding.</p>
|
||||
</div><!-- fragment --><p>This separation is intentional.</p>
|
||||
<p>The tree is useful for UI, but it is <b>not</b> the main data structure for runtime decoding.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md7"></a>
|
||||
Why the Runtime Decode Layer Exists</h1>
|
||||
<p >A tree structure is convenient for browsing, but a runtime decoder needs something different:</p>
|
||||
<p>A tree structure is convenient for browsing, but a runtime decoder needs something different:</p>
|
||||
<ul>
|
||||
<li>fast lookup by CAN ID</li>
|
||||
<li>direct access to signal decode definitions</li>
|
||||
<li>minimal overhead during repeated decoding</li>
|
||||
<li>the same logic for live frames and trace frames</li>
|
||||
</ul>
|
||||
<p >Because of that, the design uses a dedicated runtime-ready structure:</p>
|
||||
<p>Because of that, the design uses a dedicated runtime-ready structure:</p>
|
||||
<ul>
|
||||
<li><code><a class="el" href="structDecodeDatabase.html" title="Runtime decode database with fast lookup by CAN ID.">DecodeDatabase</a></code></li>
|
||||
<li><code><a class="el" href="structDecodeFrame.html" title="Runtime-ready frame definition.">DecodeFrame</a></code></li>
|
||||
<li><code><a class="el" href="structDecodeSignal.html" title="Runtime-ready signal definition.">DecodeSignal</a></code></li>
|
||||
</ul>
|
||||
<p >This avoids forcing UI-oriented structures into a decode role they were not meant for.</p>
|
||||
<p>This avoids forcing UI-oriented structures into a decode role they were not meant for.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md9"></a>
|
||||
Module Layout</h1>
|
||||
<h2><a class="anchor" id="autotoc_md10"></a>
|
||||
Parsed DBC structures</h2>
|
||||
<p >Files:</p>
|
||||
<p>Files:</p>
|
||||
<ul>
|
||||
<li><code><a class="el" href="signal__info_8h.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">signal_info.h</a></code></li>
|
||||
<li><code><a class="el" href="frame__info_8h.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">frame_info.h</a></code></li>
|
||||
<li><code><a class="el" href="dbc__database_8h.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">dbc_database.h</a></code></li>
|
||||
</ul>
|
||||
<p >These store a readable representation of the parsed DBC file.</p>
|
||||
<p>These store a readable representation of the parsed DBC file.</p>
|
||||
<h2><a class="anchor" id="autotoc_md11"></a>
|
||||
UI tree structures</h2>
|
||||
<p >Files:</p>
|
||||
<p>Files:</p>
|
||||
<ul>
|
||||
<li><code><a class="el" href="tree__node_8h.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">tree_node.h</a></code></li>
|
||||
<li><code><a class="el" href="tree__node_8cpp.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">tree_node.cpp</a></code></li>
|
||||
<li><code><a class="el" href="dbc__tree__builder_8h.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">dbc_tree_builder.h</a></code></li>
|
||||
<li><code><a class="el" href="dbc__tree__builder_8cpp.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">dbc_tree_builder.cpp</a></code></li>
|
||||
</ul>
|
||||
<p >These convert parsed DBC content into a tree hierarchy suitable for UI and model/view usage later.</p>
|
||||
<p>These convert parsed DBC content into a tree hierarchy suitable for UI and model/view usage later.</p>
|
||||
<h2><a class="anchor" id="autotoc_md12"></a>
|
||||
Runtime decode structures</h2>
|
||||
<p >Files:</p>
|
||||
<p>Files:</p>
|
||||
<ul>
|
||||
<li><code><a class="el" href="decode__database_8h.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">decode_database.h</a></code></li>
|
||||
<li><code><a class="el" href="dbc__decode__builder_8h.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">dbc_decode_builder.h</a></code></li>
|
||||
<li><code><a class="el" href="dbc__decode__builder_8cpp.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">dbc_decode_builder.cpp</a></code></li>
|
||||
</ul>
|
||||
<p >These convert parsed DBC content into a structure optimized for decoding.</p>
|
||||
<p>These convert parsed DBC content into a structure optimized for decoding.</p>
|
||||
<h2><a class="anchor" id="autotoc_md13"></a>
|
||||
Runtime decoder</h2>
|
||||
<p >Files:</p>
|
||||
<p>Files:</p>
|
||||
<ul>
|
||||
<li><code><a class="el" href="dbc__decoder_8h.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">dbc_decoder.h</a></code></li>
|
||||
<li><code><a class="el" href="dbc__decoder_8cpp.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">dbc_decoder.cpp</a></code></li>
|
||||
</ul>
|
||||
<p >These perform actual decoding of raw CAN frames using <code><a class="el" href="structDecodeDatabase.html" title="Runtime decode database with fast lookup by CAN ID.">DecodeDatabase</a></code>.</p>
|
||||
<p>These perform actual decoding of raw CAN frames using <code><a class="el" href="structDecodeDatabase.html" title="Runtime decode database with fast lookup by CAN ID.">DecodeDatabase</a></code>.</p>
|
||||
<h2><a class="anchor" id="autotoc_md14"></a>
|
||||
Parser</h2>
|
||||
<p >Files:</p>
|
||||
<p>Files:</p>
|
||||
<ul>
|
||||
<li><code><a class="el" href="dbc__parser_8h.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">dbc_parser.h</a></code></li>
|
||||
<li><code><a class="el" href="dbc__parser_8cpp.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">dbc_parser.cpp</a></code></li>
|
||||
<li><code><a class="el" href="dbc__statement__handler_8h_source.html">dbc_statement_handler.h</a></code></li>
|
||||
<li><code><a class="el" href="dbc__statement__handler_8cpp_source.html">dbc_statement_handler.cpp</a></code></li>
|
||||
<li><code><a class="el" href="typefactory_8h_source.html">typefactory.h</a></code></li>
|
||||
</ul>
|
||||
<p >These parse the DBC file itself.</p>
|
||||
<p>The parser reads files and reports errors; registered statement handlers parse DBC constructs.</p>
|
||||
<h2><a class="anchor" id="autotoc_md15"></a>
|
||||
Demo</h2>
|
||||
<p >File:</p>
|
||||
<p>File:</p>
|
||||
<ul>
|
||||
<li><code><a class="el" href="main_8cpp.html" title="Created: 2026-03-13 Author: Deeaitch (Dim. Himro)">main.cpp</a></code></li>
|
||||
</ul>
|
||||
<p >Used as a small integration example.</p>
|
||||
<p>Used as a small integration example.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md17"></a>
|
||||
Parsed Data Structures</h1>
|
||||
<h1><a class="anchor" id="autotoc_md18"></a>
|
||||
<tt>SignalInfo</tt></h1>
|
||||
<p >Represents one signal as parsed from the DBC file.</p>
|
||||
<p >Fields:</p>
|
||||
<p>Represents one signal as parsed from the DBC file.</p>
|
||||
<p>Fields:</p>
|
||||
<ul>
|
||||
<li><code>name</code></li>
|
||||
<li><code>startBit</code></li>
|
||||
@@ -246,19 +257,19 @@ Parsed Data Structures</h1>
|
||||
<li><code>receivers</code></li>
|
||||
<li><code>comment</code></li>
|
||||
</ul>
|
||||
<p >Notes:</p>
|
||||
<p>Notes:</p>
|
||||
<ul>
|
||||
<li><code>receivers</code> is a list because a signal may have more than one receiver ECU</li>
|
||||
<li><code>factor</code> and <code>offset</code> define physical conversion</li>
|
||||
<li>this structure is close to DBC content and easy to inspect</li>
|
||||
</ul>
|
||||
<p >Physical value rule:</p>
|
||||
<p>Physical value rule:</p>
|
||||
<div class="fragment"><div class="line">physical = raw * factor + offset</div>
|
||||
</div><!-- fragment --><hr />
|
||||
<h1><a class="anchor" id="autotoc_md20"></a>
|
||||
<tt>FrameInfo</tt></h1>
|
||||
<p >Represents one frame as parsed from the DBC file.</p>
|
||||
<p >Fields:</p>
|
||||
<p>Represents one frame as parsed from the DBC file.</p>
|
||||
<p>Fields:</p>
|
||||
<ul>
|
||||
<li><code>name</code></li>
|
||||
<li><code>canId</code></li>
|
||||
@@ -270,7 +281,7 @@ Parsed Data Structures</h1>
|
||||
<li><code>comment</code></li>
|
||||
<li><code>signals</code></li>
|
||||
</ul>
|
||||
<p >Notes:</p>
|
||||
<p>Notes:</p>
|
||||
<ul>
|
||||
<li><code>signals</code> is a list of <code><a class="el" href="structSignalInfo.html" title="Describes one signal inside a DBC frame.">SignalInfo</a></code></li>
|
||||
<li><code>isExtended</code> is determined during CAN ID normalization</li>
|
||||
@@ -279,23 +290,23 @@ Parsed Data Structures</h1>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md22"></a>
|
||||
<tt>DbcDatabase</tt></h1>
|
||||
<p >Top-level parsed DBC container.</p>
|
||||
<p >Conceptually:</p>
|
||||
<p>Top-level parsed DBC container.</p>
|
||||
<p>Conceptually:</p>
|
||||
<div class="fragment"><div class="line">DbcDatabase</div>
|
||||
<div class="line"> └── vector<FrameInfo></div>
|
||||
</div><!-- fragment --><p >This is the central structure produced by <code><a class="el" href="classDbcParser.html" title="Minimal DBC parser.">DbcParser</a></code>.</p>
|
||||
</div><!-- fragment --><p>This is the central structure produced by <code><a class="el" href="classDbcParser.html" title="Minimal DBC parser.">DbcParser</a></code>.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md24"></a>
|
||||
UI Tree Layer</h1>
|
||||
<h1><a class="anchor" id="autotoc_md25"></a>
|
||||
<tt>TreeNode</tt></h1>
|
||||
<p >The UI tree contains three node types:</p>
|
||||
<p>The UI tree contains three node types:</p>
|
||||
<ul>
|
||||
<li><code>Root</code></li>
|
||||
<li><code>Frame</code></li>
|
||||
<li><code>Signal</code></li>
|
||||
</ul>
|
||||
<p >Example hierarchy:</p>
|
||||
<p>Example hierarchy:</p>
|
||||
<div class="fragment"><div class="line">dbc</div>
|
||||
<div class="line"> ├── EngineData</div>
|
||||
<div class="line"> │ ├── EngineSpeed</div>
|
||||
@@ -304,43 +315,43 @@ UI Tree Layer</h1>
|
||||
<div class="line"> └── VehicleData</div>
|
||||
<div class="line"> ├── VehicleSpeed</div>
|
||||
<div class="line"> └── Odometer</div>
|
||||
</div><!-- fragment --><p >Each node stores either:</p>
|
||||
</div><!-- fragment --><p>Each node stores either:</p>
|
||||
<ul>
|
||||
<li><code><a class="el" href="structFrameInfo.html" title="Describes one CAN frame from a DBC file.">FrameInfo</a></code></li>
|
||||
<li><code><a class="el" href="structSignalInfo.html" title="Describes one signal inside a DBC frame.">SignalInfo</a></code></li>
|
||||
</ul>
|
||||
<p >The tree is intended for browsing and later Qt model integration.</p>
|
||||
<p >It is <b>not</b> the primary runtime decode structure.</p>
|
||||
<p>The tree is intended for browsing and later Qt model integration.</p>
|
||||
<p>It is <b>not</b> the primary runtime decode structure.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md27"></a>
|
||||
Runtime Decode Layer</h1>
|
||||
<h1><a class="anchor" id="autotoc_md28"></a>
|
||||
Purpose</h1>
|
||||
<p >The decode layer exists so that decoding can be fast and independent from UI concerns.</p>
|
||||
<p >Instead of searching a tree, the decoder uses a prepared database with direct lookup.</p>
|
||||
<p>The decode layer exists so that decoding can be fast and independent from UI concerns.</p>
|
||||
<p>Instead of searching a tree, the decoder uses a prepared database with direct lookup.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md30"></a>
|
||||
<tt>ByteOrder</tt></h1>
|
||||
<p >Runtime byte order enum:</p>
|
||||
<p>Runtime byte order enum:</p>
|
||||
<ul>
|
||||
<li><code>Intel</code></li>
|
||||
<li><code>Motorola</code></li>
|
||||
</ul>
|
||||
<p >This is better for decode code than passing around raw DBC characters.</p>
|
||||
<p>This is better for decode code than passing around raw DBC characters.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md32"></a>
|
||||
<tt>ValueType</tt></h1>
|
||||
<p >Numeric type enum:</p>
|
||||
<p>Numeric type enum:</p>
|
||||
<ul>
|
||||
<li><code>Unsigned</code></li>
|
||||
<li><code>Signed</code></li>
|
||||
</ul>
|
||||
<p >This is clearer than combining multiple boolean flags during runtime logic.</p>
|
||||
<p>This is clearer than combining multiple boolean flags during runtime logic.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md34"></a>
|
||||
<tt>DecodeSignal</tt></h1>
|
||||
<p >Represents one runtime-ready signal definition.</p>
|
||||
<p >Fields:</p>
|
||||
<p>Represents one runtime-ready signal definition.</p>
|
||||
<p>Fields:</p>
|
||||
<ul>
|
||||
<li><code>name</code></li>
|
||||
<li><code>startBit</code></li>
|
||||
@@ -355,12 +366,12 @@ Purpose</h1>
|
||||
<li><code>receivers</code></li>
|
||||
<li><code>comment</code></li>
|
||||
</ul>
|
||||
<p >This structure contains all information required for extracting and converting a signal value from raw frame data.</p>
|
||||
<p>This structure contains all information required for extracting and converting a signal value from raw frame data.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md36"></a>
|
||||
<tt>DecodeFrame</tt></h1>
|
||||
<p >Represents one runtime-ready frame definition.</p>
|
||||
<p >Fields:</p>
|
||||
<p>Represents one runtime-ready frame definition.</p>
|
||||
<p>Fields:</p>
|
||||
<ul>
|
||||
<li><code>name</code></li>
|
||||
<li><code>canId</code></li>
|
||||
@@ -372,44 +383,44 @@ Purpose</h1>
|
||||
<li><code>comment</code></li>
|
||||
<li><code>signals</code></li>
|
||||
</ul>
|
||||
<p >This structure is used directly by the decoder.</p>
|
||||
<p>This structure is used directly by the decoder.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md38"></a>
|
||||
<tt>FrameKey</tt></h1>
|
||||
<p >Fast lookup key for runtime frame matching.</p>
|
||||
<p >Fields:</p>
|
||||
<p>Fast lookup key for runtime frame matching.</p>
|
||||
<p>Fields:</p>
|
||||
<ul>
|
||||
<li><code>canId</code></li>
|
||||
<li><code>isExtended</code></li>
|
||||
</ul>
|
||||
<p >This matters because the same numeric identifier must not be confused between standard and extended frames.</p>
|
||||
<p>This matters because the same numeric identifier must not be confused between standard and extended frames.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md40"></a>
|
||||
<tt>DecodeDatabase</tt></h1>
|
||||
<p >Top-level runtime decode container.</p>
|
||||
<p >Fields:</p>
|
||||
<p>Top-level runtime decode container.</p>
|
||||
<p>Fields:</p>
|
||||
<ul>
|
||||
<li><code>frames</code></li>
|
||||
<li><code>frameIndexByKey</code></li>
|
||||
</ul>
|
||||
<p >Conceptually:</p>
|
||||
<p>Conceptually:</p>
|
||||
<div class="fragment"><div class="line">DecodeDatabase</div>
|
||||
<div class="line"> ├── vector<DecodeFrame></div>
|
||||
<div class="line"> └── unordered_map<FrameKey, index></div>
|
||||
</div><!-- fragment --><p >This gives the decoder fast access to a frame definition using CAN ID and frame type.</p>
|
||||
</div><!-- fragment --><p>This gives the decoder fast access to a frame definition using CAN ID and frame type.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md42"></a>
|
||||
Decoder Layer</h1>
|
||||
<h1><a class="anchor" id="autotoc_md43"></a>
|
||||
<tt>RawCanFrame</tt></h1>
|
||||
<p >Represents a raw CAN frame to decode.</p>
|
||||
<p >Fields:</p>
|
||||
<p>Represents a raw CAN frame to decode.</p>
|
||||
<p>Fields:</p>
|
||||
<ul>
|
||||
<li><code>canId</code></li>
|
||||
<li><code>isExtended</code></li>
|
||||
<li><code>data</code></li>
|
||||
</ul>
|
||||
<p >This same structure can be used for:</p>
|
||||
<p>This same structure can be used for:</p>
|
||||
<ul>
|
||||
<li>live CAN bus input</li>
|
||||
<li>replayed trace records</li>
|
||||
@@ -418,8 +429,8 @@ Decoder Layer</h1>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md45"></a>
|
||||
<tt>DecodedSignalValue</tt></h1>
|
||||
<p >Represents one decoded signal result.</p>
|
||||
<p >Fields:</p>
|
||||
<p>Represents one decoded signal result.</p>
|
||||
<p>Fields:</p>
|
||||
<ul>
|
||||
<li><code>definition</code></li>
|
||||
<li><code>rawValue</code></li>
|
||||
@@ -427,21 +438,29 @@ Decoder Layer</h1>
|
||||
<li><code>valid</code></li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md47"></a>
|
||||
<h2><a class="anchor" id="autotoc_md47"></a>
|
||||
Raw value representation and precision</h2>
|
||||
<p><code><a class="el" href="structDecodedSignalValue.html#a95db4f7f93b5f311e8f272833e45055e">DecodedSignalValue::rawValue</a></code> is a C++17 <code>std::variant<std::int64_t, std::uint64_t></code>. For a valid signal, signed definitions produce the <code>int64_t</code> alternative and unsigned definitions produce the <code>uint64_t</code> alternative. Raw values remain exact across their full 64-bit ranges. Check <code>valid</code> before using the value; an invalid result's default value is not decoded data.</p>
|
||||
<p>Use <code>std::get</code> when the numeric type is known, or <code>std::visit</code> to handle both:</p>
|
||||
<div class="fragment"><div class="line">std::visit([] (<span class="keyword">auto</span> raw) { std::cout << raw; }, decodedSignal.rawValue);</div>
|
||||
</div><!-- fragment --><p>This replaces the previous <code>int64_t</code> field: consumers that read or print <code>rawValue</code> directly must handle the variant.</p>
|
||||
<p>Physical conversion uses the active numeric type: <code>physicalValue = static_cast<double>(raw) * factor + offset</code>. <code>physicalValue</code> remains a <code>double</code> and is approximate for large integers. On usual IEEE 754 binary64 implementations, integers are exactly representable through 2^53; above that, some integers round to the same floating-point value. For example, unsigned <code>UINT64_MAX</code> remains exact in <code>rawValue</code>, but converts to approximately 18446744073709551616 in binary64 before scaling. Use <code>rawValue</code> whenever exact integer values are required.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md49"></a>
|
||||
<tt>DecodedFrameValue</tt></h1>
|
||||
<p >Represents one decoded frame result.</p>
|
||||
<p >Fields:</p>
|
||||
<p>Represents one decoded frame result.</p>
|
||||
<p>Fields:</p>
|
||||
<ul>
|
||||
<li><code>definition</code></li>
|
||||
<li><code>signals</code></li>
|
||||
<li><code>valid</code></li>
|
||||
</ul>
|
||||
<p >This is the decoder output for one raw frame.</p>
|
||||
<p>This is the decoder output for one raw frame.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md49"></a>
|
||||
<h1><a class="anchor" id="autotoc_md51"></a>
|
||||
<tt>DbcDecoder</tt></h1>
|
||||
<p >Main runtime decoder class.</p>
|
||||
<p >Responsibilities:</p>
|
||||
<p>Main runtime decoder class.</p>
|
||||
<p>Responsibilities:</p>
|
||||
<ul>
|
||||
<li>find a frame definition by CAN ID</li>
|
||||
<li>decode all signals in a frame</li>
|
||||
@@ -449,15 +468,15 @@ Decoder Layer</h1>
|
||||
<li>sign-extend signed values</li>
|
||||
<li>convert raw values into physical values</li>
|
||||
</ul>
|
||||
<p >Main methods:</p>
|
||||
<p>Main methods:</p>
|
||||
<ul>
|
||||
<li><code>FindFrame(...)</code></li>
|
||||
<li><code>Decode(...)</code></li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md51"></a>
|
||||
<h1><a class="anchor" id="autotoc_md53"></a>
|
||||
Parser Support</h1>
|
||||
<p >The current parser supports the following DBC elements:</p>
|
||||
<p>The current parser supports the following DBC elements:</p>
|
||||
<ul>
|
||||
<li><code>BO_</code></li>
|
||||
<li><code>SG_</code></li>
|
||||
@@ -465,13 +484,13 @@ Parser Support</h1>
|
||||
<li><code>CM_ SG_</code></li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md53"></a>
|
||||
<h1><a class="anchor" id="autotoc_md55"></a>
|
||||
Supported DBC Syntax</h1>
|
||||
<h1><a class="anchor" id="autotoc_md54"></a>
|
||||
<h1><a class="anchor" id="autotoc_md56"></a>
|
||||
Frame definition</h1>
|
||||
<p >Example:</p>
|
||||
<p>Example:</p>
|
||||
<div class="fragment"><div class="line">BO_ 256 EngineData: 8 EEC1</div>
|
||||
</div><!-- fragment --><p >Parsed fields:</p>
|
||||
</div><!-- fragment --><p>Parsed fields:</p>
|
||||
<ul>
|
||||
<li>frame CAN ID</li>
|
||||
<li>frame name</li>
|
||||
@@ -479,11 +498,20 @@ Frame definition</h1>
|
||||
<li>transmitter ECU</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md56"></a>
|
||||
<h2><a class="anchor" id="autotoc_md58"></a>
|
||||
Frame validation and parse errors</h2>
|
||||
<p><code>BO_</code> definitions require a decimal CAN ID, a nonempty single-token frame name, a colon, a decimal payload length, and a transmitter token. Spaces or tabs may separate fields, and whitespace before the colon is accepted. Additional trailing fields are rejected.</p>
|
||||
<p>Numeric fields must contain decimal digits only; signs, hexadecimal notation, fractional values, suffixes, and overflow are rejected. CAN IDs may contain the 29-bit identifier plus the optional DBC extended flag (bit 31). Bits 29 and 30 are rejected rather than silently discarded. For compatibility, unflagged IDs above <code>0x7FF</code> are still treated as extended.</p>
|
||||
<p>The payload length must fit <code>uint8_t</code> (<code>0..255</code>). This is a storage-range check, not CAN or CAN FD protocol validation; no new 8-byte or 64-byte limit is imposed.</p>
|
||||
<p>Parsing stops at the first detected error. Exceptions raised while parsing a line are reported as <code>std::runtime_error</code> with the supplied file path and the one-based physical line number, including blank lines:</p>
|
||||
<div class="fragment"><div class="line">example.dbc:3: Invalid CAN ID: invalid</div>
|
||||
</div><!-- fragment --><p>This change validates frame definitions. Signal definitions are also validated as described below; comprehensive DBC grammar coverage is still planned. File-open errors contain the path but have no line number.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md60"></a>
|
||||
Signal definition</h1>
|
||||
<p >Example:</p>
|
||||
<p>Example:</p>
|
||||
<div class="fragment"><div class="line">SG_ EngineSpeed : 0|16@1+ (0.125,0) [0|8000] "rpm" ECU1,ECU2</div>
|
||||
</div><!-- fragment --><p >Parsed fields:</p>
|
||||
</div><!-- fragment --><p>Parsed fields:</p>
|
||||
<ul>
|
||||
<li>signal name</li>
|
||||
<li>start bit</li>
|
||||
@@ -498,47 +526,55 @@ Signal definition</h1>
|
||||
<li>receivers</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md58"></a>
|
||||
<h2><a class="anchor" id="autotoc_md62"></a>
|
||||
Signal validation and parse errors</h2>
|
||||
<p><code>SG_</code> statements are matched completely. Signal names must be nonempty and contain no whitespace. Spaces and tabs are accepted between syntax elements; byte order and signedness remain adjacent (<code>@0+</code>, <code>@0-</code>, <code>@1+</code>, or <code>@1-</code>). A quoted unit (which may be empty) and a nonempty comma-separated receiver list are required. Unexpected trailing fields are rejected.</p>
|
||||
<p>Start bits must be unsigned decimal integers fitting <code>uint32_t</code>; lengths must be within <code>1..64</code> bits. Signs, fractional values, numeric suffixes, and overflow are rejected for these fields. Every signal bit must fit within the frame's declared payload length, using Intel increasing bit positions or Motorola sawtooth traversal. This uses the stored payload length without introducing an additional CAN or CAN FD payload limit.</p>
|
||||
<p>Factor, offset, minimum, and maximum accept signed decimal numbers, fractions, and scientific notation. The entire numeric token must be valid; hexadecimal numbers, NaN, infinity, conversion overflow, and conversion underflow are rejected. Minimum must not exceed maximum. Zero and negative factors are allowed.</p>
|
||||
<p>Multiplexing markers (<code>M</code>, <code>mN</code>, and combinations) are currently rejected rather than interpreted as part of a signal name. Multiplexing support and duplicate frame/signal detection remain separate work.</p>
|
||||
<p>Invalid signal definitions stop parsing with <code>path:line: description</code>, including when the signal exceeds the declared payload length.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md64"></a>
|
||||
Comments</h1>
|
||||
<p >Frame comment example:</p>
|
||||
<p>Frame comment example:</p>
|
||||
<div class="fragment"><div class="line">CM_ BO_ 256 "Engine data frame";</div>
|
||||
</div><!-- fragment --><p >Signal comment example:</p>
|
||||
</div><!-- fragment --><p>Signal comment example:</p>
|
||||
<div class="fragment"><div class="line">CM_ SG_ 256 EngineSpeed "Actual engine speed";</div>
|
||||
</div><!-- fragment --><p >Stored in:</p>
|
||||
</div><!-- fragment --><p>Stored in:</p>
|
||||
<ul>
|
||||
<li><code><a class="el" href="structFrameInfo.html#ace75121294f9d89b762080ab5643293c">FrameInfo::comment</a></code></li>
|
||||
<li><code><a class="el" href="structSignalInfo.html#ac99ba7563a5dad01e39c4257216953f5">SignalInfo::comment</a></code></li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md60"></a>
|
||||
<h1><a class="anchor" id="autotoc_md66"></a>
|
||||
CAN ID Normalization</h1>
|
||||
<p >The parser normalizes frame identifiers.</p>
|
||||
<p >Common DBC behavior:</p>
|
||||
<p>The parser normalizes frame identifiers.</p>
|
||||
<p>Common DBC behavior:</p>
|
||||
<ul>
|
||||
<li>extended identifiers may be stored with bit 31 set</li>
|
||||
<li>the actual 29-bit identifier must be extracted from that value</li>
|
||||
</ul>
|
||||
<p >The parser therefore stores:</p>
|
||||
<p>The parser therefore stores:</p>
|
||||
<ul>
|
||||
<li>normalized <code>canId</code></li>
|
||||
<li>separate <code>isExtended</code> flag</li>
|
||||
</ul>
|
||||
<p >This is important both for correct lookup and for future interoperability with live CAN APIs.</p>
|
||||
<p>This is important both for correct lookup and for future interoperability with live CAN APIs.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md62"></a>
|
||||
<h1><a class="anchor" id="autotoc_md68"></a>
|
||||
PGN Extraction</h1>
|
||||
<p >PGN is derived only when the frame is treated as extended.</p>
|
||||
<p >The current logic is simplified J1939 extraction:</p>
|
||||
<p>PGN is derived only when the frame is treated as extended.</p>
|
||||
<p>The current logic is simplified J1939 extraction:</p>
|
||||
<ul>
|
||||
<li><code>pf</code></li>
|
||||
<li><code>ps</code></li>
|
||||
<li><code>dp</code></li>
|
||||
</ul>
|
||||
<p >This is enough for a practical start but should not be treated as full J1939 validation.</p>
|
||||
<p>This is enough for a practical start but should not be treated as full J1939 validation.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md64"></a>
|
||||
<h1><a class="anchor" id="autotoc_md70"></a>
|
||||
Decode Flow</h1>
|
||||
<p >Typical runtime decode flow:</p>
|
||||
<p>Typical runtime decode flow:</p>
|
||||
<div class="fragment"><div class="line">RawCanFrame</div>
|
||||
<div class="line"> ↓</div>
|
||||
<div class="line">Find frame in DecodeDatabase</div>
|
||||
@@ -550,40 +586,40 @@ Decode Flow</h1>
|
||||
<div class="line"> ↓</div>
|
||||
<div class="line">DecodedFrameValue</div>
|
||||
</div><!-- fragment --><hr />
|
||||
<h1><a class="anchor" id="autotoc_md66"></a>
|
||||
<h1><a class="anchor" id="autotoc_md72"></a>
|
||||
Intel and Motorola Extraction</h1>
|
||||
<p >The decoder currently has separate extraction paths:</p>
|
||||
<p>The decoder currently has separate extraction paths:</p>
|
||||
<ul>
|
||||
<li><code>ExtractIntel(...)</code></li>
|
||||
<li><code>ExtractMotorola(...)</code></li>
|
||||
</ul>
|
||||
<p >This is important because byte order is not just metadata once decoding starts.</p>
|
||||
<p >Intel and Motorola require different bit extraction logic.</p>
|
||||
<p >This is one of the main reasons why the runtime decode layer should be explicit and prepared in advance.</p>
|
||||
<p>This is important because byte order is not just metadata once decoding starts.</p>
|
||||
<p>Intel and Motorola require different bit extraction logic.</p>
|
||||
<p>This is one of the main reasons why the runtime decode layer should be explicit and prepared in advance.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md68"></a>
|
||||
<h1><a class="anchor" id="autotoc_md74"></a>
|
||||
Example Usage</h1>
|
||||
<h1><a class="anchor" id="autotoc_md69"></a>
|
||||
<h1><a class="anchor" id="autotoc_md75"></a>
|
||||
Parse DBC</h1>
|
||||
<div class="fragment"><div class="line"><a class="code hl_class" href="classDbcParser.html">DbcParser</a> parser;</div>
|
||||
<div class="line"><a class="code hl_struct" href="structDbcDatabase.html">DbcDatabase</a> database = parser.<a class="code hl_function" href="classDbcParser.html#aef72826942c9095d653fafa435855e56">ParseFile</a>(<span class="stringliteral">"example.dbc"</span>);</div>
|
||||
<div class="ttc" id="aclassDbcParser_html"><div class="ttname"><a href="classDbcParser.html">DbcParser</a></div><div class="ttdoc">Minimal DBC parser.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__parser_8h_source.html#l00035">dbc_parser.h:35</a></div></div>
|
||||
<div class="ttc" id="aclassDbcParser_html_aef72826942c9095d653fafa435855e56"><div class="ttname"><a href="classDbcParser.html#aef72826942c9095d653fafa435855e56">DbcParser::ParseFile</a></div><div class="ttdeci">DbcDatabase ParseFile(const std::string &filePath) const</div><div class="ttdoc">Parse DBC file.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__parser_8cpp_source.html#l00040">dbc_parser.cpp:40</a></div></div>
|
||||
<div class="ttc" id="astructDbcDatabase_html"><div class="ttname"><a href="structDbcDatabase.html">DbcDatabase</a></div><div class="ttdoc">Parsed DBC content stored in a simple internal form.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__database_8h_source.html#l00022">dbc_database.h:22</a></div></div>
|
||||
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md70"></a>
|
||||
<div class="ttc" id="aclassDbcParser_html"><div class="ttname"><a href="classDbcParser.html">DbcParser</a></div><div class="ttdoc">Minimal DBC parser.</div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8h_source.html#l00033">dbc_parser.h:33</a></div></div>
|
||||
<div class="ttc" id="aclassDbcParser_html_aef72826942c9095d653fafa435855e56"><div class="ttname"><a href="classDbcParser.html#aef72826942c9095d653fafa435855e56">DbcParser::ParseFile</a></div><div class="ttdeci">DbcDatabase ParseFile(const std::string &filePath) const</div><div class="ttdoc">Parse DBC file.</div><div class="ttdef"><b>Definition</b> <a href="dbc__parser_8cpp_source.html#l00040">dbc_parser.cpp:40</a></div></div>
|
||||
<div class="ttc" id="astructDbcDatabase_html"><div class="ttname"><a href="structDbcDatabase.html">DbcDatabase</a></div><div class="ttdoc">Parsed DBC content stored in a simple internal form.</div><div class="ttdef"><b>Definition</b> <a href="dbc__database_8h_source.html#l00022">dbc_database.h:22</a></div></div>
|
||||
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md76"></a>
|
||||
Build UI tree</h1>
|
||||
<div class="fragment"><div class="line"><a class="code hl_class" href="classDbcTreeBuilder.html">DbcTreeBuilder</a> treeBuilder;</div>
|
||||
<div class="line">std::unique_ptr<TreeNode> root = treeBuilder.<a class="code hl_function" href="classDbcTreeBuilder.html#a7e57d067d831b14b383947fd125edd4b">Build</a>(database);</div>
|
||||
<div class="ttc" id="aclassDbcTreeBuilder_html"><div class="ttname"><a href="classDbcTreeBuilder.html">DbcTreeBuilder</a></div><div class="ttdoc">Builds a simple tree from parsed DBC database.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__tree__builder_8h_source.html#l00023">dbc_tree_builder.h:23</a></div></div>
|
||||
<div class="ttc" id="aclassDbcTreeBuilder_html_a7e57d067d831b14b383947fd125edd4b"><div class="ttname"><a href="classDbcTreeBuilder.html#a7e57d067d831b14b383947fd125edd4b">DbcTreeBuilder::Build</a></div><div class="ttdeci">std::unique_ptr< TreeNode > Build(const DbcDatabase &database) const</div><div class="ttdoc">Build tree representation of parsed DBC data.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__tree__builder_8cpp_source.html#l00014">dbc_tree_builder.cpp:14</a></div></div>
|
||||
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md71"></a>
|
||||
<div class="ttc" id="aclassDbcTreeBuilder_html"><div class="ttname"><a href="classDbcTreeBuilder.html">DbcTreeBuilder</a></div><div class="ttdoc">Builds a simple tree from parsed DBC database.</div><div class="ttdef"><b>Definition</b> <a href="dbc__tree__builder_8h_source.html#l00023">dbc_tree_builder.h:23</a></div></div>
|
||||
<div class="ttc" id="aclassDbcTreeBuilder_html_a7e57d067d831b14b383947fd125edd4b"><div class="ttname"><a href="classDbcTreeBuilder.html#a7e57d067d831b14b383947fd125edd4b">DbcTreeBuilder::Build</a></div><div class="ttdeci">std::unique_ptr< TreeNode > Build(const DbcDatabase &database) const</div><div class="ttdoc">Build tree representation of parsed DBC data.</div><div class="ttdef"><b>Definition</b> <a href="dbc__tree__builder_8cpp_source.html#l00014">dbc_tree_builder.cpp:14</a></div></div>
|
||||
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md77"></a>
|
||||
Build runtime decode database</h1>
|
||||
<div class="fragment"><div class="line"><a class="code hl_class" href="classDbcDecodeBuilder.html">DbcDecodeBuilder</a> decodeBuilder;</div>
|
||||
<div class="line"><a class="code hl_struct" href="structDecodeDatabase.html">DecodeDatabase</a> decodeDatabase = decodeBuilder.<a class="code hl_function" href="classDbcDecodeBuilder.html#a2bc6386dfb5e58976c42e22c19ec471b">Build</a>(database);</div>
|
||||
<div class="ttc" id="aclassDbcDecodeBuilder_html"><div class="ttname"><a href="classDbcDecodeBuilder.html">DbcDecodeBuilder</a></div><div class="ttdoc">Converts parsed DBC data into runtime decode database.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__decode__builder_8h_source.html#l00021">dbc_decode_builder.h:21</a></div></div>
|
||||
<div class="ttc" id="aclassDbcDecodeBuilder_html_a2bc6386dfb5e58976c42e22c19ec471b"><div class="ttname"><a href="classDbcDecodeBuilder.html#a2bc6386dfb5e58976c42e22c19ec471b">DbcDecodeBuilder::Build</a></div><div class="ttdeci">DecodeDatabase Build(const DbcDatabase &source) const</div><div class="ttdoc">Build runtime decode database.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__decode__builder_8cpp_source.html#l00014">dbc_decode_builder.cpp:14</a></div></div>
|
||||
<div class="ttc" id="astructDecodeDatabase_html"><div class="ttname"><a href="structDecodeDatabase.html">DecodeDatabase</a></div><div class="ttdoc">Runtime decode database with fast lookup by CAN ID.</div><div class="ttdef"><b>Definition:</b> <a href="decode__database_8h_source.html#l00132">decode_database.h:132</a></div></div>
|
||||
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md72"></a>
|
||||
<div class="ttc" id="aclassDbcDecodeBuilder_html"><div class="ttname"><a href="classDbcDecodeBuilder.html">DbcDecodeBuilder</a></div><div class="ttdoc">Converts parsed DBC data into runtime decode database.</div><div class="ttdef"><b>Definition</b> <a href="dbc__decode__builder_8h_source.html#l00021">dbc_decode_builder.h:21</a></div></div>
|
||||
<div class="ttc" id="aclassDbcDecodeBuilder_html_a2bc6386dfb5e58976c42e22c19ec471b"><div class="ttname"><a href="classDbcDecodeBuilder.html#a2bc6386dfb5e58976c42e22c19ec471b">DbcDecodeBuilder::Build</a></div><div class="ttdeci">DecodeDatabase Build(const DbcDatabase &source) const</div><div class="ttdoc">Build runtime decode database.</div><div class="ttdef"><b>Definition</b> <a href="dbc__decode__builder_8cpp_source.html#l00014">dbc_decode_builder.cpp:14</a></div></div>
|
||||
<div class="ttc" id="astructDecodeDatabase_html"><div class="ttname"><a href="structDecodeDatabase.html">DecodeDatabase</a></div><div class="ttdoc">Runtime decode database with fast lookup by CAN ID.</div><div class="ttdef"><b>Definition</b> <a href="decode__database_8h_source.html#l00111">decode_database.h:111</a></div></div>
|
||||
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md78"></a>
|
||||
Decode a raw frame</h1>
|
||||
<div class="fragment"><div class="line"><a class="code hl_struct" href="structRawCanFrame.html">RawCanFrame</a> rawFrame;</div>
|
||||
<div class="line">rawFrame.<a class="code hl_variable" href="structRawCanFrame.html#a2d0e7fa0e3d5c20bbed55ed8f7888ff4">canId</a> = 0x123;</div>
|
||||
@@ -592,23 +628,23 @@ Decode a raw frame</h1>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><a class="code hl_class" href="classDbcDecoder.html">DbcDecoder</a> decoder;</div>
|
||||
<div class="line"><a class="code hl_struct" href="structDecodedFrameValue.html">DecodedFrameValue</a> decoded = decoder.<a class="code hl_function" href="classDbcDecoder.html#a345951ffe5d943a70d3a1ea1f39e74f7">Decode</a>(decodeDatabase, rawFrame);</div>
|
||||
<div class="ttc" id="aclassDbcDecoder_html"><div class="ttname"><a href="classDbcDecoder.html">DbcDecoder</a></div><div class="ttdoc">Runtime CAN decoder using prebuilt decode database.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__decoder_8h_source.html#l00070">dbc_decoder.h:70</a></div></div>
|
||||
<div class="ttc" id="aclassDbcDecoder_html_a345951ffe5d943a70d3a1ea1f39e74f7"><div class="ttname"><a href="classDbcDecoder.html#a345951ffe5d943a70d3a1ea1f39e74f7">DbcDecoder::Decode</a></div><div class="ttdeci">DecodedFrameValue Decode(const DecodeDatabase &database, const RawCanFrame &frame) const</div><div class="ttdoc">Decode one raw CAN frame.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__decoder_8cpp_source.html#l00031">dbc_decoder.cpp:31</a></div></div>
|
||||
<div class="ttc" id="astructDecodedFrameValue_html"><div class="ttname"><a href="structDecodedFrameValue.html">DecodedFrameValue</a></div><div class="ttdoc">Fully decoded frame.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__decoder_8h_source.html#l00055">dbc_decoder.h:55</a></div></div>
|
||||
<div class="ttc" id="astructRawCanFrame_html"><div class="ttname"><a href="structRawCanFrame.html">RawCanFrame</a></div><div class="ttdoc">Raw CAN frame used for runtime or trace decoding.</div><div class="ttdef"><b>Definition:</b> <a href="dbc__decoder_8h_source.html#l00023">dbc_decoder.h:23</a></div></div>
|
||||
<div class="ttc" id="astructRawCanFrame_html_a0acb487612104c99c9907344c035df83"><div class="ttname"><a href="structRawCanFrame.html#a0acb487612104c99c9907344c035df83">RawCanFrame::data</a></div><div class="ttdeci">std::vector< std::uint8_t > data</div><div class="ttdef"><b>Definition:</b> <a href="dbc__decoder_8h_source.html#l00026">dbc_decoder.h:26</a></div></div>
|
||||
<div class="ttc" id="astructRawCanFrame_html_a2d0e7fa0e3d5c20bbed55ed8f7888ff4"><div class="ttname"><a href="structRawCanFrame.html#a2d0e7fa0e3d5c20bbed55ed8f7888ff4">RawCanFrame::canId</a></div><div class="ttdeci">std::uint32_t canId</div><div class="ttdef"><b>Definition:</b> <a href="dbc__decoder_8h_source.html#l00024">dbc_decoder.h:24</a></div></div>
|
||||
<div class="ttc" id="astructRawCanFrame_html_a462193d275adc1dba8bd18ffa0e36bb7"><div class="ttname"><a href="structRawCanFrame.html#a462193d275adc1dba8bd18ffa0e36bb7">RawCanFrame::isExtended</a></div><div class="ttdeci">bool isExtended</div><div class="ttdef"><b>Definition:</b> <a href="dbc__decoder_8h_source.html#l00025">dbc_decoder.h:25</a></div></div>
|
||||
<div class="ttc" id="aclassDbcDecoder_html"><div class="ttname"><a href="classDbcDecoder.html">DbcDecoder</a></div><div class="ttdoc">Runtime CAN decoder using prebuilt decode database.</div><div class="ttdef"><b>Definition</b> <a href="dbc__decoder_8h_source.html#l00064">dbc_decoder.h:64</a></div></div>
|
||||
<div class="ttc" id="aclassDbcDecoder_html_a345951ffe5d943a70d3a1ea1f39e74f7"><div class="ttname"><a href="classDbcDecoder.html#a345951ffe5d943a70d3a1ea1f39e74f7">DbcDecoder::Decode</a></div><div class="ttdeci">DecodedFrameValue Decode(const DecodeDatabase &database, const RawCanFrame &frame) const</div><div class="ttdoc">Decode one raw CAN frame.</div><div class="ttdef"><b>Definition</b> <a href="dbc__decoder_8cpp_source.html#l00031">dbc_decoder.cpp:31</a></div></div>
|
||||
<div class="ttc" id="astructDecodedFrameValue_html"><div class="ttname"><a href="structDecodedFrameValue.html">DecodedFrameValue</a></div><div class="ttdoc">Fully decoded frame.</div><div class="ttdef"><b>Definition</b> <a href="dbc__decoder_8h_source.html#l00051">dbc_decoder.h:51</a></div></div>
|
||||
<div class="ttc" id="astructRawCanFrame_html"><div class="ttname"><a href="structRawCanFrame.html">RawCanFrame</a></div><div class="ttdoc">Raw CAN frame used for runtime or trace decoding.</div><div class="ttdef"><b>Definition</b> <a href="dbc__decoder_8h_source.html#l00024">dbc_decoder.h:24</a></div></div>
|
||||
<div class="ttc" id="astructRawCanFrame_html_a0acb487612104c99c9907344c035df83"><div class="ttname"><a href="structRawCanFrame.html#a0acb487612104c99c9907344c035df83">RawCanFrame::data</a></div><div class="ttdeci">std::vector< std::uint8_t > data</div><div class="ttdef"><b>Definition</b> <a href="dbc__decoder_8h_source.html#l00027">dbc_decoder.h:27</a></div></div>
|
||||
<div class="ttc" id="astructRawCanFrame_html_a2d0e7fa0e3d5c20bbed55ed8f7888ff4"><div class="ttname"><a href="structRawCanFrame.html#a2d0e7fa0e3d5c20bbed55ed8f7888ff4">RawCanFrame::canId</a></div><div class="ttdeci">std::uint32_t canId</div><div class="ttdef"><b>Definition</b> <a href="dbc__decoder_8h_source.html#l00025">dbc_decoder.h:25</a></div></div>
|
||||
<div class="ttc" id="astructRawCanFrame_html_a462193d275adc1dba8bd18ffa0e36bb7"><div class="ttname"><a href="structRawCanFrame.html#a462193d275adc1dba8bd18ffa0e36bb7">RawCanFrame::isExtended</a></div><div class="ttdeci">bool isExtended</div><div class="ttdef"><b>Definition</b> <a href="dbc__decoder_8h_source.html#l00026">dbc_decoder.h:26</a></div></div>
|
||||
</div><!-- fragment --><hr />
|
||||
<h1><a class="anchor" id="autotoc_md74"></a>
|
||||
<h1><a class="anchor" id="autotoc_md80"></a>
|
||||
Unified Decode Strategy</h1>
|
||||
<p >A key design goal is that the same decoder should work for both:</p>
|
||||
<p>A key design goal is that the same decoder should work for both:</p>
|
||||
<ul>
|
||||
<li>live CAN frames</li>
|
||||
<li>trace replay frames</li>
|
||||
</ul>
|
||||
<p >That means this architecture supports:</p>
|
||||
<h2><a class="anchor" id="autotoc_md75"></a>
|
||||
<p>That means this architecture supports:</p>
|
||||
<h2><a class="anchor" id="autotoc_md81"></a>
|
||||
live path</h2>
|
||||
<div class="fragment"><div class="line">live CAN input</div>
|
||||
<div class="line"> ↓</div>
|
||||
@@ -617,7 +653,7 @@ live path</h2>
|
||||
<div class="line">DbcDecoder</div>
|
||||
<div class="line"> ↓</div>
|
||||
<div class="line">decoded signal values</div>
|
||||
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md76"></a>
|
||||
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md82"></a>
|
||||
trace path</h2>
|
||||
<div class="fragment"><div class="line">trace reader</div>
|
||||
<div class="line"> ↓</div>
|
||||
@@ -626,11 +662,11 @@ trace path</h2>
|
||||
<div class="line">DbcDecoder</div>
|
||||
<div class="line"> ↓</div>
|
||||
<div class="line">decoded signal values</div>
|
||||
</div><!-- fragment --><p >This avoids duplicating decode logic in two separate parts of the application.</p>
|
||||
</div><!-- fragment --><p>This avoids duplicating decode logic in two separate parts of the application.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md78"></a>
|
||||
<h1><a class="anchor" id="autotoc_md84"></a>
|
||||
Intended Use in FrameTap</h1>
|
||||
<p >This module is meant to support at least the following FrameTap workflows:</p>
|
||||
<p>This module is meant to support at least the following FrameTap workflows:</p>
|
||||
<ul>
|
||||
<li>load a DBC file</li>
|
||||
<li>browse frames and signals</li>
|
||||
@@ -641,7 +677,7 @@ Intended Use in FrameTap</h1>
|
||||
<li>convert raw values into physical values</li>
|
||||
<li>show metadata like units, comments, transmitter, receivers, and PGN</li>
|
||||
</ul>
|
||||
<p >Example combined workflow:</p>
|
||||
<p>Example combined workflow:</p>
|
||||
<div class="fragment"><div class="line">Load DBC</div>
|
||||
<div class="line"> ↓</div>
|
||||
<div class="line">Parse into DbcDatabase</div>
|
||||
@@ -654,31 +690,40 @@ Intended Use in FrameTap</h1>
|
||||
<div class="line"> - live frames</div>
|
||||
<div class="line"> - trace replay</div>
|
||||
</div><!-- fragment --><hr />
|
||||
<h1><a class="anchor" id="autotoc_md80"></a>
|
||||
<h1><a class="anchor" id="autotoc_md86"></a>
|
||||
Why the Tree Is Not Enough</h1>
|
||||
<p >The tree exists for browsing.</p>
|
||||
<p >However, runtime decode should not rely on tree traversal because that would introduce unnecessary coupling and inefficiency.</p>
|
||||
<p >A runtime decoder needs:</p>
|
||||
<p>The tree exists for browsing.</p>
|
||||
<p>However, runtime decode should not rely on tree traversal because that would introduce unnecessary coupling and inefficiency.</p>
|
||||
<p>A runtime decoder needs:</p>
|
||||
<ul>
|
||||
<li>fast key-based access</li>
|
||||
<li>minimal interpretation at decode time</li>
|
||||
<li>direct signal definitions already prepared</li>
|
||||
</ul>
|
||||
<p >That is why <code><a class="el" href="structDecodeDatabase.html" title="Runtime decode database with fast lookup by CAN ID.">DecodeDatabase</a></code> is a separate layer.</p>
|
||||
<p>That is why <code><a class="el" href="structDecodeDatabase.html" title="Runtime decode database with fast lookup by CAN ID.">DecodeDatabase</a></code> is a separate layer.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md82"></a>
|
||||
Why No Abstract Factory Is Used</h1>
|
||||
<p >At the current stage, abstract factory is intentionally avoided.</p>
|
||||
<p >The current design is already clean:</p>
|
||||
<div class="fragment"><div class="line">parser → parsed database → decode database</div>
|
||||
<div class="line"> ↘ tree builder → UI tree</div>
|
||||
</div><!-- fragment --><p >Introducing factory layers now would increase complexity without solving an immediate problem.</p>
|
||||
<p >If later the project requires multiple output representations or multiple build strategies, that can be added then.</p>
|
||||
<h1><a class="anchor" id="autotoc_md88"></a>
|
||||
Statement Handler Factory</h1>
|
||||
<p><code><a class="el" href="classDbcParser.html" title="Minimal DBC parser.">DbcParser</a></code> owns file reading, trimming, line numbers, and error reporting. Each <code>ParseFile()</code> call creates a fresh <code><a class="el" href="structDbcParseContext.html">DbcParseContext</a></code> and a <code><a class="el" href="classDbcStatementDispatcher.html">DbcStatementDispatcher</a></code>. The context contains the parsed database and current frame; handlers receive it by reference and retain no parsing state.</p>
|
||||
<p>The dispatcher uses <code><a class="el" href="classTypeFactory.html" title="Registry-based factory for creating objects by runtime identifier.">TypeFactory</a><std::string, <a class="el" href="classDbcStatementHandler.html">DbcStatementHandler</a>></code> to create registered handlers once per parsing session, then reuses them for all matching lines:</p>
|
||||
<ul>
|
||||
<li><code>BO_</code> → <code><a class="el" href="classDbcFrameHandler.html">DbcFrameHandler</a></code></li>
|
||||
<li><code>SG_</code> → <code><a class="el" href="classDbcSignalHandler.html">DbcSignalHandler</a></code></li>
|
||||
<li><code>CM_</code> → <code><a class="el" href="classDbcCommentHandler.html">DbcCommentHandler</a></code></li>
|
||||
</ul>
|
||||
<p>Grammar implementations live in <code><a class="el" href="dbc__statement__handler_8cpp_source.html">dbc_statement_handler.cpp</a></code>; their interface, context, and dispatcher live in <code><a class="el" href="dbc__statement__handler_8h_source.html">dbc_statement_handler.h</a></code>. <code><a class="el" href="typefactory_8h_source.html">typefactory.h</a></code> provides the generic registry and object creation.</p>
|
||||
<p>To add a construct, implement a default-constructible handler deriving from <code><a class="el" href="classDbcStatementHandler.html">DbcStatementHandler</a></code> with:</p>
|
||||
<div class="fragment"><div class="line"><span class="keywordtype">void</span> Handle(<span class="keyword">const</span> std::string &line, <a class="code hl_struct" href="structDbcParseContext.html">DbcParseContext</a> &context) <span class="keyword">const override</span>;</div>
|
||||
<div class="ttc" id="astructDbcParseContext_html"><div class="ttname"><a href="structDbcParseContext.html">DbcParseContext</a></div><div class="ttdef"><b>Definition</b> <a href="dbc__statement__handler_8h_source.html#l00011">dbc_statement_handler.h:11</a></div></div>
|
||||
</div><!-- fragment --><p>Register it in the dispatcher constructor:</p>
|
||||
<div class="fragment"><div class="line">RegisterType<DbcValueHandler>(<span class="stringliteral">"VAL_"</span>); <span class="comment">// after implementing DbcValueHandler</span></div>
|
||||
</div><!-- fragment --><p>Registration creates one handler; replacing a registration replaces that instance. Register during initialization before dispatching. A line is routed using its full first whitespace-delimited keyword, so <code>BO_TX_BU_</code> cannot match <code>BO_</code>. Unregistered keywords remain ignored. <code>SG_</code> accepts spaces and tabs after its keyword; <code>CM_</code> retains its existing policy requiring a literal space.</p>
|
||||
<p>This factory handles statements inside DBC files. A separate format-level factory can be introduced when another file format is implemented. The decoder and database builders remain independent of statement dispatch.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md84"></a>
|
||||
<h1><a class="anchor" id="autotoc_md90"></a>
|
||||
Current Limitations</h1>
|
||||
<p >This is still a minimal implementation.</p>
|
||||
<p >Not supported yet:</p>
|
||||
<p>This is still a minimal implementation.</p>
|
||||
<p>Not supported yet:</p>
|
||||
<ul>
|
||||
<li>multiplexed signals</li>
|
||||
<li><code>VAL_</code> tables</li>
|
||||
@@ -689,12 +734,12 @@ Current Limitations</h1>
|
||||
<li>full J1939 validation</li>
|
||||
<li>extensive edge-case handling for unusual DBC formatting</li>
|
||||
</ul>
|
||||
<p >Motorola extraction is implemented, but it should still be verified carefully against real-world DBC files and expected values.</p>
|
||||
<p>Motorola extraction is implemented, but it should still be verified carefully against real-world DBC files and expected values.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md86"></a>
|
||||
<h1><a class="anchor" id="autotoc_md92"></a>
|
||||
Recommended Next Steps</h1>
|
||||
<p >A practical development order would be:</p>
|
||||
<h2><a class="anchor" id="autotoc_md87"></a>
|
||||
<p>A practical development order would be:</p>
|
||||
<h2><a class="anchor" id="autotoc_md93"></a>
|
||||
Stage 1 - already implemented</h2>
|
||||
<ul>
|
||||
<li><code>BO_</code></li>
|
||||
@@ -709,9 +754,9 @@ Stage 1 - already implemented</h2>
|
||||
<li>runtime decode database</li>
|
||||
<li>runtime decoder</li>
|
||||
</ul>
|
||||
<h2><a class="anchor" id="autotoc_md88"></a>
|
||||
<h2><a class="anchor" id="autotoc_md94"></a>
|
||||
Stage 2</h2>
|
||||
<p >Recommended additions:</p>
|
||||
<p>Recommended additions:</p>
|
||||
<ul>
|
||||
<li>parent pointer in <code><a class="el" href="classTreeNode.html" title="Tree node for later use in model/view or other hierarchy consumers.">TreeNode</a></code></li>
|
||||
<li>Qt model adapter</li>
|
||||
@@ -719,9 +764,9 @@ Stage 2</h2>
|
||||
<li>better display strings for UI</li>
|
||||
<li>selective decoding of only chosen signals</li>
|
||||
</ul>
|
||||
<h2><a class="anchor" id="autotoc_md89"></a>
|
||||
<h2><a class="anchor" id="autotoc_md95"></a>
|
||||
Stage 3</h2>
|
||||
<p >Recommended additions:</p>
|
||||
<p>Recommended additions:</p>
|
||||
<ul>
|
||||
<li>multiplexing support</li>
|
||||
<li>attribute parsing</li>
|
||||
@@ -729,9 +774,9 @@ Stage 3</h2>
|
||||
<li>CSV export of decoded traces</li>
|
||||
<li>optimized filtering and signal selection</li>
|
||||
</ul>
|
||||
<h2><a class="anchor" id="autotoc_md90"></a>
|
||||
<h2><a class="anchor" id="autotoc_md96"></a>
|
||||
Stage 4</h2>
|
||||
<p >Advanced functionality:</p>
|
||||
<p>Advanced functionality:</p>
|
||||
<ul>
|
||||
<li>live plot integration</li>
|
||||
<li>signal subscriptions</li>
|
||||
@@ -739,49 +784,52 @@ Stage 4</h2>
|
||||
<li>decoder-assisted export formats</li>
|
||||
</ul>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md92"></a>
|
||||
<h1><a class="anchor" id="autotoc_md98"></a>
|
||||
Build Integration</h1>
|
||||
<p >The module does not depend on any specific build system.</p>
|
||||
<p >It can be integrated with:</p>
|
||||
<p>The module does not depend on any specific build system.</p>
|
||||
<p>It can be integrated with:</p>
|
||||
<ul>
|
||||
<li>CMake</li>
|
||||
<li>qmake</li>
|
||||
<li>Makefile</li>
|
||||
</ul>
|
||||
<p >Just add the source files to the project.</p>
|
||||
<p>Just add the source files to the project.</p>
|
||||
<hr />
|
||||
<h1><a class="anchor" id="autotoc_md94"></a>
|
||||
<h1><a class="anchor" id="autotoc_md100"></a>
|
||||
Summary</h1>
|
||||
<p >This module is now split into two intentionally separate layers:</p>
|
||||
<h2><a class="anchor" id="autotoc_md95"></a>
|
||||
<p>This module is now split into two intentionally separate layers:</p>
|
||||
<h2><a class="anchor" id="autotoc_md101"></a>
|
||||
Parsed representation</h2>
|
||||
<p >Used for:</p>
|
||||
<p>Used for:</p>
|
||||
<ul>
|
||||
<li>storing parsed DBC content</li>
|
||||
<li>browsing</li>
|
||||
<li>UI tree generation</li>
|
||||
</ul>
|
||||
<h2><a class="anchor" id="autotoc_md96"></a>
|
||||
<h2><a class="anchor" id="autotoc_md102"></a>
|
||||
Runtime decode representation</h2>
|
||||
<p >Used for:</p>
|
||||
<p>Used for:</p>
|
||||
<ul>
|
||||
<li>fast frame lookup</li>
|
||||
<li>live CAN decode</li>
|
||||
<li>trace decode</li>
|
||||
<li>physical value conversion</li>
|
||||
</ul>
|
||||
<p >That separation is the main architectural improvement.</p>
|
||||
<p >In short, the system now looks like this:</p>
|
||||
<p>That separation is the main architectural improvement.</p>
|
||||
<p>In short, the system now looks like this:</p>
|
||||
<div class="fragment"><div class="line">DBC parser → DbcDatabase → DecodeDatabase → DbcDecoder</div>
|
||||
<div class="line"> ↘ TreeNode → future UI</div>
|
||||
</div><!-- fragment --><p >This gives FrameTap a much better foundation for real use, because both browsing and decoding are supported without forcing one representation to do the other's job. </p>
|
||||
</div><!-- fragment --><p>This gives FrameTap a much better foundation for real use, because both browsing and decoding are supported without forcing one representation to do the other's job.</p>
|
||||
<h1><a class="anchor" id="autotoc_md103"></a>
|
||||
Regression tests</h1>
|
||||
<p>See <a class="el" href="md_tests_2README.html">tests/README.md</a> for compiler and qmake commands. Tests cover frame validation and error locations, Intel and Motorola extraction, signed and unsigned 64-bit boundaries, physical conversion, numeric output, and invalid signal payloads. </p>
|
||||
</div></div><!-- contents -->
|
||||
</div><!-- PageDoc -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- start footer part -->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in new issue
Block a user