CANconfig(...,ADD_ID,...)

CANconfig(...,ADD_ID,...)

Description

Configures CAN BUS interface for reading. Adds CAN ID filter.

Syntax

CANconfig(id, ADD_ID, parameter, CAN_ID);

Parameters

Variable

Input

Variable

Input

id

CAN1 - Reset filters of CAN1.

CAN2 - Reset filters of CAN2.

ADD_ID

Gives command to add ID filter.

parameter

STANDARD - Add standard 11-bit CAN identifier.

EXTENDED - Add extended 29-bit CAN identifier.

CAN_ID

User defined can ID (for example 0x7C6).

Returns

Return value

Return explanation

SCRIPT_OPERATION_SUCCESS

Filter reset successful.

SCRIPT_OPERATION_FAILED

Failed to reset filter.

SCRIPT_NO_ACCESS

Failed to get access to specified CAN-BUS

SCRIPT_PARAM_INVALID

Invalid parameters.

Function call example

CANconfig example
#define CAN1_MODE_READ #include <can> // Include can library new can_rx_buffer[11]; forward public callback (event); public callback (event) { switch(event) { case CAN1: // CAN1 callback event { ReadCANmsg(CAN1, can_rx_buffer); } } return 0; } main() { Init(CAN1, NORMAL, 500000, CAN1_READ); CANconfig(CAN1, RESET_FILTER); // Reset all filters before setting new CANconfig(CAN1, ADD_ID, STANDARD, 0x7C6); // Configure Can id which is going to be read CANconfig(CAN1, ADD_ID, STANDARD, 0x7CF); // Configure Can id which is going to be read for(;;) { Delay(1000); } }

Notes and Warnings

  • Filter limitations:

    • on XG37 series devices:

      • 28 Extended Mask filters for both CANs in total;

      • 56 Extended ID filters for both CANs in total;

      • 56 Standard Mask filters for both CANs in total;

      • 112 Standard ID filters for both CANs in total.

    • Filters are shared with canbase_b - using CAN Vehicle Model will reduce free filters available for scripts.

  • Before using filter config, first it is recommended to use command RESET_FILTER, to clear all previously set filters.

Used in Examples

CAN example