Raptor:CAN Receive Message

From NewEagleWiki
Jump to navigation Jump to search

Return to the main Raptor page

Return to CAN page

Raptor CAN Receive Message

Description

This block is used to receive a CAN message. The Raptor™ CAN Rx Raw block can be used if the raw receive bytes are needed. This block accepts a standard DBC file which describes the messages and signals on a CAN bus. The DBC block will automatically decode and scale the signals defined in the DBC file.

A signal's initial value (aka the start value) can be defined in the DBC using signal attributes named 'GenSigStartValue'.

This block can receive messages on multiple ID's through the message ID filter ID and mask. For each bit in the mask parameter which contains a 1, the corresponding bit of the incoming message ID must match the corresponding bit in the ID parameter. Some modules do not support a fully open mask (all 0's). This block implements a similar filter called the payload mask which allows messages to be selected for receive based on the data content.

Each CAN rx block uses its own queue to buffer the incoming messages until the block can execute. If another message is received once the queue is full then the oldest message is overwritten. To always get the data from the last message set the queue size to 1.

The mailbox is a mechanism to link a CAN rx block with a CAN trigger block. This allows code to be executed whenever a message is received. The mailbox name must be unique for each receive block (if used), but can have multiple trigger blocks using the same mailbox name.

One Simulink Function can be triggered directly from this block, as if a CAN Trigger block had been used. A mailbox name must be defined in order to use this. The Simulink function should be placed somewhere along the calling block's path to model root.

Outputs

Output Type Description
Age uint16 The number of times this block has executed since a new message was received. Age is 0 when a new message is being output. Shown/hidden by the "Show Age" checkbox.
RawMsgData uint8[] Array containing the raw message data that was received.

It will contain the default Start Data on init if the 'Use Start Vals' option is checked; otherwise it will contain all zeroes on init. Shown/hidden by the "Show Raw Message" checkbox.

Signals All the signals defined and enabled in the dbc file.
Signals_raw The raw, unscaled bit values of all the signals defined and enabled in the dbc file.

Shown/hidden by the "Show Raw Outputs" checkbox.

Signals_start The unscaled start values of all the signals defined and enabled in the dbc file.

Signal attribute 'GenSigStartValue' is used to define a start value in the DBC; if the attribute is not defined for that signal, the value will be 0. Shown/hidden by the "Use Start Vals" checkbox.

Parameters

Parameter Type Description
.dbc File The dbc file being used. Click the Load button to select a new dbc file.
Message List A list of messages defined in the dbc file, click on a message name to select a new message.
Size/DLC Number The length of the CAN Message in bytes.
CAN Bus String The CAN bus to transmit the message on.
Mailbox String Identifies the mailbox trigger that is connected to this receive block.
Signal Order Select The option to how the signals are sorted within the GUI.
Edit ID Checkbox Allows the Message ID to be edited.
Message ID Number The ID used in the receive message filter. This is automatically set from the dbc file.
ID Mask Number The mask used in the receive message filter.
Queue Number Specifies the size of the receive queue.
Payload Value Vector The value used with the payload filter for messages. This will be set automatically for messages with a mode signal.
Payload Mask Vector The mask used with the payload filter. This value will be set automatically for messages with a mode signal.
Use CAN Trigger Simulink Function Callback checkbox Whether to use a Simulink Function callback with this block's mailbox.

The Mailbox field needs to be filled to use this callback. This works the same as using a CAN Trigger block with a priority of 0.

Simulink Function Name String Name of the Simulink Function to call when this block is triggered.
Create button Create a Simulink Function to call when this CAN RX Message block is triggered.

Must first provide a valid function name.

Update button Update the signature of an existing Simulink Function to have 0 inputs and 0 outputs.
Enable Checkbox Enable or disable signals within a message.
Remove Scaling Checkbox Enable or disable scaling of the signal.
Show ID Port Checkbox Makes the ID port available.
Label Port Signals Checkbox Enable this to automatically name the wires on the output ports with the names of the signals.
Use Start Vals Checkbox Enable this to specify signal start values from the DBC instead of using the default (all zeroes).

This also adds one extra output port per signal that provides the start value with scaling applied. Signal attribute 'GenSigStartValue' is used to define a start value in the DBC; if the attribute is not defined for that signal, the value will be 0.

Show Age Checkbox Adds a port providing the number of times this CAN Rx Message block has executed since a new message was received.

If no messages have been received yet, it gives 65535 (0xFFFF).

Include Raw Outputs Checkbox Adds a port for each output signal providing the raw, unscaled bit value of the field.
Include Raw Message Checkbox Adds a port providing the raw, unscaled byte array containing the entire message.