Channel example - J1939
This example demonstrates how to configure a channel to accept a single J1939[1] PGN.
We want to only accept messages with PGN \(61444_{10} = \text{F004}_{16}\)[3] (EEC1).
J1939 message frames use extended 29-bit CAN-IDs[2]. The Parameter Group Number (PGN) is defined by 18 of the 29 bits. The remaining 11 bits define the priority and source address of the message. It is often useful to configure a filter to accept a specific PGN regardless of the source address and the priority. Ignoring the source and priority bits can be done using the filter message ID mask (msgIDMask
).
Below, the left red bits represent the 3-bit priority, the green bits the 18-bit PGN and the right red bits the 8-bit source address of the 29-bit CAN-ID.
Message ID bits in positions with zero bits in the filter message ID mask (msgIDMask
) are ignored. By using \(\text{3FFFF00}_{16}\) as filter mask, the source and priority are ignored.
To only accept PGN \(61444_{10}\) we configure the filter as:
The filter
msgID
is set to the PGN value with the rightmost 8 bits representing the (ignored) source address (HEX value \(\text{F00400}_{16}\))The filter
msgIDMask
is set to the only consider the 18 PGN bits as derived above (HEX value \(\text{3FFFF00}_{16}\))
Note
The filter mask \(\text{3FFFF00}_{16}\) can be used for most J1939 PGN messages.
ID (HEX) |
Filter |
Note |
---|---|---|
0F00300 |
Reject |
PGN F003 |
0F00400 |
Accept |
PGN F004 with source address 0 |
0F00401 |
Accept |
PGN F004 with source address 1 |
0F00464 |
Accept |
PGN F004 with source address 100 |
4F00400 |
Accept |
PGN F004 with priority 1 |
0F00500 |
Reject |
PGN F005 |
The resulting channel configuration becomes:
CHN[4] |
channelEnb |
extendedID |
DSP[5] |
filteringEnb |
msgID |
msgIDMask |
---|---|---|---|---|---|---|
1 |
true |
true |
1 |
true |
F00400 |
3FFFF00 |
2 |
false |
false |
1 |
false |
00000000 |
1FFFFFFF |
3 |
false |
false |
1 |
false |
00000000 |
1FFFFFFF |
4 |
false |
false |
1 |
false |
00000000 |
1FFFFFFF |
5 |
false |
false |
1 |
false |
00000000 |
1FFFFFFF |
6 |
false |
false |
1 |
false |
00000000 |
1FFFFFFF |
7 |
false |
false |
1 |
false |
00000000 |
1FFFFFFF |
8 |
false |
false |
1 |
false |
00000000 |
1FFFFFFF |