Closes #10
This commit is contained in:
1 parent
a533d9aa00
commit
a0938cb29c
14 files changed
+375
-13
No files matched your search
@@ -381,6 +381,7 @@ Fields:
|
||||
- `rawValue`
|
||||
- `physicalValue`
|
||||
- `valid`
|
||||
- `status`
|
||||
|
||||
---
|
||||
|
||||
@@ -444,7 +445,7 @@ Main runtime decoder class.
|
||||
Responsibilities:
|
||||
|
||||
- find a frame definition by CAN ID
|
||||
- decode all signals in a frame
|
||||
- decode unconditional signals and the active multiplexed branch
|
||||
- extract raw values
|
||||
- sign-extend signed values
|
||||
- convert raw values into physical values
|
||||
@@ -465,6 +466,7 @@ The current parser supports the following DBC elements:
|
||||
- `CM_ BO_`
|
||||
- `CM_ SG_`
|
||||
- `VAL_` signal value descriptions
|
||||
- basic `M` / `mN` multiplexing
|
||||
|
||||
---
|
||||
|
||||
@@ -560,15 +562,64 @@ 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.
|
||||
|
||||
Multiplexing markers (`M`, `mN`, and combinations) are currently rejected rather
|
||||
than interpreted as part of a signal name. Multiplexing support and duplicate
|
||||
frame/signal detection remain separate work.
|
||||
Basic multiplexing markers `M` and `mN` are supported as described below.
|
||||
Overlapping signals are rejected unless their branch values differ.
|
||||
Duplicate frame/signal name detection remains separate work.
|
||||
|
||||
Invalid signal definitions stop parsing with `path:line: description`, including
|
||||
when the signal exceeds the declared payload length.
|
||||
|
||||
---
|
||||
|
||||
## Basic multiplexing
|
||||
|
||||
```dbc
|
||||
BO_ 256 Status: 3 ECU
|
||||
SG_ Mode M : 0|8@1+ (1,0) [0|255] "" ECU
|
||||
SG_ Temperature m1 : 8|8@1- (1,0) [-128|127] "C" ECU
|
||||
SG_ Pressure m2 : 8|8@1+ (2,0) [0|510] "kPa" ECU
|
||||
SG_ Counter : 16|8@1+ (1,0) [0|255] "" ECU
|
||||
```
|
||||
|
||||
`SignalInfo` and `DecodeSignal` contain `multiplexing`: a `MultiplexRole`
|
||||
(`Unconditional`, `Selector`, or `Branch`) and an exact `uint64_t` branch `value`.
|
||||
Each frame may have one unsigned selector (`M`); a branch (`mN`) references that
|
||||
selector implicitly. The selector may appear after its branches. `N` must contain
|
||||
only decimal digits, fit `uint64_t`, and fit the selector's bit width. Leading
|
||||
zeros are accepted. A selector without branches is allowed. Signed selectors,
|
||||
missing selectors, multiple selectors, nested/combined markers, and extended
|
||||
`SG_MUL_VAL_` statements are rejected with the originating `path:line`.
|
||||
The dispatcher registers the unsupported statement handler through `TypeFactory`.
|
||||
|
||||
Signal bits may overlap only between branches with different selector values.
|
||||
This validation uses Intel or Motorola bit traversal, including mixed byte orders.
|
||||
It also rejects overlapping unconditional signals. Metadata survives the runtime
|
||||
and tree builders; the optional Qt adapter does not add multiplexing roles yet.
|
||||
|
||||
The shared decoder extracts the selector before processing branches, compares its
|
||||
**raw unsigned value**, and leaves result order equal to definition order. Factor,
|
||||
offset, and `VAL_` descriptions do not influence branch selection. Unconditional
|
||||
signals continue to decode. An unmapped selector value leaves all branches inactive.
|
||||
|
||||
Each result has `SignalDecodeStatus status`:
|
||||
|
||||
| Status | Meaning |
|
||||
| --- | --- |
|
||||
| `Valid` | Raw and physical values are available; `valid == true` |
|
||||
| `Inactive` | Selector is available and chooses another branch |
|
||||
| `SelectorUnavailable` | Branch activation is unknown because selector bytes are missing |
|
||||
| `InsufficientPayload` | Selected or unconditional signal bytes are missing |
|
||||
| `InvalidDefinition` | Invalid bit length or missing/invalid selector in manually built runtime metadata |
|
||||
|
||||
All statuses except `Valid` have `valid == false`; their numeric fields contain
|
||||
no decoded data and `GetValueDescription()` returns nullptr. Check `status` to
|
||||
distinguish inactive branches from errors. Consumers constructing runtime metadata
|
||||
manually must obey the same non-overlap rules as the parser. Extended and nested
|
||||
multiplexing are outside this stage and are explicitly rejected, rather than
|
||||
silently decoded as unconditional signals.
|
||||
|
||||
---
|
||||
|
||||
## Comments
|
||||
|
||||
Frame comment example:
|
||||
@@ -631,7 +682,8 @@ RawCanFrame
|
||||
↓
|
||||
Find frame in DecodeDatabase
|
||||
↓
|
||||
For each signal:
|
||||
Extract multiplexor selector first (when present)
|
||||
For each unconditional or active signal:
|
||||
extract raw bits
|
||||
apply sign extension if needed
|
||||
convert to physical value
|
||||
@@ -895,7 +947,7 @@ This is still a minimal implementation.
|
||||
|
||||
Not supported yet:
|
||||
|
||||
- multiplexed signals
|
||||
- extended and nested multiplexing (`SG_MUL_VAL_`, `mNM`)
|
||||
- named `VAL_TABLE_` tables and environment-variable value descriptions
|
||||
- `BA_` attributes
|
||||
- `BA_DEF_` definitions
|
||||
@@ -949,7 +1001,7 @@ Recommended additions:
|
||||
|
||||
Recommended additions:
|
||||
|
||||
- multiplexing support
|
||||
- basic multiplexing (implemented)
|
||||
- attribute parsing
|
||||
- richer J1939 support
|
||||
- CSV export of decoded traces
|
||||
|
||||
Reference in new issue
Block a user