Engee documentation

CAN RX

Page in progress.

Used to receive CAN messages.

can rx

Description

Unit CAN RX is used to receive CAN messages.

Message filter in the CAN RX unit

The length of the identifier of the received CAN message can be 29 bits (for extended frame format) or 11 bits (for standard frame format). The CAN message passes through the filter and is only received if all bits of the identifier have passed through the filter. If at least one bit of the message identifier does not pass the filter, the message is discarded. Settings Filter ID: и Mask: settings allow the filter to be set with respect to the individual identifier bits of the received CAN message.

The message passes the filter if the following condition is fulfilled:

CAN ID & Mask == Filter ID & Mask,

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

In other words, the operation of the filter can be represented as the following rules:

  • If the value Mask: for an individual bit is zero, this bit is not filtered. That is, this bit is not checked in the filter and passes through the filter.

  • If the value Mask: for an individual bit is equal to one, the value of this bit is filtered:

    • If the bit from CAN ID and the bit from Filter ID: are the same, this bit is passed through the filter.

    • If the bit from CAN ID and the bit from Filter ID: are different, this bit is not passed through the filter.


*An example of how the filter works:

Let the following CAN message filter be defined:

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

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

UInt32.

Complex numbers support

No

# Messages — array of received messages of type CAN_MESSAGE_BUS
vector

Details
Data types

Float64.

Complex numbers support

No

Parameters

Параметры

# Порт: — CAN port for receiving messages

Details
Default value

"can0"

Program usage name

m_port

Tunable

No

Evaluatable

Yes

# Число сообщений: — maximum number of messages transferred from the operating system buffer to the model for 1 calculation step

Details
Default value

1

Program usage name

m_messages

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: и Mask: as 0. Detailed description of the filter operation is given in the section Message filter in the CAN RX unit.

Default value

0x00

Program usage name

m_filter

Tunable

No

Evaluatable

Yes

# Mask: — calculation step in seconds for receiving CAN messages in a real-time application

Details
Default value

0x00

Program usage name

m_mask

Tunable

No

Evaluatable

Yes