-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Build new USBCANChannel to go alongside renamed SocketCANChannel
- Loading branch information
Showing
8 changed files
with
397 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run USBCANTest", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "cmd/usbcantest/usbcantest.go" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/boatkit-io/tugboat/pkg/canbus" | ||
"github.com/brutella/can" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func main() { | ||
ctx := context.Background() | ||
options := canbus.USBCANChannelOptions{ | ||
SerialInterfaceName: "tty.usbserial-210", | ||
SerialBaudRate: 2000000, | ||
BitRate: 250000, | ||
FrameHandler: func(frame can.Frame) { | ||
fmt.Printf("handled frame: %+v\n", frame) | ||
}, | ||
} | ||
c := canbus.NewUSBCANChannel(logrus.StandardLogger(), options) | ||
if err := c.Run(ctx); err != nil { | ||
fmt.Printf("error: %v\n", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package canbus | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/brutella/can" | ||
) | ||
|
||
// Interface is a basic interface for a CANbus implementation | ||
type Interface interface { | ||
Run(ctx context.Context) error | ||
Close() error | ||
WriteFrame(frame can.Frame) error | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.