Browse Source

Flush input buffers on printer initialization

Seems to be necessary, not sure why.
master
Přemysl Janouch 1 month ago
parent
commit
412efcb1ae
Signed by: Přemysl Janouch <p@janouch.name> GPG Key ID: A0420B94F92B9493
2 changed files with 13 additions and 13 deletions
  1. 7
    9
      ql/ql_linux.go
  2. 6
    4
      sklad/main.go

+ 7
- 9
ql/ql_linux.go View File

@@ -108,16 +108,14 @@ func (p *Printer) Initialize() error {
108 108
 
109 109
 	// Flush any former responses in the printer's queue.
110 110
 	//
111
-	// I'm not sure if this is necessary, or rather whether the kernel driver
112
-	// does any buffering that could cause data to be returned at this point.
113
-	/*
114
-		var dummy [32]byte
115
-		for {
116
-			if _, err := f.Read(dummy[:]); err == io.EOF {
117
-				break
118
-			}
111
+	// I haven't checked if this is the kernel driver or the printer doing
112
+	// the buffering that causes data to be returned at this point.
113
+	var dummy [32]byte
114
+	for {
115
+		if _, err := p.File.Read(dummy[:]); err == io.EOF {
116
+			break
119 117
 		}
120
-	*/
118
+	}
121 119
 
122 120
 	return nil
123 121
 }

+ 6
- 4
sklad/main.go View File

@@ -185,10 +185,12 @@ func printLabel(id string) error {
185 185
 	}
186 186
 	defer printer.Close()
187 187
 
188
-	printer.StatusNotify = func(status *ql.Status) {
189
-		log.Printf("\x1b[1mreceived status\x1b[m\n%+v\n%s",
190
-			status[:], status)
191
-	}
188
+	/*
189
+		printer.StatusNotify = func(status *ql.Status) {
190
+			log.Printf("\x1b[1mreceived status\x1b[m\n%+v\n%s",
191
+				status[:], status)
192
+		}
193
+	*/
192 194
 
193 195
 	if err := printer.Initialize(); err != nil {
194 196
 		return err

Loading…
Cancel
Save