Understanding CAN bus - mask

I’m having trouble understanding the can.addfilter function. I understand what the ID is, but not what mask is or how it works. Could someone explain the mask variable to me?

The ID is a number which has a binary representation and a mask is usually another binary number of the same width which has a set bit (1) in places you care about and 0s where you don’t care.

Here is another discussion about that

So if I only want data from a certain id, and don’t care about what it is, the mask is just the hex equivalent to 11111…?

Yup! That’s the plan, but AFAIK not setting the mask does exactly that (default exact match).

It requires a mask, so 0x7ff would be the exact match, right?