Setting Mask and Filter for CAN Shield

I am planning to use the Seeed CAN shield for the UNO and have ordered it. I have a requirement to filter out message from a CAN bus that has both 11bit and 29 bit ID . There is an example code for this ( set_mask_filter_recv.ino) and the setup for it is as below which is set for one type only .... I am not how to modify this for only receiving data from both type of IDs 0x73E and 0x18FF0108 ?

( Tried to read the chapter 4.5 in the MCP2515 data sheet. Then immediately decided to ask here :wink: )

void setup() {
    SERIAL_PORT_MONITOR.begin(115200);
    while(!Serial){};
    attachInterrupt(digitalPinToInterrupt(CAN_INT_PIN), MCP2515_ISR, FALLING); // start interrupt
    while (CAN_OK != CAN.begin(CAN_250KBPS)) {             // init can bus : baudrate = 500k
        SERIAL_PORT_MONITOR.println("CAN init fail, retry...");
        delay(100);
    }
    SERIAL_PORT_MONITOR.println("CAN init ok!");

    /*
        set mask, set both the mask to 0x3ff
    */
    CAN.init_Mask(0, 0, 0x3ff);                         // there are 2 mask in mcp2515, you need to set both of them
    CAN.init_Mask(1, 0, 0x3ff);

    /*
        set filter, we can receive id from 0x04 ~ 0x09
    */
    CAN.init_Filt(0, 0, 0x04);                          // there are 6 filter in mcp2515
    CAN.init_Filt(1, 0, 0x05);                          // there are 6 filter in mcp2515

    CAN.init_Filt(2, 0, 0x06);                          // there are 6 filter in mcp2515
    CAN.init_Filt(3, 0, 0x07);                          // there are 6 filter in mcp2515
    CAN.init_Filt(4, 0, 0x08);                          // there are 6 filter in mcp2515
    CAN.init_Filt(5, 0, 0x09);                          // there are 6 filter in mcp2515
}

assuming you are using coryjfowler library, something like this should work:
(Compiles, NOT tested!)

#include <mcp_can.h>
#include <SPI.h>

long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];

MCP_CAN CAN0(10);                          // Set CS to pin 10

void setup()
{
  Serial.begin(115200);
  if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK) Serial.print("MCP2515 Init Okay!!\r\n");
  else Serial.print("MCP2515 Init Failed!!\r\n");
  pinMode(2, INPUT);                       // Setting pin 2 for /INT input


  CAN0.init_Mask(0,0,0x07FF0000);                // Init mask A... (used for the Std CAN msg here)
  CAN0.init_Filt(0,0,0x073E0000);                // Init first filter (Filter Bank A)...
  CAN0.init_Filt(1,0,0x073E0000);                // Init second filter (Filter Bank A)...
  
  CAN0.init_Mask(1,0,0x1FFFFFFF);                // Init mask B ... (used for the Ext CAN msg here)
  CAN0.init_Filt(2,0,0x18FF0108);                // Init third filter (Filter Bank B)...
  CAN0.init_Filt(3,0,0x18FF0108);                // Init fourth filter  (Filter Bank B)...
  CAN0.init_Filt(4,0,0x18FF0108);                // Init fifth filter  (Filter Bank B)...
  CAN0.init_Filt(5,0,0x18FF0108);                // Init sixth filter  (Filter Bank B)...
  
  Serial.println("MCP2515 Library Mask & Filter Example...");
  CAN0.setMode(MCP_NORMAL);                // Change to normal mode to allow messages to be transmitted
}

void loop()
{
    if(!digitalRead(2))                    // If pin 2 is low, read receive buffer
    {
      CAN0.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s)
      Serial.print("ID: ");
      Serial.print(rxId, HEX);
      Serial.print(" Data: ");
      for(int i = 0; i<len; i++)           // Print each byte of the data
      {
        if(rxBuf[i] < 0x10)                // If data byte is less than 0x10, add a leading zero
        {
          Serial.print("0");
        }
        Serial.print(rxBuf[i], HEX);
        Serial.print(" ");
      }
      Serial.println();
    }
}

hope that helps....

Here is a calculator that may help. CAN bus mask and filter calculator