You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
727 B
44 lines
727 B
package main
|
|
|
|
import (
|
|
"cli-mon/can"
|
|
"cli-mon/ui"
|
|
"cli-mon/yabl"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
filename := flag.String("f", "", "Candump filename")
|
|
canbus := flag.String("i", "", "CAN bus interface")
|
|
stdin := flag.Bool("s", false, "Read from stdin")
|
|
flag.Parse()
|
|
|
|
var frames <-chan *can.CanFrame
|
|
|
|
switch {
|
|
case *stdin:
|
|
frames = can.ReadStdin()
|
|
case len(*filename) > 0:
|
|
frames = can.Readfile(filename)
|
|
case len(*canbus) > 0:
|
|
var err error
|
|
frames, err = can.StartCan(*canbus)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
default:
|
|
flag.Usage()
|
|
}
|
|
|
|
if frames == nil {
|
|
fmt.Println("Get no data")
|
|
os.Exit(0)
|
|
}
|
|
|
|
var messages = yabl.StartProtocolParsing(frames)
|
|
|
|
ui.InitCliApp(messages)
|
|
}
|
|
|