CAN RX
It is used for receiving CAN messages.
blockType: EngeeFunction
Path in the library:
|
Description
To work with the block, install/update the support package. equipment. |
Block 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 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. Settings 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
-
-
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.
-
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 is from the CAN ID and the bit is from Filter ID: If they match, then this bit passes through the filter.
-
If the bit is from the CAN ID and the bit is 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 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 the 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
Ports
Output
#
Number of messages
—
number of received messages
scalar
Details
Not more than the value of the parameters Число сообщений:. If there are more messages in the operating system buffer, they will be transferred to the model at the next calculation step.
Data types |
|
Complex numbers support |
No |
#
Messages
—
array of received messages of type CAN_MESSAGE_BUS
vector
Details
Data types |
|
Complex numbers support |
No |
Parameters
Параметры
# Port: — CAN port for receiving messages
Details
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
# Число сообщений: — maximum number of messages transferred from the operating system buffer to the model for 1 calculation step
Details
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
# Filter ID: — filter of received messages at the OS level.
Details
To disable the filter and receive all messages, specify Filter ID: and Mask: as 0
. Detailed description of the filter operation is given in the section Message filter in the CAN RX block.
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |
# Mask: — calculation step in seconds for receiving CAN messages in a real-time application
Details
Default value |
|
Program usage name |
|
Tunable |
No |
Evaluatable |
Yes |