Skip to content

Keep full DLC, bit length, scale, and enum values - #11

Merged
ip332 merged 1 commit into
issue-4from
issue-8
Nov 19, 2026
Merged

ip332 merged 1 commit into
issue-4from
issue-8

Conversation

@ip332

@ip332 ip332 commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • PGN::dlc_ and SPN::length_ are uint16_t. Scale and offset are double taken from the DBC decimal text, so a factor such as 1e-7 is no longer rounded through float.
  • Enum keys are uint64_t. VAL_ values are parsed with strtoull. An empty value, a leading -, trailing junk, or a value past 2^64−1 fails the file. The generated C enum value is uint64_t as well.
  • make_mask shifts 1ull. Length 0 and length above 64 return 0. read_bits and write_bits refuse those lengths and cast the big-endian byte to uint64_t before shifting.
  • The PGN table keeps every multiplex alternative. Two plain signals at the same start bit fail the compile. The packed union still carries the first signal at a start bit, because a bitfield cannot overlay two fields.

Closes #8.

This branch is based on issue-4 (PR #10). The diff here is only the type fix.

Test plan

  • Hand-built parser gtests on macOS (169 tests), including the j1939.dbc round-trip against the C database
  • CI all_tests and coverage (needs Linux; linux/can.h is not available on this Mac)

PGN::dlc_ and SPN::length_ are uint16_t. Scale and offset stay double
from the DBC decimal text. Enum keys are uint64_t, parsed with
strtoull, and a value that does not fit fails the file.

make_mask shifts 1ull. Length 0 and length above 64 are refused.
read_bits casts the big-endian byte to uint64_t before the shift.

The PGN table keeps every multiplex alternative. Two plain signals at
the same start bit fail the compile. The packed union still keeps the
first signal at a start bit.
@ip332
ip332 merged commit f46fc74 into issue-4 Nov 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant