Skip to content

Commit

Permalink
feat: add interface
Browse files Browse the repository at this point in the history
It'll be easier to mock candevice functionality in other packages.
  • Loading branch information
ardrabczyk authored and Edholm committed Sep 28, 2023
1 parent 53338ac commit d98f4cd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/candevice/device_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,18 @@ type Device struct {
ifi ifInfoMsg
}

type CanDevice interface {
Bitrate() (uint32, error)
Info() (Info, error)
IsUp() (bool, error)
SetBitrate(uint32) error
SetDown() error
SetListenOnlyMode(bool) error
SetUp() error
}

// Creates a handle to a CAN device specified by name, e.g. can0.
func New(deviceName string) (*Device, error) {
func New(deviceName string) (CanDevice, error) {
iface, err := net.InterfaceByName(deviceName)
if err != nil {
return nil, err
Expand Down

0 comments on commit d98f4cd

Please sign in to comment.