remove vcantest (use canplayer instead)

This commit is contained in:
saji 2023-07-06 15:22:00 -05:00
parent 9280067d87
commit 43b84dc0fb

View file

@ -3,14 +3,12 @@
package cli package cli
import ( import (
"strings"
"time" "time"
"github.com/kschamplin/gotelem" "github.com/kschamplin/gotelem"
"github.com/kschamplin/gotelem/skylab" "github.com/kschamplin/gotelem/skylab"
"github.com/kschamplin/gotelem/socketcan" "github.com/kschamplin/gotelem/socketcan"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"golang.org/x/exp/slog"
) )
// this file adds socketCAN commands and functionality when building on linux. // this file adds socketCAN commands and functionality when building on linux.
@ -43,7 +41,6 @@ type socketCANService struct {
} }
func (s *socketCANService) Status() { func (s *socketCANService) Status() {
return
} }
func (s *socketCANService) String() string { func (s *socketCANService) String() string {
@ -59,16 +56,11 @@ func (s *socketCANService) Start(cCtx *cli.Context, deps svcDeps) (err error) {
logger := deps.Logger logger := deps.Logger
broker := deps.Broker broker := deps.Broker
if cCtx.String("can") == "" { if cCtx.IsSet("can") {
logger.Info("no can device provided") logger.Info("no can device provided")
return return
} }
// vcan demo system - make fake packets.
if strings.HasPrefix(cCtx.String("can"), "v") {
go vcanTest(cCtx.String("can"))
}
s.sock, err = socketcan.NewCanSocket(cCtx.String("can")) s.sock, err = socketcan.NewCanSocket(cCtx.String("can"))
if err != nil { if err != nil {
logger.Error("error opening socket", "err", err) logger.Error("error opening socket", "err", err)
@ -151,28 +143,3 @@ Various helper utilties for CAN bus on sockets.
}, },
}, },
} }
func vcanTest(devname string) {
sock, err := socketcan.NewCanSocket(devname)
if err != nil {
slog.Error("error opening socket", "err", err)
return
}
testPkt := skylab.WslMotorCurrentVector{
Iq: 0.1,
Id: 0.2,
}
id, data, _ := skylab.ToCanFrame(&testPkt)
testFrame := gotelem.Frame{
Id: id,
Data: data,
Kind: gotelem.CanSFFFrame,
}
for {
slog.Info("sending test packet")
sock.Send(&testFrame)
time.Sleep(1 * time.Second)
}
}