jCOM1939-Protocol
jCOM1939-Protocol
All operating modes allow the reception of up to 1785 bytes per message, while the
Communication operating mode also allows the transmission of up to 1785 bytes per
message (BAM or RTS/CTS Session).
The Communication operating mode engages the full Address Claim procedure,
requiring a NAME, a preferred source address (SA), and an optional address range (in
case the preferred SA is already taken).
START-UP SEQUENCE
The start-up sequences for each mode are:
Listen-Only:
1. Send RESET command, which also initializes the CAN baud rate (250/500 kbps).
2. Set all filters (ADDFILTER command).
3. Operation starts with setting the first filter.
Communication:
1. Send RESET command, which also initializes the CAN baud rate (250/500 kbps).
2. Initiate Address Claim Process and set operating mode using the SETPARAM or
SETPARAM1 command.
3. When using the SETPARAM1 command, the gateway responds with REPSTATUS
message.
4. After successful address claim (check status per REPSTATUS message), data
transmission is enabled.
5. Set all filters (ADDFILTER command).
6. Receiving messages is enabled with setting the first filter.
2
MESSAGE FORMAT
The jCOM.J1939 protocol defines two special tokens, START and ESC. START has the
value of 192 decimal and ESC has the value of 219 decimal.
Data is sent to and from the jCOM.J1939 gateway using the industry standard method of
byte stuffing. Byte stuffing is the process of inserting additional tokens when the START
or ESC tokens are part of the data field.
All messages start with a START token, and due to byte stuffing, a START token can
never appear in any other part of the message. If the value of 192 is contained in the
message length, data field, or checksum, an ESC token is inserted into the data stream
followed by a 220, this indicates a value of 192. If an ESC token appears in the message
length, data field, or checksum, an ESC token is inserted into the stream followed by a
221, this indicates a value of 219.
All messages must be byte stuffed, following the START token, by the transmitter and
unstuffed by the receiver.
To send a packet, the transmitting device starts by sending a START character followed
by the size of the data to follow, along with the data and the checksum of the packet.
The message length is a 2-byte field (MSB first, followed by LSB) equal to the size of the
data field plus checksum, both before byte stuffing.
The checksum is a 2’s complement checksum over the length and data fields and is
calculated before byte stuffing has been added.
3
WHAT IS A 2’S COMPLEMENT CHECKSUM?
A checksum is a technique to check data for transmission errors or tampering. If the last
few bytes are the sum of all the preceding bytes, then any errors are likely to be
detected.
In this case, the checksum is the sum of all bytes between the data length field (MSB)
and the last byte of the actual data field, ignoring any carry, meaning the checksum is
always 8 bits long (0 to 255).
MESSAGES
This chapter describes the commands sent to and received from the gateway.
Note: All message definitions are documented in their unstuffed representation. All
highlighted sections represent the data field.
Every message is part of the data field, and it starts with a message identifier. This is an
eight-bit value that tells the receiver what type of message follows. This is followed by
one or more additional data field(s), depending on the message. The message
identifiers, data fields, responses, etc. are documented for each message in the
following chapters.
4
TXDATA 3 Transmit Data Host ACK
RXDATA 4 Receive Data Gateway -
RESET 5 Reset jCOM.J1939.USB Host ACK
HEART 6 Heartbeat Gateway -
SETPARAM 7 Set Protocol Parameters Host ACK
REQINFO 8 Request Information Host REPSTATUS or
RXDATA or
VERSION
REPSTATUS 9 Report Protocol Status Gateway -
FLASH 10 Starts flash programmer Host ACK
SETACK 11 Set Acknowledgement Host ACK
SETHEART 12 Set Heartbeat Frequency Host ACK
VERSION 13 Report HW/SW Version Gateway -
SETPARAM1 14 Set Protocol Parameters Host ACK
With REPSTATUS response
SETMSGMODE 15 Set Message Mode Host ACK
TXDATAL 16 Transmit Data Loopback Host ACK
TXDATAP 17 Periodic Data Transmission Host ACK
TXDATAPL 18 TXDATAP with Loopback Host ACK
Note: This list of messages is sorted by message ID. The original protocol included only
the first 10 messages and further messages were added over time. In order to maintain
a strict backwards compatibility, the function of a message, once established, will
remain unchanged. Any additional or modified functionality is accomplished through
new messages (as an example, see the original TXDATA and the added TXDATAL
messages).
5
With REPSTATUS response
SETMSGMODE2 143 Set Message Mode Host ACK
TXDATAL2 144 Transmit Data Loopback Host ACK
TXDATAP2 145 Periodic Data Transmission Host ACK
TXDATAPL2 146 TXDATAP with Loopback Host ACK
Note: These messages are only implemented in our dual-port gateways. The single-port
gateways will not respond to them.
ACK – Acknowledgment
This message is sent by the jCOM.J1939to acknowledge the correct receipt of a message
from the host system. ACK will not be transmitted in cases where the checksum is wrong
or byte-stuffing errors were detected.
Note:
• The ACK message can be suppressed through the SETACK message.
Message Identifier: 0
Total Length: 6 bytes
Response: -
Note:
• The jCOM.J1939 gateway will, per default, not pass on any data messages unless
their associated PGN is set (ADDFILTER command).
6
• Setting filters referring to PGNs used for Address Claim or Network Management
will be ignored, i.e. the gateway reports only data and request PGNs.
• To enable SAE J1939 request messages (PGN = 0xEAxx), it is sufficient to use the
base PGN 0xEA00 (59904) or any PGN in the range from 0xEA00 to 0xEAFF,
which will enable the entire range.
Message Identifier: 1
Total Length: 8 bytes
Response: ACK
Note:
• The gateway will, per default, not pass on any data messages unless their
associated PGN is set (ADDFILTER command).
Message Identifier: 2
Total Length: 8 bytes
Response: ACK
7
TXDATA – Transmit Data
This message schedules a J1939 message for transmission. The message will be sent as
soon as the J1939 network allows.
Note:
• The gateway will not transmit any data during the Address Claim process (applies
only to the Communication operating mode), which can last up to several
hundreds of milliseconds.
• A J1939 message can be between 0 and 1785 bytes long. If a message is longer
than 8 bytes, the jCOM.J1939 gateway will, depending on the destination
address, manage the transmission per broadcast (BAM) or peer-to-peer
(RTS/CTS) session.
• The jCOM.J1939 gateway will allow you the use of a random source address,
provided that the address claim process was finished successfully. It is highly
recommended using the negotiated source address (obtained through the
REPSTATUS message). Nevertheless, this feature is provided for maximum
flexibility.
Message Identifier: 3
Total Length: Variable (19 with 8 data bytes)
Response: ACK
8
will be reflected back to the host system (which is a mandatory feature for gateway
applications).
Message Identifier: 16
Total Length: Variable (19 with 8 data bytes)
Response: ACK
Note:
• The message frequency (in units of milliseconds) is submitted using two bytes,
thus allowing a maximum time of 65.536 seconds.
• The minimum message frequency is limited to 10 milliseconds.
• A message frequency = 0 will disable (delete) the message.
• The gateway allows up to 50 periodic messages. The DUO version supports 25
periodic messages per port.
Important!
In accordance with the SAE j1939 protocol, the periodic transmission of PGNs
applies only to regular 8-byte data frames, i.e. any messages requiring the
9
Transport protocol (up to 1785 bytes) will be ignored and the message will not
be acknowledged.
Note:
• The gateway will not forward any data as long as the filters are not set.
• The gateway will also not forward any data during the Address Claim process
(applies only to the Communication operating mode).
Message Identifier: 4
Total Length: Variable (19 with 8 data bytes)
Response: -
10
3 MSG_ID_RX 4
4 PGN MSB xx
5 PGN 2ND xx
6 PGN LSB xx
7 Destination Address xx
8 Source Address xx
9 Priority 0…7
10 Data Field Start xx
:
:
nn CHKSUM xx
The purpose of the RESET command is for synchronizing the gateway with the host
system. The gateway’s settings will not be affected by a host system power-down,
meaning all filter settings plus negotiated address will remain active. To prevent any
synchronization issues, it is therefore recommended to issue the RESET command as
soon as the host system powers down or starts up.
CAN Baud Rate Switching – The RESET command also allows initializing the gateway
with a CAN baud rate of 250 kbps or 500 kbps. To do so, modify the “Reset Key 3” value
as shown in the message format description below.
Note:
• The gateway-reset command does not affect the heartbeat frequency or ACK
message settings.
Message Identifier: 5
Total Length: 8 bytes
Response: ACK
11
0x5B for 500 kbps
7 CHKSUM xx
HEART - Heartbeat
This message is per default being transmitted with a one second frequency; it is being
used as a so-called “watchdog” function to monitor the serial connection functionality.
The message contains the hardware and software versions in a form of A.BB.CC (for
instance, 1.02.03):
• A - Major Update
• BB - Minor Update
• CC - Bug Fix
Following the hardware and software versions are two error counters that allow an
insight into the quality of the serial connection:
• Checksum Error
• Byte Stuffing Error
Please be aware that the range of these counters is from 0 to 255, where, at a count
greater than 255, the counter will start at zero again. However, action should be taken
as soon as a certain (project-specific) count has been reached.
The heartbeat message frequency can be adjusted through the SETHEART message,
which also allows suppressing the heartbeat.
Message Identifier: 6
Total Length: 13 bytes
Response: -
12
10 ERRCNT_CHECKSUM xx
11 ERRCNT_STUFFING xx
12 CHKSUM xx
With using the SETPARAM1 command, as soon as the address claim process is finished
(successful or not), the gateway will send a REPSTATUS message, reporting the address
claim status and the negotiated address.
Note:
• The Address Claim process is initiated by overwriting the Listen-Only mode
(gateway default) to Communication mode.
Setting the address range or not will impact the Address Claim process:
1. Full SAE J1939/81 compliant address claim with source address and alternative
address range:
The user can set a preferred source address, but, in case the address is already used in
the vehicle network, an alternative address range is available for the address claim
process.
2. Full SAE J1939/81 compliant address claim with only one source address:
Setting both address range parameters to 254 but submitting a source address (i.e.
setting the control application as non-arbitrary-address-capable) will reset the Arbitrary
Address Capable flag in the NAME.
Note:
13
• SETPARAM, SETPARAM1 will be rejected (i.e. no ACK will be sent) in case the
operating mode is set other than the defined values.
• The SETPARAM1 command (ID = 14) function is identical to the original
SETPARAM command, but in addition it initiates the REPSTATUS message, which
is being transmitted as soon as the Address Claim process is finished. This allows
the host’s program to wait for the REPSTATUS message to obtain the negotiated
source address.
Note:
• The gateway will return no message when the Request ID is not the REPSTATUS-
ID.
14
• Further request IDs may be added in future firmware versions.
Message Identifier: 8
Total Length: 6 bytes
Response: Depending on Request ID
The reported SA will be NULLADDRESS (254) when the address claim process is in
progress, the address claim failed, or the operating mode is Listen-Only. In case the
source address is 254, check the J1939 Protocol Status.
Message Identifier: 9
Total Length: 7 bytes
Response: -
15
FLASH – Starts the In-Circuit Programmer
This message starts the internal in-circuit programmer. This is usually invoked by pulling
a pin low during power-up, but with this function it can be started by the host system at
any time. A flash programming tool (Flash Magic) can be used after calling this function.
After sending the FLASH command, all LEDs on the jCOM.J1939will be on. In order to
switch back to normal operation, you need to go through a power-off-on cycle.
Message Identifier: 10
Total Length: 5 bytes
Response: -
Note:
• The ACK message will be active per default, unless overwritten by the host
system.
Message Identifier: 11
Total Length: 6 bytes
Response: ACK (only when activated)
16
SETHEART – Set Heartbeat Frequency
This message allows the setting of the heartbeat frequency in units of milliseconds. The
message frequency is assigned by two bytes, allowing a range of 100 – 5000
milliseconds, i.e. a time of less than 100 milliseconds will be corrected to 100, and a
time of more than 5000 will be corrected to 5000.
Note:
• Passing a heartbeat frequency of 0 will suppress the message, and it will not be
reset to the minimum time of 100 milliseconds.
Message Identifier: 12
Total Length: 7 bytes
Response: ACK
Message Identifier: 13
Total Length: 11 bytes
Response: -
17
8 SW_VERSIONMINOR xx
9 SW_VERSIONBUGFIX xx
10 CHKSUM xx
• 00 – ECU Message Mode (default after RESET) – The gateway reports only PGNs
addressed to the ECU’s source address or the global address.
• 01 – Gateway Message Mode 1 – The gateway reports PGNs addressed to all
destination addresses including the global address (255).
• 02 – Gateway Message Mode 2 – The gateway reports all PGNs as described in
mode 1 but also includes protocol PGNs according to SAE J1939/21 and SAE
J1939/81.
Message Identifier: 15
Total Length: 6 bytes
Response: ACK
18