|
|
|
@ -12,11 +12,22 @@ var ( |
|
|
|
|
serial_device = flag.String("serial-device", "/dev/ttyUSB0", "Serial device to use") |
|
|
|
|
serial_baudrate = flag.Int("serial-baud", 9600, "Serial baud rate") |
|
|
|
|
|
|
|
|
|
commands = map[string]CommandFunc{"hi": cmd_hi, "ls": cmd_ls, "cat": cmd_cat, "time": cmd_time, "bootversion": cmd_bootversion, "bootok": cmd_bootok} |
|
|
|
|
commands = map[string]CommandFunc{ |
|
|
|
|
"hi": cmd_hi, |
|
|
|
|
"buzzer": cmd_buzzer, |
|
|
|
|
"led": cmd_led, |
|
|
|
|
"reset": cmd_reset, |
|
|
|
|
"ls": cmd_ls, |
|
|
|
|
"cat": cmd_cat, |
|
|
|
|
"date": cmd_date, |
|
|
|
|
"time": cmd_time, |
|
|
|
|
"boot_version": cmd_bootversion, |
|
|
|
|
"boot_ok": cmd_bootok, |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func cmd_generic(tbm *TBM, command string, args []string) error { |
|
|
|
|
cmd := &Command{command, args} |
|
|
|
|
func cmd_generic(tbm *TBM, command string, args []string, payload []byte) error { |
|
|
|
|
cmd := &Command{command, args, payload} |
|
|
|
|
tbm.Commands <- cmd |
|
|
|
|
res := <-tbm.Results |
|
|
|
|
|
|
|
|
@ -29,27 +40,43 @@ func cmd_generic(tbm *TBM, command string, args []string) error { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_hi(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "hi", []string{"v20170802 testing"}) |
|
|
|
|
return cmd_generic(tbm, "hi", []string{"v20170802 testing"}, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_buzzer(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "buzzer", args, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_led(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "led", args, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_reset(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "reset", args, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_ls(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "ls", args) |
|
|
|
|
return cmd_generic(tbm, "ls", args, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_cat(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "cat", args) |
|
|
|
|
return cmd_generic(tbm, "cat", args, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_date(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "time", args, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_time(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "time", args) |
|
|
|
|
return cmd_generic(tbm, "time", args, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_bootversion(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "booting", args) |
|
|
|
|
return cmd_generic(tbm, "booting", args, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func cmd_bootok(tbm *TBM, args []string) error { |
|
|
|
|
return cmd_generic(tbm, "booting", []string{"ok"}) |
|
|
|
|
return cmd_generic(tbm, "booting", []string{"ok"}, nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
|