RITM-CAN RX
Receiving CAN messages.
blockType: CFunction
|
Path in the library:
|
Description
| To work with the block, install/update the support package RITM blocks. |
Block RITM-CAN RX It is used for receiving CAN messages.
Ports
Input
#
RITM-CAN Setup
—
port descriptor port
scalar
Details
The receiver unit must be connected to the corresponding port configuration unit.
| Data types |
|
| Complex numbers support |
No |
Output
#
Number of messages
—
the number of received messages available for reading from the output Messages
scalar
Details
| Data types |
|
| Complex numbers support |
No |
#
Messages
—
received CAN message
vector
Details
The received CAN message is in the form of a bus type CAN_MESSAGE_BUS.
| Data types |
|
| 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 |
|
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
# Максимальное число сообщений: — the maximum number of messages transferred from the operating system buffer to the model in 1 calculation step.
Details
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
# Шаг расчёта, с: — calculation step in seconds for receiving CAN messages in a real-time application
Details
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
Фильтр:
# Filter ID: — filter received messages at the OS level
Details
To disable the filter and receive all messages, set the Filter ID and Mask values 0. For a detailed description of how the filter works, see the Message filter in the CAN RX block section.
| Default value |
|
| Program usage name |
|
| 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 OS level. The message is accepted if the condition is met: CAN_ID & Mask == Filter_ID & Mask.
-
0in the bitMask— the corresponding bitCAN_IDnot checked (skipped); -
1in the bitMask— the corresponding bitCAN_IDmust match the bitFilter_IDotherwise the message is discarded.
To disable the filter and accept all messages, set Filter_ID = 0 and Mask = 0. The CAN identifier can be 11 bits long (Standard) or 29 bits long (Extended).
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
Message filter in the CAN RX block
The length of the identifier of the received CAN message can be 29 bits (for the extended frame format) or 11 bits (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. The Filter ID and Mask settings allow 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
-
-
If the Mask value for a single bit is zero, then this bit is not filtered. That is, this bit is not checked in the filter and passes through the filter.
-
If the Mask value for a single bit is one, then filtering is performed by the value of this bit.:
-
If the bit from the CAN ID and the bit from the Filter ID match, then this bit passes through the filter.
-
If the bit from the CAN ID and the bit from the Filter ID are different, 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 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 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
