SAE J1939 Programming with Arduino - ARD1939 Function Overview
This post is part of a series about SAE J1939 ECU Programming & Vehicle Bus Simulation with Arduino.
The programming of every serial communication (such as RS232, CAN, Ethernet, just to name a few) should follow a very simple sequence:
- 2.Read data
- 3.Write data
- 4.Check status
These four function calls should be everything a programmer needs to access the serial protocol, and there is no reason why an SAE J1939 protocol stack implementation should not follow the same scheme. Digging inside complex code in order to understand how to access protocol functions is simply a waste of time.
Unfortunately, most commercially available protocol stacks shine through complexity and/or lack of documentation. To mention it upfront, the ARD1939 protocol stack requires only very few function calls and thus enables the programmer to put the protocol into use in a very short time.
The functions available to the SAE J1939 application layer (i.e. your program) are:
- j1939.Init – Initializes the protocol stack settings
- j1939.SetPreferredAddress – Sets the preferred node (source) address
- j1939.SetNAME – Sets the ECU’s NAME using the individual parameters
- j1939.SetMessageFilter – Sets the PGNs to be processed in your application
Read/Write – Check Status
- j1939.Operate – Handles the address claim process, reads PGNs from the vehicle network, and delivers the current protocol status (Address Claim in progress, Address Claim successful, Address Claim failed)
- j1939.Transmit – Transmits data to the vehicle network and handles the Transport Protocol (TP)
Other Application Functions
- j1939.Terminate – Resets the protocol stack settings
- j1939.GetSourceAddress – Delivers the negotiated node address
- j1939.DeleteMessageFilter – Deletes a message filter
For a detailed description of these function calls, please refer to the appendix “ARD1939 Protocol Stack Reference.”
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.