Engee documentation

RITM-CAN RX

Receiving CAN messages.

blockType: CFunction

Path in the library:

/RITM/RITM CAN/RITM-CAN RX

Description

To work with the block, install/update the support package RITM blocks.

Block RITM-CAN RX It is used for receiving CAN messages.

Message filter in the CAN RX block

The length of the identifier of the received CAN message can be 29 bit (for extended frame format) or 11 bit (for the standard frame format). The CAN message passes through the filter and is accepted only if all the bits of the identifier have passed through the filter. If at least one bit of the message identifier has not passed through the filter, the message is discarded. Parameter values Filter ID: and Mask: allows you to set a filter based on individual bits of the identifier of the received CAN message.

The message passes through the filter if the following condition is met:

CAN ID & Mask == Filter ID & Mask,

where CAN ID is the identifier of the received CAN message.

In other words, the filter can be represented in the form of the following rules
  1. If the value is Mask: If an individual bit is zero, then this bit is not filtered. That is, this bit is not checked in the filter and passes through the filter.

  2. If the value is Mask: for a single bit, it is equal to one, then filtering is performed by the value of this bit.:

    • If the bit from CAN ID and the bit from Filter ID: If they match, then this bit passes through the filter.

    • If the bit from CAN ID and the bit from Filter ID: if they differ, then this bit does not pass through the filter.

Example of the filter operation

Let the following message filter be set.:

FilterID = 0b0100;
Mask     = 0b0110;

Messages with CAN identifiers 0x4, 0x5 and 0xC they pass through the filter and are accepted:

CAN_ID = [0b0100 0b0101 0b1100];
can_msg_passed = bitand(CAN_ID, Mask) == bitand(FilterID, Mask)
can_msg_passed =

  1×3 logical array

   1   1   1

Messages with CAN identifiers 0x1, 0x2 and 0x6 they do not pass through the filter and are discarded:

CAN_ID = [0b0001 0b0010 0b0110];
can_msg_passed = bitand(CAN_ID, Mask) == bitand(FilterID, Mask)
can_msg_passed =

  1×3 logical array

   0   0   0

Ports

Input

# RITM-CAN Setup — port descriptor port
scalar

Details

The receiver unit must be connected to the corresponding port configuration unit. RITM-CAN Setup.

Data types

Float64

Complex numbers support

No

Output

# Number of messages — the number of received messages available for reading from the output Messages
scalar

Details
Data types

UInt32

Complex numbers support

No

# Messages — received CAN message
the tire

Details

The received CAN message is in the form of a bus type CAN_MESSAGE_BUS.

Data types

BusSignal

Complex numbers support

No

Parameters

Параметры:

# Интерфейс CAN: — CAN port for receiving messages
CAN 1 | CAN 2 | CAN 3 | CAN 4 | CAN 5 | CAN 6 | CAN 7 | CAN 8

Details

The port numbers are indicated on the case of the KPM "RITM".

Values

CAN 1 | CAN 2 | CAN 3 | CAN 4 | CAN 5 | CAN 6 | CAN 7 | CAN 8

Default value

CAN 1

Program usage name

m_interfaceCAN

Tunable

No

Evaluatable

Yes

# Максимальное число сообщений: — maximum number of messages

Details

The maximum number of messages transferred from the operating system buffer to the model in one calculation step

Default value

1

Program usage name

m_maxMsgNum

Tunable

No

Evaluatable

Yes

# Шаг расчёта, с: — calculation step in seconds for receiving CAN messages in a real-time application

Details
Default value

-1

Program usage name

m_smplT

Tunable

No

Evaluatable

Yes

Фильтр:

# Filter ID: — filter received messages at the operating system level

Details

To disable the filter and receive all messages, set the parameters Filter ID: and Mask: value 0. For a detailed description of how the filter works, see the Message filter in the CAN RX block section.

Default value

0x00

Program usage name

m_canId

Tunable

No

Evaluatable

Yes

# Mask: — bitmask of the CAN message identifier filter

Details

Specifies which bits of the identifier of the received CAN message are involved in filtering at the operating system level. The message is accepted if the condition is met: CAN_ID & Mask == Filter_ID & Mask.

  • 0 in the bit Mask — the corresponding bit CAN_ID not checked (skipped);

  • 1 in the bit Mask — the corresponding bit CAN_ID must match the bit Filter_ID otherwise the message is discarded.

To disable the filter and receive all messages, set the parameters Filter ID: and Mask: value 0. For a detailed description of how the filter works, see the Message filter in the CAN RX block section. The CAN identifier can be long 11 bit (for extended frame format) or 11 bit (for standard frame format).

Default value

0x00

Program usage name

m_canMask

Tunable

No

Evaluatable

Yes