diff --git a/include/hexagram/cluster.h b/include/hexagram/cluster.h index a3f1cad..ca9e83f 100644 --- a/include/hexagram/cluster.h +++ b/include/hexagram/cluster.h @@ -1,10 +1,9 @@ #ifndef _HEXAGRAM_CLUSTER_H #define _HEXAGRAM_CLUSTER_H -#include - #include +#include #include #include #include @@ -37,6 +36,8 @@ void hexagram_cluster_init(hexagram_cluster *cluster, hexagram_cluster *hexagram_cluster_new(double width, double height); +int hexagram_cluster_filter_can_if(hexagram_can_if *can_if); + int hexagram_cluster_update(hexagram_cluster *cluster, struct can_frame *frame); diff --git a/src/cluster.c b/src/cluster.c index 93d4679..9fdd989 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -72,6 +72,20 @@ error_malloc_cluster: return NULL; } +int hexagram_cluster_filter_can_if(hexagram_can_if *can_if) { + struct can_filter filters[3] = { + { .can_id = 0x280, .can_mask = 0x3f0 }, + { .can_id = 0x320, .can_mask = 0x320 }, + { .can_id = 0x5a0, .can_mask = 0x5a0 } + }; + + return setsockopt(hexagram_can_if_fd(can_if), + SOL_CAN_RAW, + CAN_RAW_FILTER, + &filters, + sizeof(filters)); +} + int hexagram_cluster_update(hexagram_cluster *cluster, struct can_frame *frame) { switch (frame->can_id) {