From b89a07c5efff1b491560209d154f1ba57c297acd Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 12 May 2015 01:02:45 +0200 Subject: Add timeout --- cutter.go | 13 +++++++++++-- 1 file 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 ??? -- cgit v1.2.3