From 412efcb1aea3a0803dd3eeae24f80ce62de86238 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch
Date: Sun, 14 Apr 2019 21:34:56 +0200 Subject: Flush input buffers on printer initialization Seems to be necessary, not sure why. --- ql/ql_linux.go | 16 +++++++--------- sklad/main.go | 10 ++++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ql/ql_linux.go b/ql/ql_linux.go index 1b1f22c..9d465b5 100644 --- a/ql/ql_linux.go +++ b/ql/ql_linux.go @@ -108,16 +108,14 @@ func (p *Printer) Initialize() error { // Flush any former responses in the printer's queue. // - // I'm not sure if this is necessary, or rather whether the kernel driver - // does any buffering that could cause data to be returned at this point. - /* - var dummy [32]byte - for { - if _, err := f.Read(dummy[:]); err == io.EOF { - break - } + // I haven't checked if this is the kernel driver or the printer doing + // the buffering that causes data to be returned at this point. + var dummy [32]byte + for { + if _, err := p.File.Read(dummy[:]); err == io.EOF { + break } - */ + } return nil } diff --git a/sklad/main.go b/sklad/main.go index 9a7be68..4d6776e 100644 --- a/sklad/main.go +++ b/sklad/main.go @@ -185,10 +185,12 @@ func printLabel(id string) error { } defer printer.Close() - printer.StatusNotify = func(status *ql.Status) { - log.Printf("\x1b[1mreceived status\x1b[m\n%+v\n%s", - status[:], status) - } + /* + printer.StatusNotify = func(status *ql.Status) { + log.Printf("\x1b[1mreceived status\x1b[m\n%+v\n%s", + status[:], status) + } + */ if err := printer.Initialize(); err != nil { return err -- cgit v1.2.3-70-g09d2