SAE J1939 Programming with Arduino - Special Programming Topics
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino.
Each programmer has his/her own coding style, and I am most certainly no exception. Nevertheless, code should always be written with the following aspects in mind:
- High level of readability, including plenty of comments (you will have trouble decoding your own programming only weeks after you looked at it the last time)
- Easy debugging (readability helps here, too)
- Possible memory restraints (applies especially to the Arduino Uno)
- Keep It Simple Stupid (it doesn’t make any sense spending valuable time analyzing/documenting overly complex structures, enum arrays, etc. unless they provide great advantages in respect to performance)
With my particular programming style, I try to follow these rules, especially under the aspect that I am sharing my code with a large community. If the code isn’t simple and intuitive enough for my readers to figure it out without asking any questions, it usually will be rejected.
SAE J1939 has become the accepted industry standard and the vehicle network technology of choice for off-highway machines in applications such as construction, material handling, and forestry machines. J1939 is a higher-layer protocol based on Controller Area Network (CAN). It provides serial data communications between microprocessor systems (also called Electronic Control Units - ECU) in any kind of heavy duty vehicles. The messages exchanged between these units can be data such as vehicle road speed, torque control message from the transmission to the engine, oil temperature, and many more.
A Comprehensible Guide to J1939 is the first work on J1939 besides the SAE J1939 standards collection. It provides profound information on the J1939 message format and network management combined with a high level of readability.