Closes #3 Validate DBC frame definitions and report error locations

This commit is contained in:
deeaitch committed 2026-10-01 13:23:01 -04:00
1 parent 69074e3321
commit 3bd9339baf
6 files changed
+213 -36

No files matched your search

+32 -1
View File
@@ -505,6 +505,36 @@ Parsed fields:
---
### Frame validation and parse errors
`BO_` 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.
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 `0x7FF` are still treated as extended.
The payload length must fit `uint8_t` (`0..255`). This is a storage-range check,
not CAN or CAN FD protocol validation; no new 8-byte or 64-byte limit is imposed.
Parsing stops at the first detected error. Exceptions raised while parsing a
line are reported as `std::runtime_error` with the supplied file path and the
one-based physical line number, including blank lines:
```text
example.dbc:3: Invalid CAN ID: invalid
```
This change validates frame definitions. Signal syntax and unsupported DBC
constructs retain their existing behavior; comprehensive validation is still
planned. File-open errors contain the path but have no line number.
---
## Signal definition
Example:
@@ -871,5 +901,6 @@ This gives FrameTap a much better foundation for real use, because both browsing
## Regression tests
See [tests/README.md](tests/README.md) for compiler and qmake commands.
Tests cover Intel and Motorola extraction, signed and unsigned 64-bit boundaries,
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.