Description

isFilterEnabled( num, ext ) – returns true if the CAN-filter number num is active and returns false if disabled.

Syntax

if( MCAN0.isFilterEnabled( num, ext ) )

Parameters

uint8_t num– filter number – Standard 11bit: FILTER_0, FILTER_1 . . . FILTER_7) or
– Extended 29bit: FILTER_EXT_0, FILTER_EXT_1 . . . FILTER_EXT_7)
uint8_t ext – extended ID – 0 for a Standard 11bit ID filter definition
1 for an Extended 29 bit ID filter definition

Returns

bool true: filter is enabled
false: filter is disabled

Example Code

The following example configures filters, checks them and receives messages on the CAN bus (MCAN0).

void setup()
{
	while(!Serial);
	Serial.println("Setting filters for CAN0");
	
	// Set Single Standard ID filter (re-config FILTER_0)
	MCAN0.init_FiltID(FILTER_0, 0 , 0x0A5);
	
	// Disable the pre-configured FILTER_EXT_0 to not receive all msg. anymore
	MCAN0.disableFilter(FILTER_EXT_0, 1);
	
	Serial.print("Standard ID FILTER_0 is");
	if( MCAN0.isFilterEnabled( FILTER_0, 0 ) )
		Serial.println(" enabled");
	else
		Serial.println(" disabled");
		
	Serial.print("Extended ID FILTER_EXT_0 is");
	if( MCAN0.isFilterEnabled( FILTER_EXT_0, 1 ) )
		Serial.println(" enabled");
	else
		Serial.println(" disabled");
}
void loop()
{
	// Receive CAN messages
	if(MCAN0.checkReceive())
	{
		CANMessage t_canMesgToRecv;		// create a CAN message handle to receive
		if(MCAN0.readMsgBuf(t_canMesgToRecv) == CAN_OK)
			Serial.println("CAN0: "+t_canMesgToRecv.toString());
	}
}

Notes and Warnings

At start-up, the filters FILTER_0 and FILTER_EXT_0 are pre-configured to receive all standard (FILTER_0) and all extended IDs (FILTER_EXT_0). Please, consider that if you edit one filter that the other one is still active so that you might use disableFilter() to switch it off.
Always use the given defines FILTER_x/ FILTER_EXT_x for the parameter num.
When disabling a filter for standard IDs use num: FILTER_x and set ext:0, if a filter for extended identifiers should be configured, then use num: FILTER_EXT_x and set ext:1.

Allowing all messages:

In order to let all messages be accepted again, just set two filters as follows. One (e.g. FILTER_0) for all standard IDs and another one for all extended IDs (e.g. FILTER_EXT_0):

init_FiltID(FILTER_0,     0, 0, MSG_ID_ALLOW_ALL_MASK);
init_FiltID(FILTER_EXT_0, 1, 0, MSG_ID_ALLOW_ALL_MASK);

Examples can be found in the Arduino IDE menu:
File -> Examples -> DICE -> CAN Bus ->

See also

Find more details about the CAN buses of dice devices
disableFilter()
getFilterType()
Mask / ID filtering
defines
init_FiltRang()
init_FiltID()
SAMC21_CAN – Library
CAN operation background
users manual
BOOTLOADER SETTINGS – Library
samc21 datasheet