diff --git a/can_adapter.go b/can_adapter.go index 0a5c4ef..3d551aa 100644 --- a/can_adapter.go +++ b/can_adapter.go @@ -19,4 +19,4 @@ func (cdb *CanDB) Recv() (*Frame, error) { panic("not implemented") // TODO: Implement } -func NewCanDB() +func NewCanDB() {} diff --git a/socketcan/netlink.go b/socketcan/netlink.go index 8ff2796..15e9a0c 100644 --- a/socketcan/netlink.go +++ b/socketcan/netlink.go @@ -1,3 +1,5 @@ +//go:build linux + package socketcan // TODO: implement netlink support to set baud rate and other parameters. diff --git a/socketcan/socketcan.go b/socketcan/socketcan.go index e6f4977..a8c231e 100644 --- a/socketcan/socketcan.go +++ b/socketcan/socketcan.go @@ -1,3 +1,5 @@ +//go:build linux + /* Package socketcan provides a wrapper around the Linux socketCAN interface. */ @@ -21,6 +23,12 @@ type CanSocket struct { fd int } +type CanFilter interface { + Inverted() bool + Mask() uint32 + Id() uint32 +} + // standardFrameSize is the full size in bytes of the default CAN frame. const standardFrameSize = unix.CAN_MTU @@ -96,15 +104,15 @@ func (sck *CanSocket) SetFDMode(enable bool) error { } // SetFilters will set the socketCAN filters based on a standard CAN filter list. -func (sck *CanSocket) SetFilters(filters []gotelem.CanFilter) error { +func (sck *CanSocket) SetFilters(filters []CanFilter) error { // helper function to make a filter. // id and mask are straightforward, if inverted is true, the filter // will reject anything that matches. - makeFilter := func(filter gotelem.CanFilter) unix.CanFilter { - f := unix.CanFilter{Id: filter.Id, Mask: filter.Mask} + makeFilter := func(filter CanFilter) unix.CanFilter { + f := unix.CanFilter{Id: filter.Id(), Mask: filter.Mask()} - if filter.Inverted { + if filter.Inverted() { f.Id = f.Id | unix.CAN_INV_FILTER } return f diff --git a/socketcan/socketcan_test.go b/socketcan/socketcan_test.go index be9c915..be21d2c 100644 --- a/socketcan/socketcan_test.go +++ b/socketcan/socketcan_test.go @@ -1,3 +1,5 @@ +//go:build linux + package socketcan import (