Fix: J1939 decoded wrong values from wrong bytes and wrong messages - #28
Merged
Merged
Conversation
The PGN table produced confident wrong numbers. Checked against SAE J1939-71 and against the 145,534-frame truck log in the corpus: - Coolant temperature was read from byte 6 of EFL/P1, which is half of the crankcase pressure. It lives in ET1, which was not decoded at all. - 0xF005 was labelled ETC1; it is ETC2, and its three fields were at the wrong bytes. EBC2's wheel speeds were filed under 0xFE68 and ERC1 under 0xF006. - VEP battery voltages were read from the current bytes, barometric pressure from cab temperature's low byte, oil level from the blow-by byte. - Cruise control active and enable were whole-byte reads of byte 1, the parking brake and axle switch byte: "Cruise Control Active = 195". - Only all-ones was treated as "not available", so J1939 error codes (0xFE, 0xFExx) and reserved ranges were decoded as readings. - Most source address names did not match the preferred address table: 0x21 was "Brakes" (it is the body controller; brakes are 0x0B). - The scan kept the first sender of each PGN and dropped the rest, so DM1 from nine ECUs was one row with one ECU's count. The table now lives in core/j1939_db.py as bit fields: 26 decoded PGNs with 152 parameters, 30 more named, the preferred address table, two-bit states, error and reserved ranges, park as a gear, ASCII ranges. The scan is a row per PGN and sender. On the truck log the corrected layouts agree with each other: the brakes' front axle speed and the engine's wheel speed differ by 0.33 km/h over 1,957 pairs (r 0.9997); absolute inlet pressure minus boost is the barometer; VD and HRVD give the same 464,671 km; lifetime distance over fuel matches the ECU's reported economy to 0.5%. Those checks are now in the stress run, and 22 unit tests pin the layouts with frames copied from the truck.
Sherin-SEF-AI
force-pushed
the
fix/j1939-layouts
branch
from
September 23, 2026 18:49
3baff97 to
c9b77b3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defects
The J1939 table produced confident wrong numbers, and nothing tested a layout. Checked against SAE J1939-71 and against the 145,534-frame truck log in the acceptance corpus:
0xF005labelled ETC1, fields at the wrong bytes0xF005is ETC2; ETC1 is0xF0020xFE68, ERC1 under0xF0060xFEBF,0xF0000xFE,0xFExx) and reserved ranges handled0x21"Brakes",0x3D"Retarder", most others0x0Bis the brakes)The fix
canlab/core/j1939_db.pyholds the layouts as bit fields: 26 decoded PGNs, 152 parameters, 30 more named, Proprietary B named as such, the preferred source address table, two-bit states, error and reserved ranges, park as a gear, ASCII transmission ranges.decode_pgnkeeps its return shape; an error code is the string"error", and not-available is left out.decode_spnsreturns SPN numbers and status for tools that need to cite them.Verified on the real truck
Those checks are now in
acceptance_stress.py(7/7).tests/test_j1939_spns.pypins 22 layouts with frames copied from the truck, plus the value ranges, no overlapping parameters, and the per-sender scan.pytest -q: 699 passed.acceptance_new_sources.py: 57/57. ruff clean.