From 68a4ed0b73bece074ceafc2890db99cbd83f282f Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 2 May 2015 18:28:52 +0200 Subject: Fix ETX --- cutter.go | 29 +++++++++++++---------------- doc/TestCutIntel.plt | 22 +++++++++++++++++++++- main.go | 2 +- usb.go | 4 ++-- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/cutter.go b/cutter.go index 5ce877b..e54b818 100644 --- a/cutter.go +++ b/cutter.go @@ -53,23 +53,23 @@ func NewCutter(io *bufio.ReadWriter, o Orientation) Cutter { if !c.Ready() { fmt.Println("not ready") } + c.CR() // Home v, _ := c.Version() fmt.Println("Craft ROBO Ver.", v) - m := MediaID[113] - c.MediaType(m.ID) - c.Speed(m.Speed) - c.Force(m.Thickness) - c.UnknownFC(m.FC) + pen := MediaID[113] + c.MediaType(pen.ID) + c.Speed(pen.Speed) + c.Force(pen.Thickness) + c.UnknownFC(pen.FC) + c.TrackEnhancing(On) c.UnknownFE(0) - p := c.GetCalibration() - fmt.Println("Calibration", p) + fmt.Println("Calibration", c.GetCalibration()) + fmt.Println("FA", c.UnknownFA()) - p = c.UnknownFA() - fmt.Println("FA", p) c.Orientation(o) return Cutter{io} @@ -82,8 +82,8 @@ const ( ) func (c Cutter) Send(a ...interface{}) { - a = append(a, ETX) fmt.Fprint(c, a...) + c.WriteByte(ETX) c.Flush() } @@ -183,8 +183,7 @@ func (c Cutter) readResponse() (string, error) { // Version requests hardware version func (c Cutter) Version() (string, error) { - c.WriteString("FG") - c.Flush() + c.Send("FG") return c.readResponse() } @@ -194,8 +193,7 @@ func (c Cutter) MediaType(n int) { } func (c Cutter) ReadUpperRight() (string, error) { - c.WriteString("U") - c.Flush() + c.Send("U") return c.readResponse() } @@ -293,8 +291,7 @@ func (c Cutter) BootVersion() (string, error) { // Upgrade starts update sequence // Send raw S-Record data after func (c Cutter) Upgrade() (bool, error) { - c.WriteString("CC1VERUP") - c.Flush() + c.Send("CC1VERUP") ans, err := c.readResponse() return ans == string(NUL), err } diff --git a/doc/TestCutIntel.plt b/doc/TestCutIntel.plt index 48a4435..3861099 100644 --- a/doc/TestCutIntel.plt +++ b/doc/TestCutIntel.plt @@ -1 +1,21 @@ -FN0,&100,100,100,^0,0,\0,0,M510,637,BZ1,510,637,439,637,383,580,383,510,BZ1,383,510,383,439,439,383,510,383,BZ1,510,383,580,383,637,439,637,510,BZ1,637,510,637,580,580,637,510,637,M764,764,D256,764,D256,256,D764,256,D764,764,M2,510,D1018,510,M510,1018,D510,2,M0,0, \ No newline at end of file +FN0,&100,100,100,^0,0,\0,0,M510,637,BZ1,510,637,439,637,383,580,383,510,BZ1,383,510,383,439,439,383,510,383,BZ1,510,383,580,383,637,439,637,510,BZ1,637,510,637,580,580,637,510,637,M764,764,D256,764,D256,256,D764,256,D764,764,M2,510,D1018,510,M510,1018,D510,2,M0,0, + +FN0 +&100,100,100 +^0,0 +\0,0 +M510,637 +BZ1,510,637,439,637,383,580,383,510 +BZ1,383,510,383,439,439,383,510,383 +BZ1,510,383,580,383,637,439,637,510 +BZ1,637,510,637,580,580,637,510,637 +M764,764 +D256,764 +D256,256 +D764,256 +D764,764 +M2,510 +D1018,510 +M510,1018 +D510,2 +M0,0 diff --git a/main.go b/main.go index f15fcc7..32e2e11 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ func main() { //defer cu.LineType(Solid) //cu.Raw([]string{"L100,1,400,100"}) - //cu.TestCut() + cu.TestCut() //cu.TestPattern() //cu.EasterEgg() //cu.DrawMarks() diff --git a/usb.go b/usb.go index aab16b6..81a9031 100644 --- a/usb.go +++ b/usb.go @@ -24,8 +24,8 @@ var ( func init() { // bump timeouts to one minute - usb.DefaultReadTimeout *= 60 - usb.DefaultWriteTimeout *= 60 + usb.DefaultReadTimeout *= 10 + usb.DefaultWriteTimeout *= 10 } func CC100(desc *usb.Descriptor) bool { -- cgit v1.2.3