File: canfilter.cpp

package info (click to toggle)
savvycan 220-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,456 kB
  • sloc: cpp: 61,803; sh: 293; javascript: 91; python: 44; makefile: 8
file content (27 lines) | stat: -rw-r--r-- 436 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "canfilter.h"

CANFilter::CANFilter()
{
    ID = 0;
    mask = 0;
    bus = -1;
}

void CANFilter::setFilter(uint32_t id, uint32_t mask, int bus)
{
    this->ID = id;
    this->mask = mask;
    this->bus = bus;
}

bool CANFilter::checkFilter(uint32_t id, int bus)
{
    if (bus == -1 || bus == this->bus)
    {
        uint32_t result = id & this->mask;
        if (result == this->ID) return true;
    }
    return false;

}