Repository navigation
Closed
Description
What happens
Several fields are narrowed or rounded while the DBC is copied into PGN / SPN, so a generated table cannot represent the file even before lookup.
- DLC.
Message::dlc_isuint16_t.PGN::dlc_isuint8_t(j1939_frame.h), andMessage::toPgnassigns it across.J1939_frame::max_dlc_is 1758 because a transport-protocol payload can be that long. Any nominal length above 255 is truncated.toStringPgnprintspgn.dlc_rather than the frame length it actually holds. - Signal length.
Signal::length_isuint16_t.SPN::length_isuint8_t, filled bySignal::toSpn. A signal longer than 255 bits is truncated. Independently,read_bits/write_bitsandsignalRawValuereturn a singleuint64_t, so a VIN, a NAME-adjacent text field, or any NMEA string longer than 64 bits cannot round-trip.make_maskspecial-cases 64 and otherwise does1ul << length.unsigned longis 32 bits on LLP64 and on many 32-bit ECUs, so lengths from 32 to 63 are undefined there. Lengths above 64 are undefined everywhere. - Scale and offset.
Signalparses the DBC factor withstd::stofinto afloat.SPN::scalar_andSPN::offset_arefloat.min_/max_aredouble. Factors such as1e-7or a long decimal do not survivefloat, andtoDoublecannot recover the bits that were already rounded.setSignalValuethen divides by thatfloat. - Enums.
Signal::addValueparses the numeric value withstd::stoi(signed 32-bit) and stores it instd::map<uint32_t, std::string>. A value outsideintthrows. A value above2^31-1cannot be stored as the unsigned raw bit pattern it is on the wire. The same function writes every enum label tostd::cout, so compiling a DBC that hasVAL_records spams the compiler's stdout. - Duplicate start bits.
Message::signals_isstd::map<uint16_t, Signal>andaddSignalusesemplace. A second signal with the same start bit (the usual shape of a multiplex) is discarded with no diagnostic.
Expected
The C database in the companion proposal uses uint16_t for DLC and bit length, double (or an exact decimal rational) for scale and offset, and an enum value wide enough for the signal (uint64_t). make_mask should be 1ull << length for length < 64, with length 0 and length 64 as explicit cases, and should refuse length > 64 for integer signals.
addValue should not print. A dropped or truncated field should be a compiler error, not a silent narrowing.
Metadata
Metadata
Assignees
Labels
No labels
Activity
ip332 commentedon Nov 19, 2026
Fixed in #11.
PGN::dlc_andSPN::length_areuint16_t. Scale and offset stay double from the DBC decimal text. Enum keys areuint64_t, and aVAL_value that does not fit fails the file.make_maskshifts1ull. The PGN table keeps every multiplex alternative. Two plain signals at the same start bit fail the compile.The pull request is based on
issue-4(#10), so the diff is only this type fix.