aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-05-12 01:02:45 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-05-12 01:02:45 +0200
commitb89a07c5efff1b491560209d154f1ba57c297acd (patch)
treec3f2812db7ba75ee7584414512f33d8b8a9d54c2
parente4edf1d052ed00a1d99f86f58756926741a8337f (diff)
Add timeout
-rw-r--r--cutter.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/cutter.go b/cutter.go
index 9472b96..471c702 100644
--- a/cutter.go
+++ b/cutter.go
@@ -233,7 +233,16 @@ func (c Cutter) UnknownFE(n int) {
}
func (c Cutter) returnString() string {
- return c.Response()
+ ch := make(chan string, 1)
+ go func() {
+ ch <- c.Response()
+ }()
+ select {
+ case s := <-ch:
+ return s
+ case <-time.After(time.Second):
+ return "no response"
+ }
}
func (c Cutter) returnUnit() Unit {
@@ -303,7 +312,7 @@ func (c Cutter) Upgrade() bool {
// Educated Guss, not tested
func (c Cutter) EnableDebug() {
- c.Send("FPGRFCC1")
+ c.Send("FP,GRFCC1")
}
// Initialize ???