Channel example - Simple mask

This example extends example Channel example - Single ID to demonstrate a simple use of the filter message ID mask (msgIDMask).

We want to create a filter which accepts two standard ID messages with specific message IDs (using only Channel 1)[1]:

  • ID 1: \(2000_{10} = \text{7D0}_{16} = 11111010000_2\)

  • ID 2: \(2001_{10} = \text{7D1}_{16} = 11111010001_2\)

Note

Note that the binary representation of the IDs are identical except for the rightmost bit.

To do so, we enable Channel 1 (channelEnb to true) and enable filtering (filteringEnb to true).

  • The filter msgID can be set to either of the two message IDs, we arbitrarily select \(\text{7D0}_{16}\)

  • The filter msgIDMask is set to all ones except for the rightmost bit, \(11111111110_2 = \text{7FE}_{16}\)[2]

Note

Setting the rightmost bit of the filter mask to zero effectively makes the filter ignore the value of rightmost bit.

To test if messages with both ID \(\text{7D0}_{16}\) and \(\text{7D1}_{16}\) pass the filter, we apply the filter mask to both the filter message ID (1 in below) and the message IDs (2 in below)[3]. As the results are equal, both message IDs are accepted by the filter.

Note

In below X is used to indicate either 0 or 1 as the value of the bit does not matter (due to the mask)

\[\begin{split}\begin{array}{cc} \begin{array}{cc} \begin{array}{l} \text{Filter ID}\\ \text{Filter mask}\\ \text{Masked filter} \end{array} & \begin{array}{r} 11111010000_2\\ \&\color{green}{1111111111}\color{red}{0_2} \\\hline 11111010000_2 \end{array} \end{array} (1) & \begin{array}{cc} \begin{array}{l} \text{Message ID}\\ \text{Filter mask}\\ \text{Masked ID} \end{array} & \begin{array}{r} \text{1111101000X}_2\\ \&\color{green}{1111111111}\color{red}{0_2} \\\hline 11111010000_2 \end{array} \end{array} (2) \end{array}\end{split}\]

The resulting channel configuration becomes:

Compact overview of channel configurations

CHN[4]

channelEnb

extendedID

DSP[5]

filteringEnb

msgID

msgIDMask

1

true

false

1

true

7D0

7FE

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