aboutsummaryrefslogtreecommitdiff
path: root/dev_darwin.go
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 /dev_darwin.go
parent91489f1134568813fd5fac1e651d21cfd91e4ccd (diff)
wip gohome, logging
Diffstat (limited to 'dev_darwin.go')
-rw-r--r--dev_darwin.go9
1 files changed, 7 insertions, 2 deletions
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()