|
|
|
@ -5,6 +5,7 @@ import ( |
|
|
|
|
"io" |
|
|
|
|
"log" |
|
|
|
|
"strings" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"github.com/tarm/serial" |
|
|
|
|
) |
|
|
|
@ -127,6 +128,7 @@ func handleResults(in io.Reader, c chan *Result) { |
|
|
|
|
|
|
|
|
|
func serialise(out io.Writer, command string, args []string, payload []byte) error { |
|
|
|
|
var quoted_args []string |
|
|
|
|
var err error |
|
|
|
|
|
|
|
|
|
quoted_args = append(quoted_args, command) |
|
|
|
|
|
|
|
|
@ -139,18 +141,23 @@ func serialise(out io.Writer, command string, args []string, payload []byte) err |
|
|
|
|
output := []byte(out_string) |
|
|
|
|
output = append(output, '\r') |
|
|
|
|
|
|
|
|
|
if payload != nil { |
|
|
|
|
output = append(output, payload...) |
|
|
|
|
output = append(output, 0x4) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_, err := out.Write(output) |
|
|
|
|
_, err = out.Write(output) |
|
|
|
|
// err is non nil if n != len(output)
|
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if payload == nil { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// FIXME: wait for command to finish
|
|
|
|
|
time.Sleep(time.Second) |
|
|
|
|
|
|
|
|
|
output = append(payload, 0x4) |
|
|
|
|
_, err = out.Write(output) |
|
|
|
|
|
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func handleCommands(out io.Writer, c chan *Command) { |
|
|
|
|