aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-09-25 14:35:58 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-09-25 14:35:58 +0200
commit06fe0f88b8cfb51ab7e58c3d6ef5c8c940963ed8 (patch)
treee32a98e609f3dfd1f24a313c3b1ab03a0a0df24d
parent91489f1134568813fd5fac1e651d21cfd91e4ccd (diff)
wip gohome, logging
-rw-r--r--cmd/version/main.go1
-rw-r--r--dev_darwin.go9
-rw-r--r--plot.go6
3 files changed, 12 insertions, 4 deletions
diff --git a/cmd/version/main.go b/cmd/version/main.go
index 53bfa16..ed780fb 100644
--- a/cmd/version/main.go
+++ b/cmd/version/main.go
@@ -19,4 +19,5 @@ func main() {
}
ver := r.Version()
fmt.Println("Version:", ver)
+ r.GoHome()
}
diff --git a/dev_darwin.go b/dev_darwin.go
index c49fd75..305a696 100644
--- a/dev_darwin.go
+++ b/dev_darwin.go
@@ -4,6 +4,7 @@ import (
"bufio"
"errors"
"io"
+ "log"
"github.com/kylelemons/gousb/usb"
)
@@ -97,16 +98,19 @@ func (d USB) Close() error {
// ReadString reads until End of Text
func (d USB) ReadString() (string, error) {
buf := bufio.NewReader(d.Reader)
- resp, err := buf.ReadString(ETX)
+ s, err := buf.ReadString(ETX)
if err != nil {
return "", err
}
- return resp[:len(resp)-1], nil
+ s = s[:len(s)-1]
+ log.Printf(">>> %q", s)
+ return s, nil
}
// WriteString terminates transfer with End of Text
func (d USB) WriteString(s string) error {
buf := bufio.NewWriter(d.Writer)
+ log.Printf("<<< %q", s)
buf.WriteString(s)
buf.WriteByte(ETX)
return buf.Flush()
@@ -115,6 +119,7 @@ func (d USB) WriteString(s string) error {
// Command prefixes transfer with Escape
func (d USB) Command(b []byte) error {
buf := bufio.NewWriter(d.Writer)
+ log.Printf(">>> %q", b)
buf.WriteByte(ESC)
buf.Write(b)
return buf.Flush()
diff --git a/plot.go b/plot.go
index d939b7f..39953ba 100644
--- a/plot.go
+++ b/plot.go
@@ -2,7 +2,6 @@ package robo
import (
"fmt"
- "log"
"strings"
)
@@ -70,6 +69,9 @@ func (r Robo) Init() {
func (r Robo) Ready() bool {
r.dev.Command([]byte{5})
resp, _ := r.dev.ReadString()
- log.Printf("ready %q", resp)
return resp == "0"
}
+
+func (r Robo) GoHome() {
+ r.dev.WriteString("TT")
+}