canFilterStatus (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

MX2 pro, DX4 pro, CX1 pro-c/warp-c, MX2 turbo/encore/warp, NX-200, NX-400, LX2, LX5

Firmware version:

1.40 / 1.00.00


This will return the status of a receive filter. The filter ID retrieved from canFilterCreate, canFilterCreateOnce, or canFilterCreateX must be used to identify the filter.

 

 

Input:

filterid : SINT

ID for the filter.

 

 

Returns: INT

-1

- Illegal filter ID.

0

- Filter not created.

1

- Filter active.

2

- Filter inactive (the number of received message has reached the limit for the filter).

 

Declaration:

FUNCTION canFilterStatus : INT;
VAR_INPUT
  filterid : SINT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR
  canRX : canReceiveMessage;
  buf   : ARRAY [1..8] OF SINT;
END_VAR;
 
PROGRAM CANExample;
VAR
  Filter_ID : SINT;
  FilterOnce : SINT;
  timer     : TON;
END_VAR;
 
// Open can
canOpen(baud := 250);
canRX(data := ADDR(buf));
 
// Open filters
timer.pt := 1000;
Filter_ID := canFilterCreate(xtd := TRUE, startID := 16#0EFDD600, length := 6);
 
BEGIN
  ...
  canRX();
  IF canRX.ready THEN
    DebugMsg(message:="Message received!");
    DebugFmt(message:="canRX.xtd= \1", v1:=INT(canRX.xtd));
    DebugFmt(message:="canRX.ID= \4", v4:=canRX.ID);
    DebugFmt(message:="canRX.DataSize= \1", v1:=INT(canRX.DataSize));
  END_IF;
  ...
  timer(trig := TRUE);
  IF timer.q THEN
    IF canFilterStatus(filterid := FilterOnce) <> 1 THEN
        canFilterDestroy(filterid := FilterOnce);
        FilterOnce := canFilterCreateOnce(xtd := TRUE, startID := 16#0E00FDD3, length := 1);
    END_IF;
     timer(trig := FALSE);
  END_IF;
  ...
END;
 
END_PROGRAM;