Esempio n. 1
0
File: main.go Progetto: miters/gdmux
func sendPg() {
	log.Println("Sending over V+ code")
	s, err := serial.OpenPort(&serial.Config{Name: *ttyConsole, Baud: *baudConsole})
	if err != nil {
		log.Fatal(err)
	}
	defer s.Close()
	console := vplus.NewConsole(s)

	f := *dataRoot + "/pkg/staubli/V+/gcode.pg"

	err = console.Cmd("abort")
	if err != nil {
		log.Fatal("error sending file: ", f)
	}
	console.Expect()
	err = console.Cmd("kill")
	if err != nil {
		log.Fatal("error sending file: ", f)
	}
	console.Expect()
	err = console.UpdateFile(f)
	if err != nil {
		log.Fatal("error sending file: ", f)
	}
	err = console.Cmd(fmt.Sprintf("ex %s", path.Base(f)))
	if err != nil {
		log.Fatal("error sending file: ", f)
	}
}
Esempio n. 2
0
File: main.go Progetto: miters/gdmux
func main() {
	flag.Parse()

	if len(flag.Args()) == 0 {
		flag.Usage()
		os.Exit(1)
	}

	term, err := os.OpenFile(*terminal, os.O_APPEND|os.O_RDWR, os.ModeDevice)
	defer term.Close()
	if err != nil {
		log.Fatal("error opening device file: ", err)
	}

	console = vplus.NewConsole(term)

	// Quit the currently running V+ program, if one is.
	Cmd("abort")

	// Remove it from the stack so we can modify it.
	// TODO perhaps parse the output of 'status' and only kill the right process?
	// For now a couple of kill commands should do it, since it's unlikely that we're
	// running any more than that.
	Cmd("kill")
	Cmd("kill")

	for _, f := range flag.Args() {
		err = console.UpdateFile(f)
		if err != nil {
			log.Fatal("error sending file: ", f)
		}
	}

	if *execute {
		// Execute the first argument if we're running
		Cmd(fmt.Sprintf("ex %s", path.Base(flag.Args()[0])))
	}
}