This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Configure CAN message filter to allow only specified messages





filterAllowOnly(canch,name) configures the filter on the channel canch to pass only messages with the specified name.

Set the channel object Database property to attach a database to allow filtering by message names.


filterAllowOnly(canch,IDs,type) configures the filter on the channel canch to pass only messages of the specified identifier type and values.


collapse all

Filter a database defined message with the name 'EngineMsg'

canch = canChannel('Vector','CANCaseXL 1',1);
canch.Database = canDatabase('candatabase.dbc');

Filter messages by identifiers.

canch = canChannel('Vector','CANCaseXL 1',1);
filterAllowOnly(canch,[602 612],'Standard')

Input Arguments

collapse all

CAN device channel, specified as a CAN channel object, on which to filter.

Example: canch = canChannel('NI','CAN1')

Name of CAN messages that you want to allow, specified as a character vector, string, or supporting array of these types.

Example: 'EngineMsg'

Data Types: char | string | cell

CAN message IDs that you want to allow, specified as a numeric value or vector.

Specify IDs as a decimal value. To convert a hexadecimal to a decimal value, use the hex2dec function.

Example: 600, [600,610], [600:800], [200:400,600:800]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Identifier type by which to filter, specified as a character vector or string. CAN messages identifier types are 'Standard' and 'Extended'.

Example: 'Standard'

Data Types: char | string

Introduced in R2011b